clang

template template parameters and clang

被刻印的时光 ゝ 提交于 2019-12-30 06:33:06
问题 I have had problems (possibly mine) with template template parameters and clang. The following toy example compiles and runs under g++ 4.7.0, not clang++ 3.0 (based on LLVM 3.0), both ubuntu 12.04. Toy example (test_1.cpp): #include <iostream> #include <memory> struct AFn { void operator()() { ; // do something } }; template<typename T> struct impl { T *backpointer_; }; template<typename S, template <typename> class T> struct implT { T<S> *backpointer_; }; template<typename> class AClass;

gcc vs clang: inlining a function with -fPIC

放肆的年华 提交于 2019-12-30 04:33:06
问题 Consider this code: // foo.cxx int last; int next() { return ++last; } int index(int scale) { return next() << scale; } When compiling with gcc 7.2: $ g++ -std=c++11 -O3 -fPIC This emits: next(): movq last@GOTPCREL(%rip), %rdx movl (%rdx), %eax addl $1, %eax movl %eax, (%rdx) ret index(int): pushq %rbx movl %edi, %ebx call next()@PLT ## next() not inlined, call through PLT movl %ebx, %ecx sall %cl, %eax popq %rbx ret However, when compiling the same code with the same flags using clang 3.9

What's the right way to match #includes (or #defines) using Clang's libtooling?

£可爱£侵袭症+ 提交于 2019-12-30 04:31:22
问题 I'm writing a libtooling refactoring tool. I have a class, let's say Foo , defined in a header called foo.h . I want to see if foo.h is included in a file. Currently, to check if bar.cc includes foo.h , I'm just matching using recordDecl(hasName("Foo")) . This works because class Foo { ... }; will exist inside of bar.cc 's AST after preprocessing, if bar.cc includes foo.h . But this doesn't work if, for example, bar.cc includes cat.h which includes foo.h . I want bar.cc to EXPLICITLY include

Clang Error - stddef file not found?

痴心易碎 提交于 2019-12-30 04:12:53
问题 After upgrading to Ubuntu 13.10 "Saucy", Clang now gives me the error message: clang -Wall -Werror -std=c99 -ggdb -O0 5.1.c -o 5.1 In file included from 5.1.c:1: /usr/include/stdio.h:33:11: fatal error: 'stddef.h' file not found # include <stddef.h> ^ 1 error generated. make: *** [5.1] Error 1 BTW the header I included was stdio.h not stddef.h but I am assuming that stdio.h references or #includes stddef.h 回答1: This error appeared for me when trying to run clang-tidy without clang installed.

Building iPhone Code using xcodebuild and running LLVM/Clang Static Analyzer

て烟熏妆下的殇ゞ 提交于 2019-12-30 02:25:48
问题 I followed the steps in Finding memory leaks with the LLVM/Clang Static Analyzer but I was unable to run static analyzer on my project. When I try to run xcodebuild on my project (1. Open Terminal, 2. Go to Project Directly, 3. > xcodebuild), I get this error: === BUILDING NATIVE TARGET XProject OF PROJECT XProject WITH THE DEFAULT CONFIGURATION (Release) === Checking Dependencies... CodeSign error: no certificate found in keychain for code signing identity 'iPhone Developer' \** BUILD FAILED

How do I compile C++ with Clang?

為{幸葍}努か 提交于 2019-12-29 10:49:01
问题 I have installed Clang by using apt-get in Ubuntu, and I can successfully compile C files using it. However, I have no idea how to compile C++ through it. What do I need to do to compile C++? 回答1: The command clang is for C, and the command clang++ is for C++. 回答2: Also, for posterity -- Clang (like GCC) accepts the -x switch to set the language of the input files, for example, $ clang -x c++ some_random_file.txt This mailing list thread explains the difference between clang and clang++ well:

How do I compile C++ with Clang?

会有一股神秘感。 提交于 2019-12-29 10:47:32
问题 I have installed Clang by using apt-get in Ubuntu, and I can successfully compile C files using it. However, I have no idea how to compile C++ through it. What do I need to do to compile C++? 回答1: The command clang is for C, and the command clang++ is for C++. 回答2: Also, for posterity -- Clang (like GCC) accepts the -x switch to set the language of the input files, for example, $ clang -x c++ some_random_file.txt This mailing list thread explains the difference between clang and clang++ well:

How to detect SSE/SSE2/AVX/AVX2/AVX-512/AVX-128-FMA/KCVI availability at compile-time?

旧城冷巷雨未停 提交于 2019-12-29 10:07:46
问题 I'm trying to optimize some matrix computations and I was wondering if it was possible to detect at compile-time if SSE/SSE2/AVX/AVX2/AVX-512/AVX-128-FMA/KCVI [1] is enabled by the compiler ? Ideally for GCC and Clang, but I can manage with only one of them. I'm not sure it is possible and perhaps I will use my own macro, but I'd prefer detecting it rather and asking the user to select it. [1] "KCVI" stands for Knights Corner Vector Instruction optimizations. Libraries like FFTW detect

-rewrite-objc and Objective-C in clang

我只是一个虾纸丫 提交于 2019-12-29 09:37:15
问题 Recently, I have one problem. The clang can translate Objective-C to c++ use -rewrite-objc. So I think, the first step. clang compile Objective-C to C++. And then compile only can use c++ compiler. Is it do like this? clang first translate Objective-C to C++ with runTime, and then compile to the machine code? 回答1: -rewrite-objc exists to translate ObjC to C++ so it can be compiled in the Visual Studio. It is still Objective-C semantics and you still need the objective-c runtime. It is not

Is it possible to initialise an array of non-POD with operator new and initialiser syntax?

折月煮酒 提交于 2019-12-29 07:34:07
问题 I have just read and understood Is it possible to initialise an array in C++ 11 by using new operator, but it does not quite solve my problem. This code gives me a compile error in Clang: struct A { A(int first, int second) {} }; void myFunc() { new A[1] {{1, 2}}; } I expected {{1, 2}} to initialise the array with a single element, in turn initialised with the constructor args {1, 2}, but I get this error: error: no matching constructor for initialization of 'A' new A[1] {{1, 2}}; ^ note: