llvm

How to get a list of all global declarations of a C/C++ program using Clang?

喜欢而已 提交于 2020-01-11 05:19:51
问题 I'm trying to write a program that lists all of the publicly exported variables and functions of a C or C++ program by using Clang. I followed part 05 of this tutorial, but it doesn't work for current version of clang. Above that, I got some hints that CompilerInstance can make the code shorter, but I'm not entirely sure how to use it. How would you implement this functionality? Can you give me any pointers into the right direction? For example: is there a large hash table of globally

Build llvm ClangTool

本秂侑毒 提交于 2020-01-10 14:16:23
问题 I managed to build llvm and clang and now I am trying to create a ClangTool according to clang docs. But I am getting the following error when I am trying to build it: CMake Error at tools/clang/tools/loop-convert/CMakeLists.txt:6 (target_link_libraries): The keyword signature for target_link_libraries has already been used with the target "loop-convert". All uses of target_link_libraries with a target must be either all-keyword or all-plain. The uses of the keyword signature are here: *

Build llvm ClangTool

六眼飞鱼酱① 提交于 2020-01-10 14:16:11
问题 I managed to build llvm and clang and now I am trying to create a ClangTool according to clang docs. But I am getting the following error when I am trying to build it: CMake Error at tools/clang/tools/loop-convert/CMakeLists.txt:6 (target_link_libraries): The keyword signature for target_link_libraries has already been used with the target "loop-convert". All uses of target_link_libraries with a target must be either all-keyword or all-plain. The uses of the keyword signature are here: *

LLVM一个简单的Pass

女生的网名这么多〃 提交于 2020-01-10 02:05:28
1 // Before : 2 // entry 3 // | 4 // ______v______ 5 // | switch | 6 // |_____________| 7 // | 8 // +---------------+ 9 // | _____________ 10 // +------->| case1 |-------+ 11 // | |_____________| | 12 // +------->| case2 |-------+ 13 // | |_____________| | 14 // +------->| case3 |-------+ 15 // | |_____________| | 16 // +------->| case4 |-------+ 17 // | |_____________| | 18 // +------->| case5 |-------+ 19 // | |_____________| | 20 // +------->| default |-------+ 21 // |_____________| | 22 // | 23 // +--------------+ 24 // | 25 // v 26 // return 27 // 28 // After : 29 // entry 30 // | 31 // _

LLVM get constant integer back from Value*

隐身守侯 提交于 2020-01-09 09:59:07
问题 I create a llvm::Value* from a integer constant like this: llvm::Value* constValue = llvm::ConstantInt::get( llvmContext , llvm::APInt( node->someInt() )); now i want to retrieve the compile-time constant value back; int constIntValue = constValue->??? The examples shown in LLVM Programmer manual seem to imply that cast<> will accept a pointer when using the type (rather than the type plus pointer) template parameter, however i'm pretty sure thats failing as from 2.8: llvm::Value* foo = 0;

LLVM get constant integer back from Value*

那年仲夏 提交于 2020-01-09 09:58:27
问题 I create a llvm::Value* from a integer constant like this: llvm::Value* constValue = llvm::ConstantInt::get( llvmContext , llvm::APInt( node->someInt() )); now i want to retrieve the compile-time constant value back; int constIntValue = constValue->??? The examples shown in LLVM Programmer manual seem to imply that cast<> will accept a pointer when using the type (rather than the type plus pointer) template parameter, however i'm pretty sure thats failing as from 2.8: llvm::Value* foo = 0;

LLVM assertion error

浪子不回头ぞ 提交于 2020-01-07 08:32:00
问题 I'm trying to use LLVM/Clang API to compile the source code to LLVM IR. clang_ir.cpp: #include <iostream> #include <clang/Driver/Compilation.h> #include <clang/Driver/Driver.h> #include <clang/Frontend/TextDiagnosticPrinter.h> #include <llvm/Support/Host.h> #include <llvm/Support/Program.h> #include <llvm/Support/raw_ostream.h> using namespace std; using namespace clang; using namespace clang::driver; int main(int argc, char** argv) { cout << "Starting ----" << std::endl; // [clang -S -emit

Finding all possible paths in a c/c++ program by LLVM

戏子无情 提交于 2020-01-07 02:03:29
问题 I am trying to find any possible path in my program by LLVM. Right now I can find paths from entry to exit BB of all functions in my code. However that's not what I need. What I need is extending CFG (maybe by inlining function calls?!) to have a CFG for entire source code and find paths in this extended CFG. I was thinking of using -inline pass first to inline all functions first and then run my pathfinder pass but as I observed -inline works only for functions which are explicitly mentioned

Building Gold linker in FreeBSD

坚强是说给别人听的谎言 提交于 2020-01-06 19:06:17
问题 I followed the steps on http://llvm.org/docs/GoldPlugin.html#lto-how-to-build to build the gold plugin on FreeBSD but ! Heres a link to the screenshot of the error:http://postimg.org/image/anlpuufbl/ This is the error message that it shows and so I am also unable to get ld-new. I checked and no CFLAGS were set in etc/make.conf. How to proceed with the installation? I am using the deault clang version supplied with FreeBSD 10.1. 回答1: I think you just need to install devel/binutils port or its

How to implement arrays - llvm

心不动则不痛 提交于 2020-01-06 05:25:22
问题 I am working on a toy language written using the llvm c++ api and I am trying to implement arrays. I have tried several different things none of which have worked very well. Here is what I am going for: A type that can resemble an array (struct, vector or array would work) Can be passed to and returned from functions Can have infinitely nested arrays (eg. [8 x [8 x [8 x [...] ) Can be re-assignable Arrays are all of the same type Arrays are of finite length specified on creation. Ideally,