I want to configure Eclipse (or Codeblocks) so that when I write a pass, I can at least take advantage of Intellisense (even if building passes directly from within Eclipse is not possible). Update: I am getting at least some intellisense once I enabled Parsing-based Proposals in Eclipse (details below)
So far I have configured Eclipse to use clang to compile simple C++ programs.
To get intellisense for LLVM pass, I added /usr/local/include
to Includes directories and tried code:
#include <iostream>
#include <llvm/IR/Function.h>
using namespace std:
int main() {
cout << "Hello World" << endl;
return 0;
}
It doesn't fail on #include <llvm/IR/Function.h>
itself (i.e. it can find this header file), but upon including subsequent files, gives me
/usr/local/include/llvm/Support/DataTypes.h:58:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
Any pointers to how I could make it give me intellisense at least?
Complete Log
01:22:48 **** Rebuild of configuration Debug for project HelloWorld2 ****
Info: Internal Builder is used for build
clang++ -I/usr/local/include -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/HelloWorld2.bc ../src/HelloWorld2.cpp
In file included from ../src/HelloWorld2.cpp:10:
In file included from /usr/local/include/llvm/IR/Function.h:22:
In file included from /usr/local/include/llvm/IR/Argument.h:17:
In file included from /usr/local/include/llvm/ADT/Twine.h:14:
/usr/local/include/llvm/Support/DataTypes.h:58:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
^
/usr/local/include/llvm/Support/DataTypes.h:62:3: error: "Must #define __STDC_CONSTANT_MACROS before " "#including Support/DataTypes.h"
# error "Must #define __STDC_CONSTANT_MACROS before " \
^
In file included from ../src/HelloWorld2.cpp:10:
In file included from /usr/local/include/llvm/IR/Function.h:22:
In file included from /usr/local/include/llvm/IR/Argument.h:19:
In file included from /usr/local/include/llvm/IR/Attributes.h:19:
In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14:
In file included from /usr/local/include/llvm/ADT/SmallVector.h:20:
/usr/local/include/llvm/Support/MathExtras.h:273:24: error: use of undeclared identifier 'INT64_C'
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
^
/usr/local/include/llvm/Support/MathExtras.h:273:56: error: use of undeclared identifier 'INT64_C'
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
^
/usr/local/include/llvm/Support/MathExtras.h:299:26: error: use of undeclared identifier 'UINT64_C'
return N >= 64 || x < (UINT64_C(1)<<(N));
^
/usr/local/include/llvm/Support/MathExtras.h:331:24: error: use of undeclared identifier 'INT64_C'
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
^
/usr/local/include/llvm/Support/MathExtras.h:331:56: error: use of undeclared identifier 'INT64_C'
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
^
In file included from ../src/HelloWorld2.cpp:10:
In file included from /usr/local/include/llvm/IR/Function.h:22:
In file included from /usr/local/include/llvm/IR/Argument.h:19:
In file included from /usr/local/include/llvm/IR/Attributes.h:19:
In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14:
/usr/local/include/llvm/ADT/SmallVector.h:232:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
void push_back(T &&Elt) {
^
/usr/local/include/llvm/ADT/SmallVector.h:476:33: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
iterator insert(iterator I, T &&Elt) {
^
/usr/local/include/llvm/ADT/SmallVector.h:645:46: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SmallVectorImpl &operator=(SmallVectorImpl &&RHS);
^
/usr/local/include/llvm/ADT/SmallVector.h:383:12: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto I = this->end(), E = this->begin() + N; I != E; ++I)
^
/usr/local/include/llvm/ADT/SmallVector.h:764:70: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SmallVectorImpl<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&RHS) {
^
/usr/local/include/llvm/ADT/SmallVector.h:878:27: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SmallVector(SmallVector &&RHS) : SmallVectorImpl<T>(N) {
^
/usr/local/include/llvm/ADT/SmallVector.h:883:44: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
const SmallVector &operator=(SmallVector &&RHS) {
^
In file included from ../src/HelloWorld2.cpp:10:
In file included from /usr/local/include/llvm/IR/Function.h:22:
In file included from /usr/local/include/llvm/IR/Argument.h:19:
In file included from /usr/local/include/llvm/IR/Attributes.h:20:
In file included from /usr/local/include/llvm/ADT/FoldingSet.h:21:
/usr/local/include/llvm/Support/Allocator.h:134:70: error: expected expression
BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>> {
^
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected a type
};
^
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected class name
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected '{' after base class list
/usr/local/include/llvm/Support/Allocator.h:362:53: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SpecificBumpPtrAllocator(SpecificBumpPtrAllocator &&Old)
^
/usr/local/include/llvm/Support/Allocator.h:366:64: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
SpecificBumpPtrAllocator &operator=(SpecificBumpPtrAllocator &&RHS) {
^
/usr/local/include/llvm/Support/Allocator.h:375:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto DestroyElements = [](char *Begin, char *End) {
^
/usr/local/include/llvm/Support/Allocator.h:375:28: error: expected expression
auto DestroyElements = [](char *Begin, char *End) {
^
/usr/local/include/llvm/Support/Allocator.h:381:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E;
^
/usr/local/include/llvm/Support/Allocator.h:381:29: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E;
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:381:58: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E;
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:383:52: error: no member named 'computeSlabSize' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
size_t AllocatedSlabSize = BumpPtrAllocator::computeSlabSize(
~~~~~~~~~~~~~~~~~~^
/usr/local/include/llvm/Support/Allocator.h:384:35: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
std::distance(Allocator.Slabs.begin(), I));
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:386:35: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:386:60: error: no member named 'CurPtr' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:392:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto &PtrAndSize : Allocator.CustomSizedSlabs) {
^
/usr/local/include/llvm/Support/Allocator.h:392:39: error: no member named 'CustomSizedSlabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>'
for (auto &PtrAndSize : Allocator.CustomSizedSlabs) {
~~~~~~~~~ ^
/usr/local/include/llvm/Support/Allocator.h:392:27: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (auto &PtrAndSize : Allocator.CustomSizedSlabs) {
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
13 warnings and 20 errors generated.
01:22:50 Build Finished (took 1s.509ms)
UPDATE: Eclipse does give me intellisense (at least some of it), I had to check Parsing-based Proposals in Window -> Preferences -> C/C++ -> Editor -> Content Assist -> Advanced (It was unchecked by default).
This is not answering the question directly, but it will ensure, you have a correctly working build environment. It is specific for code blocks.
First checkout the source tree of llvm (directly taken from the getting started guide):
git clone http://llvm.org/git/llvm.git
cd llvm/tools
git clone http://llvm.org/git/clang.git
cd ..
cd projects
git clone http://llvm.org/git/compiler-rt.git
git clone http://llvm.org/git/libcxx.git
git clone http://llvm.org/git/libcxxabi.git
git clone http://llvm.org/git/test-suite.git
git clone http://llvm.org/git/openmp.git
Remove anything you don't like.
Then create an directory outside the llvm directory:
cd ..
mkdir build
Change your directory (cd) to there and run:
cd build
cmake -g "CodeBlocks - Unix Makefiles" <your configure options> ../llvm
Assuming llvm shares the root path, otherwise change the ../llvm line to the correct path. Then open it as an existing project in code::blocks.
If all went well, your build environment is setup correctly and code completion should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With