clang++

Clang -Wweak-vtables and pure abstract class

孤者浪人 提交于 2019-12-04 10:53:03
问题 With regard to previous questions on this topic: This a follow up of the question that I've asked recently: clang: no out-of-line virtual method definitions (pure abstract C++ class) and which was marked as duplicate of this question: What is the meaning of clang's -Wweak-vtables?. I don't think that that answered my question, so here I'm focusing on the very thing that puzzles me and that hasn't been answered yet. My scenario: I'm trying to compile the following simple C++ code using Clang-3

clang++ link failure: error: source file is not valid UTF-8?

情到浓时终转凉″ 提交于 2019-12-04 09:15:58
I'm having an interesting problem. I'm compiling a toy compiler with clang++ -g -x c++ y.tab.c lex.yy.c semantic_actions.cpp -o parser -lfl In y.tab.c I included semantic_actios.hpp and the contents in semantic_actions.hpp are some method declarations that are used in y.tab.c . That compiles fine. However if I change it to clang++ -c -g -x c++ semantic_actions.cpp -o semantic_actions.o clang++ -g -x c++ y.tab.c lex.yy.c -o parser semantic_actions.o -lfl I see semantic_actions.o:1:1: error: source file is not valid UTF-8 <CF><FA><ED><FE><U+0007> ^ semantic_actions.o:1:2: error: source file is

Building and using a pure llvm toolchain for c++ on linux

大憨熊 提交于 2019-12-04 08:56:17
Assuming this is possible, could someone tell me, how I have to configure the cmake build to create a "pure" llvm toolchain on ubuntu-16.04 consisting of clang lld libc++ libc++abi libunwind (llvm) compiler-rt any other pieces that might be relevant and are "production ready" The resulting compiler should be as fast as possible (optimizations turned on, no unnecessary asserts or other checks in the compiler binary itself) be installed in a separate, local directory (lets call it <llvm_install> ) not have dependencies to the llvm tolchain provided by packet manager use libc++, libc++abi etc by

g++ and clang++ (with libc++) different behaviour with template template class specialization

无人久伴 提交于 2019-12-04 08:15:49
I'm playing with c++11 and I came across a difference in behavior between g++ 4.9.2 and clang++ 3.5 (but only when it uses the libc++; when it uses the libstdc++, clang++ seems to behave as such as g++) related with a template template specialization for a template class. The following is a trivial example #include <set> template <typename X> class foo; template <template<typename, typename ...> class C, typename X> class foo<C<X>> {}; int main () { foo<std::set<int>> f; return 0; } g++ compiles without problems; clang++ compiles without problems with the libstdc++ but, adding -stdlib=libc++ ,

How to compile C++ for Windows with clang in Visual Studio 2015

ⅰ亾dé卋堺 提交于 2019-12-04 07:42:36
问题 As far as I understand, Visual Studio 2015 is shipped with clang. First I though this was only for Android and iOS apps, but according to this article it should also be possible to use the clang++ frontend for Windows programs. However, I can't find the according option. So could you please explain to me, how I can change the used compiler to clang in a c++ project (in VS2015 RC Community Edition). 回答1: Starting with VS2015 Update 1 you can install the "Clang with Microsoft CodeGen" template

What is clang's 'range-loop-analysis' diagnostic about?

℡╲_俬逩灬. 提交于 2019-12-04 07:33:41
Background: Consider the following example : #include <iostream> #include <vector> int main() { std::vector<bool> vectorBool{false, true}; for(const auto &element : vectorBool) std::cout << std::boolalpha << element << ' '; return 0; } It emits the warning: test.cpp:6:21: warning: loop variable 'element' is always a copy because the range of type 'std::vector<bool>' does not return a reference [-Wrange-loop-analysis] for(const auto &element : vectorBool) std::cout << std::boolalpha << element << ' '; ^ test.cpp:6:9: note: use non-reference type 'std::_Bit_reference' for(const auto &element :

Clangs C++ Module TS support: How to tell clang++ where to find the module file?

ぃ、小莉子 提交于 2019-12-04 05:44:41
In his talk at CppCon, Richard Smith mentioned that even though the Module TS support is currently work in progress, it can already be used. So I build clang 4.0 from svn and tried it on a very simple example. In my myclass.cppm file I defined a simple wrapper for an int module myclass; export class MyClass { public: MyClass (int i) : _i{i} {} int get() { return _i; } private: int _i; }; and my main.cpp just creates one instance of that class and outputs its held int to std::cout . #include <iostream> #include <string> import myclass; int main(int, char**) { MyClass three{3}; std::cout << std:

No luck compiling __thread using ndk clang 3.4/3.5

≡放荡痞女 提交于 2019-12-04 05:18:12
问题 I am trying to use __thread in this small program without luck. Any idea if this TLS is supported in ndk 10c clang 3.4/3.5? The same program compiles fine with ndk gcc 4.8/4.9 and native clang/gcc compilers. Here is the program and compile line - __thread int counter; int main () { counter=20; return 0; } [armeabi] Compile++ thumb: test <= test.cpp /Users/padlar/android/android-ndk-r10c/toolchains/llvm-3.5/prebuilt/darwin-x86/bin/clang++ -MMD -MP -MF ./obj/local/armeabi/objs/test/test.o.d

How can I enable clang-tidy's “modernize” checks?

假装没事ソ 提交于 2019-12-04 05:04:34
I just installed ClangOnWin ,and I'm trying to get clang-tidy 's "modernize" checks to work. Unfortunately, clang-tidy doesn't seem to know about them: clang-tidy -list-checks foo.cpp -- | grep modernize produces no output. The "modernize" checks are listed here , but that page seems to document Clang 3.8, and the version I have installed is 3.7. However, version 3.7 is the current one listed at the LLVM Download Page . clang-tidy knows about a variety of security checks, so I think I have it installed correctly. For example, clang-tidy -list-checks foo.cpp -- | grep security yields this:

Is clang's c++11 support reliable?

青春壹個敷衍的年華 提交于 2019-12-04 04:27:23
I ran into an interesting issue when trying to mix clang (Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn, Target: x86_64-apple-darwin14.0.0), c++11 and CGAL (via MacPorts). It seems that whether or not I call std::vector<>::reserve will determine whether my program will even compile. I've trimmed down the problem into a minimal example (as minimal as CGAL examples get): #include <vector> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/AABB_tree.h> #include <CGAL/AABB_traits.h> #include <CGAL/AABB_triangle_primitive.h> // CGAL::Epeck works fine,