clang

clang unicode characters for variable name

cat test.cpp #include <iostream> int main() { int à; } results in: clang++ test.cpp test.cpp:4:7: error: expected unqualified-id int à; ^ 1 error generated. Now, is there a way to get clang to allow unicode variable names? Thanks! ...

Make LLVM inline a function from a library

I am trying to make LLVM inline a function from a library. I have LLVM bitcode files (manually generated) that I linked together with llvm-link, I also have a library (written in C) compiled into bitcode by clang and archived with llvm-ar. I manage to link everything together and to execute but i can't manage to get LLVM to inline a func...

Xcode 3.2: Build & Analyze never finds any issues

I've used the Clang Static Analyzer from the command line before. I wanted to try Xcode's built-in version via Build & Analyze. I never get any negative results even though i specially prepared my code with very obvious issues Clang was always able to point out: // over-releasing an object: [label release]; [label release]; ...

Is the scope of what Xcode's "Build and Analyze" will catch as a leak supposed to be this limited?

It doesn't care about this: NSString* leaker() { return [[NSString alloc] init]; } I thought it would have been smart enough to check if any code paths could call that function without releasing its return value (I wouldn't normally code this way, I'm just testing the analyzer). It reports this as a leak: NSString* leaker() { NSSt...

Linking LLVM JIT Code to Static LLVM Libraries?

I'm in the process of implementing a cross-platform (Mac OS X, Windows, and Linux) application which will do lots of CPU intensive analysis of financial data. The bulk of the analysis engine will be written in C++ for speed reasons, with a user-accessible scripting engine interfacing with the C++ testing engine. I want to write several s...

How to static analyze C++ and Objective-C++ code?

The "Build and analyze" option doesn't seem to work for .cpp and .mm files. I tried "clang --analyze" on individual files without any standard #includes and it works well. However I'm not able to run it on my Xcode project. I couldn't figure out a way to make clang find the standard #includes like even UIKit.h. Any clues? ...

How can I fix this clang warning: "Object with +0 retain counts returned to caller where +1 (owning) retain count is expected"?

I have a piece of Objective-C code that looks like the following: - (NSString *)copyData:(NSData *)data { NSString *path = [[[self outputDirectory] stringByAppendingPathComponent:@"archive"] stringByAppendingPathExtension:@"zip"]; NSLog(@"Copying data to %@", path); [data writeToFile:path atomically:NO]; return path; } ...

tail call generated by clang 1.1 and 1.0 (llvm 2.7 and 2.6)

After compilation next snippet of code with clang -O2 (or with online demo): #include <stdio.h> #include <stdlib.h> int flop(int x); int flip(int x) { if (x == 0) return 1; return (x+1)*flop(x-1); } int flop(int x) { if (x == 0) return 1; return (x+0)*flip(x-1); } int main(int argc, char **argv) { printf("%d\n", flip(atoi(ar...

Clang static analyzer configuration in Xcode 3.2

Hello, There are times when I just want to run static analyzer on a certain group of code in an Xcode project, but not all of the source files. Is there any way to configure this using Xcode 3.2? ...

How do I disable Xcode static analysis (Clang) messages?

I'd like my Xcode project to go through a Build And Analyze step without generating any errors, warnings, or static analysis messages. A problem with this is that my project includes libraries that generate (possibly innocuous) warnings and static analysis messages. I can't find a way to disable specific Clang warnings so that "my" code...

Clang doesn't support the Lock Prefix. How shall I workaround?

Assume this code: static inline void inc(int64_t* atomic) { __asm__ __volatile__ ( "lock incq %0\n" : "=m" (*atomic) : "m" (*atomic) ); } The Clang compiler doesn't support the lock prefix (yet?). What shall I do now? ...

problem with clang application

Hi, I am building an application using clang libraries, I running to a problem, it will be very helpful if somebody can give some directions. #./a.out /home/nmathew/Desktop/algorithms/array.cpp gives In file included from /home/nmathew/Desktop/algorithms/array.cpp:1: In file included from /usr/include/c++/4.4.3/iostream:39: In file i...

Unknown error while installing CLang

I am trying to install CLang from the source but getting unknown errors. The error is make[2]: Leaving directory `/home/ram/Desktop/llvm/tools/llvmc' make[2]: Entering directory `/home/ram/Desktop/llvm/tools/clang' make[3]: Entering directory `/home/ram/Desktop/llvm/tools/clang/include' make[4]: Entering directory `/home/ram/Desktop/llv...

Clang not generating default members

I am using CLang but on using -ast-dump option I do not get the desired output Code ram@ram-desktop ~ $ cat a.cpp class A{}; ram@ram-desktop ~ $ clang++ -cc1 -ast-dump a.cpp typedef char *__builtin_va_list; class A { class A; }; ram@ram-desktop ~ $ I thought I would be getting something like that mentioned by litb in th...

Clang vs GCC - which produces better binaries?

I'm currently using GCC, but I discovered Clang recently and I'm pondering switching. There is one deciding factor though - quality (speed, memory footprint, reliability) of binaries it produces - if gcc -O3can produce a binary that runs 1% faster or takes 1% less memory, it's a deal-breaker. Clang boasts better compile speeds and lower...

Are llvm-gcc and clang binary compatible with gcc? - particularly mingw gcc on Windows.

If I build a static library with llvm-gcc, then link it with a program compiled using mingw gcc, will the result work? The same for other combinations of llvm-gcc, clang and normal gcc. I'm interested in how this works out on Linux (using normal non-mingw gcc, of course) and other platforms as well, but the emphasis is on Windows. I'm ...

Any tutorial for embedding Clang as script interpreter into C++ Code?

I have no experience with llvm or clang, yet. From what I read clang is said to be easily embeddable Wikipedia-Clang, however, I did not find any tutorials about how to achieve this. So is it possible to provide the user of a c++ application with scripting-powers by JIT compiling and executing user-defined code at runtime? Would it be po...

Compiling with LLVM/Clang causes crash, not GCC 4.2

I'm working on an iPhone app, and I'm having some compiler trouble. Here's the low-down: I am compiling using Xcode 3.2.3, targeting iOS 4.0: my device is a 2nd Gen. iPod touch running iOS 4.0. Compiling with GCC 4.2: works on both the simulator and the device Compiling with LLVM compiler 1.5: works on simulator, but not on device. Com...

Clang TOT, huh?

Hey, I wanted to try out some new features in Clang, and I was referred to Clang TOT. Now this might be an obvious question by what the heck is Clang TOT. TOT must be some acronym that I am not familiar with. Can anyone enlighten me? ...

Is there Python Clang wrapper in the vein of pygccxml which wraps GCC-XML?

For a long time now I've been using pygccxml to parse and introspect my C++ source code: it helps me to do some clever code-generation during our build process. Recently I've read a lot about the benefits of the LLVM stack, and especially the benefits that the LLVM Clang parser brings to C++ compilation. I am now wondering if there is ...