簡體   English   中英

配置Eclipse CDT或Codeblocks以獲取LLVM IR intellisense

[英]Configure Eclipse CDT or Codeblocks to get LLVM IR intellisense

我想配置Eclipse(或Codeblocks),這樣當我編寫一個pass時,我至少可以利用Intellisense(即使直接從Eclipse內部構建傳遞也是不可能的)。 更新:一旦我在Eclipse中啟用基於解析的建議 ,我至少得到了一些智能感知(詳情如下)

到目前為止,我已經將Eclipse配置為使用clang來編譯簡單的C ++程序。

為了獲得LLVM傳遞的intellisense,我將/usr/local/includeIncludes目錄並嘗試了代碼:

#include <iostream>
#include <llvm/IR/Function.h>

using namespace std:
int main() {
    cout << "Hello World" << endl;
    return 0;
}

它在#include <llvm/IR/Function.h>本身沒有失敗(即它可以找到這個頭文件),但是在包含后續文件時,給了我

/usr/local/include/llvm/Support/DataTypes.h:58:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"

任何關於我如何制作它的指示至少給我智能感知?

完成日志

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)

更新: Eclipse確實給了我intellisense(至少其中一些),我必須在窗口中檢查基於解析的提議 - >首選項 - > C / C ++ - >編輯器 - >內容輔助 - >高級 (默認情況下未選中) 。

這不是直接回答問題,但它將確保您擁有正確工作的構建環境。 它特定於代碼塊。

首先檢查llvm的源代碼樹(直接從入門指南中獲取):

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

刪除任何你不喜歡的東西。

然后在llvm目錄外創建一個目錄:

 cd ..
 mkdir build 

將目錄(cd)更改為並運行:

 cd build 
 cmake -g "CodeBlocks - Unix Makefiles" <your configure options> ../llvm 

假設llvm共享根路徑,否則將../llvm行更改為正確的路徑。 然后在code :: blocks中將其作為現有項目打開。

如果一切順利,您的構建環境將正確設置並且代碼完成應該可行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM