llvm

Print the type of a parameter (ParmVarDecl) with clang API

谁都会走 提交于 2019-12-03 06:35:54
I need to print the type of a parameter in a C++ source file using the clang API. If I have a parameter representation in clang ( ParmVarDecl* param ) I can print the name of the parameter using param->getNameAsString() . I would need a method param->getTypeAsString() , but there is no such method. So is there another way to do this task? Got the answer to my question in the llvm irc: There is a method std::string clang::QualType::getAsString(SplitQualType split) So this does work for me: ParmVarDecl* param = *someParameter; cout << QualType::getAsString(param->getType().split()) << endl; You

“too many errors emitted stopping now” - How to increase or remove the limit?

陌路散爱 提交于 2019-12-03 06:22:33
So I'm doing some refactoring and it's really annoying that I don't get all the errors up front. How can I either increase the limit or remove the limit, so that the compiler will output all the errors it can find? Erik B So I found how to do it. You add this compiler flag: -ferror-limit=0 0 means that it will not stop because of too many errors. This seems to be a question and answer that explains how to add a compiler flag in Xcode 4: Xcode Project-Wide compiler flag Maybe this: Preferences > General > Continue Building After Errors https://developer.apple.com/library/ios/recipes/xcode_help

Build 32-bit with 64-bit llvm-gcc

好久不见. 提交于 2019-12-03 06:19:45
I have a 64-bit version of llvm-gcc, but I want to be able to build both 32-bit and 64-bit binaries. Is there a flag for this? I tried passing -m32 (which works on the regular gcc), but I get an error message like this: [jay@andesite]$ llvm-gcc -m32 test.c -o test Warning: Generation of 64-bit code for a 32-bit processor requested. Warning: 64-bit processors all have at least SSE2. /tmp/cchzYo9t.s: Assembler messages: /tmp/cchzYo9t.s:8: Error: bad register name `%rbp' /tmp/cchzYo9t.s:9: Error: bad register name `%rsp' ... This is backwards; I want to generate 32-bit code for a 64-bit processor

Using homebrew, gcc and llvm with C++ 11

非 Y 不嫁゛ 提交于 2019-12-03 05:57:00
问题 Here's my problem: I want to use C++11 features provided by either gcc or clang. However, I have these requirements: I'm using a mac I'm dependent on a bunch of libraries provided by homebrew (and really don't want to compile them myself). Specifically OSG, which itself is dependent on a ton of other libraries. And boost, though I can always compile that myself. Homebrew seems to only want to use gcc (please correct me if I'm wrong). I can't find any options to switch to LLVM instead. While I

STL/Boost equivalent of LLVM SmallVector?

五迷三道 提交于 2019-12-03 04:59:31
I have been trying to see if I can optimize the case when having many small vectors of data. In my use case there may be 100,000+ of these vectors so the size of the vector storage is critical. Each may only have 1 or 2 elements at times but may grow larger capacities in many cases. I have tried using a simple std::vector but this is incredibly slow as it allocates N small buffers on the heap which wastes memory and takes far too long in a time-critical environment. Effectively a small-buffer-optimization (SBO) on a vector seems to look like a viable solution. This means the internal (i.e.

What are canonical types in Clang?

笑着哭i 提交于 2019-12-03 04:55:42
问题 I have a simple header parser based on clang and I get the typedefs from some source. struct _poire { int g; tomate rouge; }; typedef struct _poire kudamono; After parsing this I have a clang::TypedefDecl then I get the clang::QualType of the typedef with clang::TypedefDecl::getUnderlyingType() With the QualType if I use the getAsString method I can find the "struct _poire" std::string . All this is Ok. The problem is if I try to see if this type is a canonical type, with QualType:

Generating LLVM Code from Java

半世苍凉 提交于 2019-12-03 04:51:40
I want to use the LLVM code generation Framework from Java. I.e., I do not want to compile Java code into LLVM. I simply want an LLVM library for code generation that I can call from Java. The usual LLVM library is C, so I cannot use it. Are there any Java ports? If no, what would be the easiest way to do it anyway? Wrap the API into JNI? A quick search for llvm java api bindings turned out several projects that seem like a good fit: LLVM-J JLLVM LAJ All of those libraries use JNI to access the C-API, so you have a DLL or SO file of the LLVM itself in any case. To answer the question with more

performance comparison - gcc and llvm-gcc

一世执手 提交于 2019-12-03 03:54:42
I compared gcc and llvm-gcc with -O3 option on hmmer and mcf in spec cpu2006 benchmark. Surprisingly, I found gcc beat llvm-gcc for both cases. Is it because the -O3 has different meanings? How should I establish the experiments to get a fair comparison? BTW, I did the experiment by ONLY changing cc in the makefile. Thanks, Bo bobbogo You seem surprised that gcc beat llvm on your benchmark. Phoronix hosts a bunch of interesting benchmarks in this area. For instance, have a look at: Benchmarking LLVM & Clang Against GCC 4.5 . Compiler Benchmarks Of GCC, LLVM-GCC, DragonEgg, Clang ∶ (Lots of

How can I implement a string data type in LLVM?

房东的猫 提交于 2019-12-03 03:52:27
问题 I have been looking at LLVM lately, and I find it to be quite an interesting architecture. However, looking through the tutorial and the reference material, I can't see any examples of how I might implement a string data type. There is a lot of documentation about integers, reals, and other number types, and even arrays, functions and structures, but AFAIK nothing about strings. Would I have to add a new data type to the backend? Is there a way to use built-in data types? Any insight would be

Generating LLVM code for 'lambda', 'define'

限于喜欢 提交于 2019-12-03 03:47:13
问题 So I now have a fairly complete LISP (scheme) interpreter written in haskell. Just for fun I want to try to have it compile down to LLVM. Most of the code generation seems pretty straight forward, but I'm at a loss as to how to generate code for a lambda expression (kind of important in lisp ;) ) and how to manage the heap when I encounter a define expression. How might I generated code for these expressions? Note: I can generate code for the body of the lambda expression, What is confusing