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
16
votes
5 answers

Why does objective-c not have API availability checking?

Swift 2 have API availability checking. The compiler will give you an error when using an API too new for your minimum target OS Why can't the objective-c compiler do the equivalent? I googled objective c API availability checking and only swift…
oky_sabeni
  • 7,672
  • 15
  • 65
  • 89
15
votes
2 answers

llvm and install time optimization

Based on LLVM official page, it is possible to have install-time optimization, based on my understanding, which first compiles to bytecode on build machine before distribution, and then on target machines, converts the bytecode to native code when…
Kan Li
  • 8,557
  • 8
  • 53
  • 93
14
votes
3 answers

Getting clang-tidy to fix header files

I'm in the process of moving a project currently compiling with gcc to clang, and have a bunch of warnings that gcc didn't generate (-Winconsistent-missing-override). clang-tidy works for fixing these errors in the *.cpp files, however it doesn't…
nishantjr
  • 1,788
  • 1
  • 15
  • 39
14
votes
1 answer

Unresolved extern when compiling OpenCL to PTX using Clang?

I'm following the instructions on this SO answer but when I try to run the resulting PTX file I get the follow error in clBuild ptxas fatal : Unresolved extern function 'get_group_id' In the PTX file I have the following for every OpenCL function…
Andrew
  • 2,519
  • 6
  • 29
  • 46
14
votes
1 answer

Make an LLVM ModulePass available on clang command line

I have a ModulePass that's working with the opt tool, but I'm having trouble figuring out how to make it available to clang at the command line. My current workflow for using my pass is: clang -c -emit-llvm [c-source code files] llvm-link [llvm…
Erik
  • 301
  • 2
  • 10
13
votes
1 answer

What is an indirect goto statement?

In Clang API, there is a GotoStmt and an IndirectGotoStmt. There is very little explanation on the difference between these two kinds of goto statments. I know what a goto label; statement is. But what is an indirect goto statement? I want to know…
Galaxy
  • 2,363
  • 2
  • 25
  • 59
13
votes
3 answers

Cross-compiling from Linux to Windows with Clang

I am trying to cross-compile C applications from Linux (64 bit) to Windows (64 bit) using Clang. I read the page on cross-compilation, which wasn't too helpful. As a simple test, I have the following code in test.c: #include int main() { …
Rogue
  • 636
  • 8
  • 22
13
votes
2 answers

Clang VS VC++:"error: declaration of 'T' shadows template parameter"

I was trying to compile the following code for the classic copy&swap idiom on my Mac with clang 3.3 template class node{ private: node* left; node* right; T value; public: friend void swap(node&, node&); …
CloudyTrees
  • 711
  • 2
  • 10
  • 20
13
votes
1 answer

For what and from where is Compiler-RT invoked?

I would like to know the following about LLVM's Compiler-RT project: from what program is it invoked. To my understanding, Compiler-RT is a collection of functions that handle instructions in LLVM that don't really have hardware counterparts (is…
Jonathan Gallagher
  • 2,115
  • 2
  • 17
  • 31
12
votes
2 answers

Clang/LLVM 7 and 8 on Windows initialize inline static data member multiple times (with both link.exe and lld-link.exe)

Clang/LLVM 7 and 8 on Windows initialize an inline static data member once per TU. As far as I understand C++17 this is not correct. Although an inline variable may be defined in multiple TUs the compiler and/or linker must ensure that it exists…
x y
  • 557
  • 3
  • 10
12
votes
1 answer

How can I find all member field read/writes using Clang?

Given a C++ source code, I want to find the class fields that every function writes and reads. What is the best way of doing this using the Clang frontend? (I'm not asking for a detailed explanation of all the steps; however a starting point for an…
kubuzetto
  • 1,046
  • 1
  • 12
  • 31
12
votes
2 answers

Do C++ compilers perform compile-time optimizations on lambda closures?

Suppose we have the following (nonsensical) code: const int a = 0; int c = 0; for(int b = 0; b < 10000000; b++) { if(a) c++; c += 7; } Variable 'a' equals zero, so the compiler can deduce on compile time, that the instruction 'if(a) c++;'…
haael
  • 972
  • 2
  • 10
  • 22
12
votes
1 answer

Adding a function call in my IR code in llvm

Can you give me an example of how to add a simple call of a function like foo(x); on my IR code with my pass in llvm?
rtroulak
  • 459
  • 1
  • 8
  • 16
11
votes
1 answer

how to add include paths to clang globally

I know this one way of adding include paths to clang:- clang++ -I a.cpp but with this, that path is only added for that particular file, and u have to write that every time linting, so how can I add some include paths globally to clint.
Vishnubly
  • 539
  • 1
  • 8
  • 17
11
votes
1 answer

No Emscripten, How to Compile C++ With Standard Library to WebAssembly

I am having trouble building standalone webassembly with the full control I want over memory and layout. I don't want to use emscripten because, as the following post says, it doesn't give me all of the compile-time options I want (e.g. stack size…
synchronizer
  • 1,955
  • 1
  • 14
  • 37
1
2
3
73 74