clang

Clang AST dump doesn't show #defines

最后都变了- 提交于 2019-12-24 02:58:40
问题 I'm dumping the AST of some headers like this: clang -cc1 -ast-dump -fblocks header.h However, any #define s on the header are not showing on the dump. Is there a way of adding them? 回答1: It's true, #defines are handled by the preprocessor, not the compiler. So you need a preprocessor parser stage. I know of two: Boost Wave can preprocess the input for you, and/or give you hooks to trigger on macro definitions or uses. The Clang tool pp-trace uses a Clang library that can do callbacks on many

Clang AST dump doesn't show #defines

邮差的信 提交于 2019-12-24 02:58:07
问题 I'm dumping the AST of some headers like this: clang -cc1 -ast-dump -fblocks header.h However, any #define s on the header are not showing on the dump. Is there a way of adding them? 回答1: It's true, #defines are handled by the preprocessor, not the compiler. So you need a preprocessor parser stage. I know of two: Boost Wave can preprocess the input for you, and/or give you hooks to trigger on macro definitions or uses. The Clang tool pp-trace uses a Clang library that can do callbacks on many

CLang 3.5 LibTooling: getting file name of a variable in clang::VarDecl

南笙酒味 提交于 2019-12-24 02:33:39
问题 I am having a clang::VarDecl object. I want to fetch the file name/location of the variable (at least if they are global). I also skimmed through a question:- How to get location of variable name in clang::VarDecl But I guess it is not about file name in which variables are declared. I also referred to http://clang.llvm.org/doxygen/classclang_1_1SourceLocation.html There isn't any function which may return file name. Can anybody tell me how to get it? 回答1: You're supposed to use SourceManager

FFMPEG source compilation failed with Android NDK Clang compiler (r16b) with error “the clang compiler does not support '-mcpu=arm'”

倾然丶 夕夏残阳落幕 提交于 2019-12-24 01:47:55
问题 while compiling FFMPEG source with Android NDK Clang compiler (r16b), I'm getting compiler error. for the below config: ./configure \ --prefix=/home/prasaathviki/Desktop/ffmpeg/bin/android/26/arm64_26 \ --cross- prefix=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android- \ --sysroot="/home/prasaathviki/Desktop/depends/android/ndk/mytoolchains/r16b/arm64_26/sysroot" \ --disable-static \ --disable-doc \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ -

Clang Cross Compiling for Windows Phone ARM target

扶醉桌前 提交于 2019-12-24 01:47:31
问题 I would like to compile a program written in C using Clang for 'Windows Phone' ARM target. Does anyone have experience with it? What is a better approach? 1) Building on a host running Windows 8 using Clang for Windows and MinGW. Does Clang for Windows / MinGW supports ARM by default? If not, I will need to re-build Clang and MinGW? 2) Building on a Linux/MAC host (where ARM target comes as default) and using Windows Phone toolchain (where can I get it?). Thanks in advance! 回答1: There is no

static pre-calculation optimization in clang

随声附和 提交于 2019-12-24 01:45:39
问题 I have #include <stdlib.h> #include <time.h> #include <sys/time.h> #include <stdio.h> #include <math.h> int fib(int n) { return n < 2 ? n : fib(n-1) + fib(n-2); } double clock_now() { struct timeval now; gettimeofday(&now, NULL); return (double)now.tv_sec + (double)now.tv_usec/1.0e6; } #define NITER 5 and in my main() , I'm doing a simple benchmark like this: printf("hi\n"); double t = clock_now(); int f = 0; double tmin = INFINITY; for (int i=0; i<NITER; ++i) { printf("run %i, %f\n", i,

How to set ICC attribute “fp-model precise” for a single function, to prevent associative optimizations?

别等时光非礼了梦想. 提交于 2019-12-24 01:01:17
问题 I am implementing Kahan summation, in a project that supports compilation with gcc47, gcc48, clang33, icc13, and icc14. As part of this algorithm, I would like to disable optimizations that take advantage of the associativity of addition of real numbers. (Floating point operations are not associative.) I would like to disable those optimizations only in the relevant function . I have figured out how to do this under gcc, using the ''no-associative-math'' attribute. How can I do this in icc or

clang 4.0 fails to build clang 3.42 on ubuntu 17.04

烈酒焚心 提交于 2019-12-24 00:30:05
问题 I have posted my failures of building llvm 3.42 with gcc6.3 here and here. I am posting separately the failure of clang 4.0 to build llvm 3.42 from source as these are somewhat different developers communities. Here is the script I've used: svn co https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_342/final llvm svn co https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_342/final llvm/tools/clang svn co https://llvm.org/svn/llvm-project/compiler-rt/tags/RELEASE_342/final llvm/projects

Why can't clang and gcc optimize away this int-to-float conversion?

◇◆丶佛笑我妖孽 提交于 2019-12-24 00:24:53
问题 Consider the following code: void foo(float* __restrict__ a) { int i; float val; for (i = 0; i < 100; i++) { val = 2 * i; a[i] = val; } } void bar(float* __restrict__ a) { int i; float val = 0.0; for (i = 0; i < 100; i++) { a[i] = val; val += 2.0; } } They're based on Examples 7.26a and 7.26b in Agner Fog's Optimizing software in C++ and should do the same thing; bar is more "efficient" as written in the sense that we don't do an integer-to-float conversion at every iteration, but rather a

Address Sanitizer on a python extension

心不动则不痛 提交于 2019-12-24 00:19:18
问题 I am trying to compile a python extension with Address Sanitizer. When I load the extension, I get Traceback (most recent call last): File "test.py", line 2, in <module> from extension import package File "/tmp/python_test/extension/package.py", line 28, in <module> from extension._ext import * ImportError: /tmp/python_test/extension/_ext.so: undefined symbol: __asan_version_mismatch_check_v8 The compiler invocation is clang -g -o _ext.so code.ll -fsanitize=address -lrt -lpthread -ldl -lstdc+