Questions tagged [llvm-clang]

Clang is the C language family front-end for the LLVM compiler. (The C language family includes C, C++, Objective-C, and Objective-C++.)

Clang refers to the C language family front-end for the LLVM (originally known as "low level virtual machine") compiler. The C language family consists of C, C++, Objective-C, and Objective-C++.

High-level features of clang include better compile-time performance than gcc, helpful error and warning messages, and a static analyzer to automatically detect software bugs.

1101 questions
8
votes
1 answer

Issue with extensions in Objective-C

The following is a code snippet which deals with class extensions. What I am trying to do is generate a random ID called internal ID (that is used by the program later on) which is stored in an encrypted form in memory. The code fails to compile…
hecate
  • 620
  • 1
  • 8
  • 33
8
votes
1 answer

VisitDecl vs. TraverseDecl (Clang RecursiveASTVisitor)

I've read this link but still don't fully understand what's the difference between TraverseDecl and VisitDecl (and their use case) http://clang.llvm.org/doxygen/classclang_1_1RecursiveASTVisitor.html Which method should I be overriding when writing…
8
votes
1 answer

Using clang matchers to detect sequence of patterns

Is it possible to use clang matchers to identify sequence of patterns in a program? For example I need to find cases in which pattern1 happens before pattern2. For instance: Pattern1 = assigning a value to pointer P pattern2 = dereferencing pointer…
Mehrnoosh EP
  • 161
  • 7
8
votes
1 answer

LLVM struct array iteration

While compiling this code with LLVM: struct bar { int int1; int int2; char char1; char char2; char char3; }; struct foo { struct bar array[16]; }; int func(struct foo *f, int num) { for(int i = 0; i < num; i++){ …
Eitan Ziv
  • 81
  • 2
8
votes
3 answers

Using swift compiler for bare metal?

I would really like to use swift for embedded programming as I feel like its a much better replacement for c++, The processor I'm using is an ARM Cortex-M4F(http://www.ti.com/tool/ek-tm4c123gxl). Looking at the swift compiler page, it says you can…
jack sexton
  • 1,227
  • 1
  • 9
  • 28
8
votes
1 answer

LLVM LoopInfo in FunctionPass doesn't compile

i'm starting to learn llvm api and i wrote my first pass. My goal is to print how functions call each others. Lately i wanted to add some loop information to the display to look if a function can be call several time or not. But when i try to use…
islandia
  • 91
  • 1
  • 6
8
votes
1 answer

Xcode and C11 stdatomic.h

Seems like Xcode 5 and higher supports C11 but when I try to include stdatomic.h it says it can not find the file? Is it possible to use C11 atomic structures in Xcode?
bitwise
  • 541
  • 6
  • 16
8
votes
1 answer

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

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…
cedlemo
  • 3,205
  • 3
  • 32
  • 50
8
votes
1 answer

How to disable automatic "pass by pointer" optimization in clang++?

I have a function void X(Object o) { .... } When I compile it, I see, that clang changes its signature to void X(Object* o) It is inconvenient, because I use this function from some llvm IR code directly. How to forbid it from doing this…
Necto
  • 2,594
  • 1
  • 20
  • 45
8
votes
1 answer

Identifying user define function through llvm pass

Is there anyway by which I can identify whether the callee function is a user define or not? For example: void foo() { printf("hello world again"); } int main() { printf("hello world\n"); foo(); } As in this case foo() is a user define,…
Abhinash Jain
  • 169
  • 10
8
votes
2 answers

Objective-C naming conventions with ARC and possible caveats

I have experience with pure ARC coding. As a compiler feature it honors Objctive-C method family putting right retain/release calls whenever neeeded. All methods that start with alloc, mutableCopy, copy and new create a new object. They increase the…
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
7
votes
2 answers

libclang: error: clang-c/Index.h: No such file or directory

i was trying to use clang to parse c++ code, but am unable to compile my source code because i am unable to find libclang headers. I am running ubuntu 10.04 and have installed clang and llvm successfully from the repositories. Please tell me where…
ConfusedAboutCPP
  • 573
  • 3
  • 8
  • 20
7
votes
1 answer

Clang - Getting SubstTemplateTypeParm full template information

I am traversing a clang AST, but am having trouble getting the desired information when traversing the type information of a declaration of the AST that contains a clang::SubstTemplateTypeParmType. Given the following minimal input code to clang…
Justin
  • 447
  • 4
  • 10
  • 33
7
votes
1 answer

Are there any builtins to tell compiler whether a branch is predictable?

I'm not asking about things like __builtin_expect. I'm thinking of the case where I don't know that a branch will be usually true or usually false, but I do know that it's predictable (or not). I would expect the compiler, knowing a branch is…
Brennan Vincent
  • 10,736
  • 9
  • 32
  • 54
7
votes
2 answers

Location of the generated header "MyProject-Swift.h"

I am working on a project with mixed Objective-C and Swift; I followed the "Using Swift with Cocoa and Objective-C" guide by Apple and it works great. Out of curiosity, I would like to locate and read the generated header described in the "Mix and…
Axel Guilmin
  • 11,454
  • 9
  • 54
  • 64