clang++

How do I get clang to dump the AST without color?

那年仲夏 提交于 2019-12-06 19:49:17
问题 Using clang-check to dump a source code's AST, can be done with the following command: $ clang-check -ast-dump file.c -- However, the output of this command will appear colorful within the terminal. When I direct the output to a file, I'm stuck with all of the color escape codes: $ clang-check -ast-dump file.c -- > out.txt example: [0;1;32mTranslationUnitDecl[0m[0;33m 0x227c5c0[0m <[0;33m<invalid sloc>[0m> [0;33m<invalid sloc>[0m [0;34m|-[0m[0;1;32mTypedefDecl[0m[0;33m 0x227cac0[0m <[0;33m

Getting clang-tidy to fix header files

≯℡__Kan透↙ 提交于 2019-12-06 19:41:26
问题 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 touch the hpp files because a compile command wasn't found in the database (as I would expect). I'm using ninja to build the project and ninja -t compdb cc cxx > .build/compile_commands.json to generate the compilation database. I've tried running:

Making a SFML2 Applcation with Clang, libc++ and c++11. Undefined Reference to SFML Library

╄→гoц情女王★ 提交于 2019-12-06 13:20:30
I'm having a weird problem with making an SFML2 application. I'm using Clang++ from the Repositories as well as libc++ (both updated today). SFML2 was also updated from the SVN repo. I'm using the latest version of Kubuntu. I also had the same problem when I last tried about a month ago with the then up-to-date repositories. The parameters I'm passing through to the compiler for c++11 and stdlib are: -std=c++11 -stdlib=libc++ Here's the full version of what I'm calling: clang++ -std=c++11 -stdlib=libc++ main2.cpp -o main -L/home/jonathan/OpenSource/sfml/SFML-Build/lib/ -I/home/jonathan

AddressSanitizer / LeakSanitizer Error with -lsupc++ and -stdlib=libc++ on a never called virtual function that writes to a stream

萝らか妹 提交于 2019-12-06 11:28:36
The following code throws an AddressSanitizer Error when compiled on Debian Jessie with clang 3.5. It appears to be related to the combination of linked libraries, but i have not been able to find something similar on the internet. Reproduction of the Error Invocation: clang++ -stdlib=libc++ -lc++abi -fsanitize=address,vptr sample.cpp -lsupc++ -o sample //sample.cpp #include <iostream> class Foo { virtual void bar() { std::cerr << std::endl; } public: virtual ~Foo() { } }; int main() { Foo foo; try{ throw 1; } catch(int i) { return i; } return -1; } When omitting compile flag -lc++abi , a

Issue with friend template functions clang++ / msvc++ and enable_if

 ̄綄美尐妖づ 提交于 2019-12-06 10:48:11
I get a compiler error in clang++. MSVC++ is happy. I believe my declarations are correct. Am I incorrect in my beliefs and I am "lucky" in MSVC? Is there a non #ifndef _MSC_VER ... public: way to make this work in both compilers? I'd like to keep the constructor private. The real code is slightly more complex. (additional template meta-programming and "perfect forwarding") The following is a distilled version for the question and to isolate the issue as much as possible. I've tried a number of variations for the friend declaration. The one that "seems best" is shown in the example. #include

gcc: is there no tail recursion if I return std::string in C++?

跟風遠走 提交于 2019-12-06 07:14:05
As per my answer in Write a recursive function that reverses the input string , I've tried seeing whether clang++ -O3 or g++ -O3 would make a tail-recursion optimisation, using some of the suggestions from How do I check if gcc is performing tail-recursion optimization? , but it doesn't look like any tail recursion optimisation is taking place. Any idea why? Does this have to do with the way C++ objects are created and destroyed? Is there any way to make it work? The programme: % cat t2.cpp #include <iostream> #include <string> std::string rerev1(std::string s) { if (s.empty()) return s;

CocoaPods: Linking with C++ symbols defined in libPods.a

孤街浪徒 提交于 2019-12-06 06:24:33
问题 I recently started working on a podSpec file that integrates levelDB into my projects. (https://github.com/iljaiwas/Podspecs/blob/master/LevelDBPodSpec/0.0.1/leveldb.podspec) However, when I reference any C++ symbol from a .mm file in the main target, I get a linker error like this: Undefined symbols for architecture x86_64: "leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, leveldb::DB**)", referenced from

Error while trying to compile c++11 regex tutorial with Clang++ on Linux

房东的猫 提交于 2019-12-06 06:22:51
问题 I'm trying to follow this tutorial about regex in C++11. When I try to compile the little code example I get these errors clang++ -std=c++0x test.cpp -o test In file included from test.cpp:3: In file included from /usr/include/c++/4.6/regex:55: /usr/include/c++/4.6/bits/regex_constants.h:196:36: error: constexpr variable 'match_default' must be initialized by a constant expression static constexpr match_flag_type match_default = 0; ^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/4.6/bits/regex

Xcode 11.1: iostream' file not found

人盡茶涼 提交于 2019-12-06 06:02:05
I just updated my MacBook Pro to macOS Catalina 10.15 , and tried to compile and run a C++ command line program , but I had a problem which didn’t exist on previous versions; This is simply the code: #include <iostream> using namespace std; int main() { cout << "Hello, World!\n"; return 0; } The code compiles and outputs the expected, but still the Xcode says: fatal error: 'iostream' file not found I tried changing the Build Settings/C++ Standard Library to libstdc++ , but a warning says: warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use

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

狂风中的少年 提交于 2019-12-06 05:35:12
问题 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: