llvm-clang

Unable to force a clang CompilerInstance object to parse a header as C++ file

柔情痞子 提交于 2019-12-10 04:13:43
问题 I have a C++ header called class.h that I want to parse: class MyClass { public: Class() {} ~Class() {} bool isTrue() const; bool isFalse() const; private: bool m_attrib; }; bool MyClass::isTrue() const { return true; } bool MyClass::isFalse() const { return false; } I use clang a compiler Instance with an AST consumer. All my code works well with c source file. But I am unable to configure/force the langage that the CompilerInstance must use. Here is the code I use : m_ci = new clang:

Unable to cross-compile to SPARC using clang

五迷三道 提交于 2019-12-10 04:13:18
问题 So here's the situation: I need to be able to compile binaries from a Linux machine (on Ubuntu, for what it's worth) which are able to run from a SPARC server. The program I'm trying to compile is very simple: #include <stdio.h> #include <stdlib.h> int main() { printf("Testing the SPARC program..."); return EXIT_SUCCESS; } I've tried a number of different compile lines to get it to work, but unfortunately nothing appears to be working. I tried the traditional: clang -target sparc blah.c -o

lldb is not starting an application

余生长醉 提交于 2019-12-09 18:22:09
问题 this is my first experience in commandline mode of lldb. unsuccessful. installed minimal kit with clang, lld, lldb v5 (ubuntu 16.04) sample application built with clang. trying to start: lldb applcation >run error: process launch failed: unable to locate lldb-server-5.0.0 so now the questions: why lldb tries to run a server? this is not a remote debugging. why lldb refers to 5.0.0 (and where to change this setting)? actually there was added symbolic links automiticaly with xxx-5.0 suffix to

how to build BPF program out of the kernel tree

末鹿安然 提交于 2019-12-09 12:53:55
问题 The kernel provides a number of examples in samples/bpf . I am interested in building one of examples outside of the tree, just like we build a kernel module, where Makefile can be simple enough. Is it possible to do the same with bpf? I tried it by ripping out unnecessary parts from samples/bpf/Makefile and keeping dependencies to libbpf and others, however it turned out to be not that easy. For example, trying to build samples/bpf/bpf_tcp_kern.c outside of the kernel tree, with the

Integrating LLVM passes

你说的曾经没有我的故事 提交于 2019-12-09 06:46:17
问题 This maybe a rookie question but is there a way to integrate my LLVM modulepass to be called by default during the transformation phase? Right now I am using this syntax to load my pass and register it ~/llvm/llvm/build/Debug+Asserts/bin/clang -Xclang -load -Xclang ~/llvm/llvm/build/Debug+Asserts/lib/SOMEPASSLIB.so (The problem is when I want to build some package with this pass, the compiler accepts it when I say, pass the loading part as CFLAGS env variable, but some makefiles use CFLAGS

Clang IfStmt with shortcut binary operator in condition

为君一笑 提交于 2019-12-08 12:43:12
问题 I am trying to detect if there is a function call inside an if statement as part of condition; like following: if (cmp(a, b)){ \\do something } I have found I could do this with AST matcher in following manner: Matcher.addMatcher(ifStmt(hasCondition(callExpr().bind("call_expr"))) .bind("call_if_stmt"),&handleMatch); But the problem is condition could have shortcuts like &&, ||; like following: if(a != b && cmp(a,b) || c == 10){ \\ do something } Now this condition has binaryoperator && and ||

Clang Linking error: undefined reference to function calls added by LLVM pass

限于喜欢 提交于 2019-12-08 10:43:14
问题 So I am following this tutorial https://www.cs.cornell.edu/~asampson/blog/llvm.html to make a pass that instruments a program by adding calls to an external function (which is logop in rtlib.c). But unlike the tutorial I am trying to instrument a larger code-base which is masstree: https://github.com/kohler/masstree-beta. So as instructed for masstree I run ./configure first but then I edit the generated Makefile to use clang (instead of gcc/g++) and run my pass. I also add rtlib.c in the

Undefined symbols for architecture x86_64: “std::terminate()”, when building kaleidoscope llvm

不羁的心 提交于 2019-12-08 08:39:23
问题 I'm doing the kaleidoscope tutorial. I'm on step two. https://github.com/westymatt/creole But I get this error when building with clang++ clang++ -Wno-c++11-extensions -g -std=c++11 -I/usr/local/Cellar/llvm/3.6.1/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS src/lexer.cc src/parser.cc -L/usr/local/Cellar/llvm/3.6.1/lib/ -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData

How do I link when building with llvm libraries?

混江龙づ霸主 提交于 2019-12-08 07:55:12
问题 I am trying to parse a LLVM-IR file(.ll) and do a static analysis.. I found this sample code below, and I tried to build it, but I don't know which library to link. #include <iostream> #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IRReader/IRReader.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; int main(int argc, char** argv) { if (argc < 2) { errs() << "Expected an argument - IR file name\n"; exit(1); }

Clang Tool (libtooling): set header search path to standard libs headers. Foundation framework

坚强是说给别人听的谎言 提交于 2019-12-08 02:06:08
问题 related link http://kevinaboos.wordpress.com/2013/07/23/clang-tutorial-part-ii-libtooling-example I'am using CommonOptionsParser to parse arguments for clang tool: // parse the command-line args passed to your code CommonOptionsParser op(argc, argv); // create a new Clang Tool instance (a LibTooling environment) ClangTool Tool(op.getCompilations(), op.getSourcePathList()); // run the Clang Tool, creating a new FrontendAction (explained below) int result = Tool.run(newFrontendActionFactory