llvm-clang

Arguments to attribute constructor style functions

坚强是说给别人听的谎言 提交于 2019-12-12 17:53:12
问题 I've seen code like this: (Apple based code) __attribute__((constructor)) void do_action(int argc, const char **argv, const char **envp, const char **things, struct ProgramVars *) { // } Which is odd to be because I read that constructors style functions are supposed to be void. Where are those arguments coming from, can I choose what those parameters can be? Is this an Apple only thing for gcc/clang? This code is supposed to be used with DYLD_INSERT_LIBRARIES, (Linux's LD_PRELOAD). Is that a

Is any way to get llvm deference pointer value's raw type(i.e. pointer type)

跟風遠走 提交于 2019-12-12 04:48:41
问题 Maybe the title is somehow confused. but let me show you a example. void foo(int val) { // do something } int i = 27; int* pi = &i; foo(*pi); Here, if we compile it using clang, the type of *pi will be i32, but we know pi is pointer type. my question is we use Function::getgetFunctionParamType method, the result will be i32. but how do I use some wayst to get ' pi ' type, not ' *pi ' type? This problem has confused me some days. Update: I see some people confused this question. Alright, I

clang-analyzer-alpha.unix.PthreadLock check missing from clang-tidy version 3.8 and 4.0?

£可爱£侵袭症+ 提交于 2019-12-12 02:33:07
问题 I am trying to modernize my module's C++ source code using clang-tidy. A few weeks ago, I downloaded and built clang and clang tools version 3.9 and when I ran it on one of my cpp files I got clang-analyzer-alpha.unix.PthreadLock saying that lock has already been taken. Later, because of space constraints I removed that version of clang and used version 3.8 and 4.0 available in our 3rd party repos. In both of these versions, I did not get any warnings regarding this alpha check. How do I

How to build clang with MINGW on winodws?

こ雲淡風輕ζ 提交于 2019-12-11 18:45:53
问题 I am trying to build clang from the source code using MINGW on Windows 8. I downloaded the clang from the source and other necessary tools from the official page of llvm clang-llvm source code : git clone https://github.com/llvm/llvm-project.git cmake and ninja I downloaded just like in the below page http://clang.llvm.org/docs/LibASTMatchersTutorial.html I m running on terminal and giving the following commands cmake -GNinja -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt"

Duplicate protocol definition warning

孤人 提交于 2019-12-11 14:32:29
问题 First, I have seen this question as well as this, but my problem is not addressed there. I have a protocol ProtocolA defined in its own header file. Then I have two classes ClassA and ClassB which both conform to this protocol so the protocol-header is imported in their header files. Now it gets a bit complicated. ClassA is used (and thus imported) in a third ClassC . This class conforms to a second protocol ProtocolB . This protocol also has its own header file where it uses and imports

Method to create LLVM IR

只愿长相守 提交于 2019-12-11 11:42:36
问题 I am creating clang tool and I want to generate LLVM IR from clang AST. I am aware of -emit-llvm option that I can use to get *.ll file, but is there way to generate IR inside code? Some method that I can call that takes clang AST or AST context and returns llvm::Module ? I cannot find any example that shows this. Edited: So I tried using CodeGenAction for this, but I can't get it to work. I end up with unresolved external symbol error. Am I missing something? #include <clang/CodeGen

Unable to run windows binary compiled with clang/lld/mingw

人盡茶涼 提交于 2019-12-11 11:27:03
问题 I have downloaded and installed clang on windows 10 from http://releases.llvm.org/download.html and mingw from https://sourceforge.net/projects/mingw-w64/ I am trying to compile a very basic C program using clang/lld/mingw: int main(int argc, char* argv[argc + 1]) { return 0; } To compile I invoke: clang.exe -target x86_64-windows-gnu -fuse-ld=lld.exe -g -gcodeview -Wl,/debug,/pdb:example.pdb example.c -o example.exe This creates an exe which faults on startup in mainCRTStartup (__security

unique_ptr as class member and move semantics fail to compile with clang

浪尽此生 提交于 2019-12-11 07:51:15
问题 I can't get clang (Apple LLVM version 4.2 (clang-425.0.28)) to compile these classes: struct A { int f(){return 2;} }; class Cl{ std::unique_ptr<A> ptr; public: Cl(){ptr = std::unique_ptr<A>(new A);} Cl(const Cl& x) : ptr(new A(*x.ptr)) { } Cl(Cl&& x) : ptr(std::move(x.ptr)) { } Cl(std::unique_ptr<A> p) : ptr(std::move(p)) { } void m_ptr(std::unique_ptr<A> p){ ptr = std::unique_ptr<A>(std::move(p)); } double run(){return ptr->f();} }; I would like to run the constructor as follows: std:

build clang from source using specific gcc toolchain

瘦欲@ 提交于 2019-12-11 06:40:02
问题 I'm building clang from source, but using a gcc 7.2 build that doesn't live in the normal spot. I want the resulting clang++ binary to use this toolchain by default. I tried to do: $ export GCC_PREFIX=/path/to/gcc/7.2 $ mkdir -p build $ cd build $ cmake -G Ninja -DCMAKE_C_COMPILER=${GCC_PREFIX}/bin/gcc \ -DCMAKE_CXX_COMPILER=${GCC_PREFIX}/bin/g++ \ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_TARGETS_TO_BUILD=X86 .. But the resulting build just looks in /usr/include/c++/4.8.5 for standard library

How do I get a homebrewed version of GDB working on Mac OS X Nr. 2?

故事扮演 提交于 2019-12-11 02:46:01
问题 I installed XCode 5.1 with clang I installed gcc 4.8 via homebrew Installed gdb 7.7.1 via homebrew Using OSX 10.9.3 I compile my c++ source in eclipse kepler with a Makefile using g++-4.8 and try to debug it but when reaching a breakpoint I can't see any variables just like in this question: GDB says "no symbol table," but nm shows file has debug symbols I followed the suggestions of @Tom Tromey in the suggestions section of that question to use set complaints 10000 in gdb and then load the