clang++

Configure clang-check for c++ standard libraries

旧时模样 提交于 2020-04-06 21:52:08
问题 I am trying to run Ale as my linter, which in turn uses clang-check to lint my code. $ clang-check FeatureManager.h Error while trying to load a compilation database: Could not auto-detect compilation database for file "FeatureManager.h" No compilation database found in /home/babbleshack/ or any parent directory json-compilation-database: Error while opening JSON database: No such file or directory Running without flags. /home/babbleshack/FeatureManager.h:6:10: fatal error: 'unordered_map'

Configure clang-check for c++ standard libraries

若如初见. 提交于 2020-04-06 21:51:24
问题 I am trying to run Ale as my linter, which in turn uses clang-check to lint my code. $ clang-check FeatureManager.h Error while trying to load a compilation database: Could not auto-detect compilation database for file "FeatureManager.h" No compilation database found in /home/babbleshack/ or any parent directory json-compilation-database: Error while opening JSON database: No such file or directory Running without flags. /home/babbleshack/FeatureManager.h:6:10: fatal error: 'unordered_map'

g++ , range based for and vectorization

半腔热情 提交于 2020-03-24 04:56:42
问题 considering the following range based for loop in C++ 11 for ( T k : j ) { ... } there are g++ or clang++ optimization flags that can speed up the compiled code ? I'm not talking about any for cycle I'm only considering this new C++11 construct. 回答1: Optimizing loops is very rarely about optimizing the actual loop iteration code ( for ( T k : j ) in this case), but very much about optimizing what is IN the loop. Now, since this is ... in this case, it's impossible to say if, for example,

How to use compile_commands.json with clang python bindings?

南楼画角 提交于 2020-02-27 06:50:50
问题 I have the following script that attempts to print out all the AST nodes in a given C++ file. This works fine when using it on a simple file with trivial includes (header file in the same directory, etc). #!/usr/bin/env python from argparse import ArgumentParser, FileType from clang import cindex def node_info(node): return {'kind': node.kind, 'usr': node.get_usr(), 'spelling': node.spelling, 'location': node.location, 'file': node.location.file.name, 'extent.start': node.extent.start,

AddressSanitizer blacklist in c++ not working

允我心安 提交于 2020-02-24 09:10:08
问题 I'm trying to get address sanitizer blacklist working in a C++ project but its not working as expected. I tried the example on their website, if I compile with clang , it works fine. build % cat suppress.txt fun:bad_foo build % cat foo.c #include <stdlib.h> void bad_foo() { int *a = (int*)malloc(40); a[10] = 1; } int main() { bad_foo(); } build % clang -fsanitize=address -fsanitize-blacklist=suppress.txt foo.c ; ./a.out Exit code: 0 But as soon as I use clang++ , its ignored. build % cp foo.c

Clang modifies return value in destructor?

我怕爱的太早我们不能终老 提交于 2020-02-13 08:04:18
问题 While trying to write a class that times the duration between calling it's constructor and destructor, I ran into what I think is a bug in clang. (Edit: it's not a bug; it's implementation defined copy elision) The timer struct below keeps a pointer to the duration object that's passed in as reference and adds the duration of the scope to this. #include <iostream> #include <chrono> struct timer { using clock = std::chrono::high_resolution_clock; using time_point = clock::time_point; using

C++ 17 features in Visual Studio 2015 with Clang

这一生的挚爱 提交于 2020-01-23 03:32:53
问题 This is a perennial question here, but: does anyone know if there is a way to get Visual Studio 2015, with the Clang tool chain installed (tab for "cross compilation") to enable the 2017 features that Clang itself normally supports? For example, I would like this to compile: constexpr bool test(bool a){bool b= false; b = b || a; return b;} static_assert(test(true),""); With Clang itself, version 3.7, from command line with --std=++1z, this will compile correctly, but Visual Studio C++ is not

Qt Creator: Undefined symbols for architecture x86_64

大憨熊 提交于 2020-01-20 07:01:36
问题 I have a program in Qt creator that compiles and runs fine in a Windows machine. But as soon as I tried to compile it in a Mac OS X (10.9) I received these messages: Undefined symbols for architecture x86_64: "std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from: std::__1::enable_if<__is_forward_iterator<char*>::value, void>::type std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init<char*>(char*, char*) in

Compilation of two files from different compiler one is using other

允我心安 提交于 2020-01-16 08:41:42
问题 If I will compile something(x.cpp) with clang++ and generate dynamic link library, let's say x.so files and i will use that .so files in other source(y.cpp) which i am compiling using g++, so do I get any run time error. 来源: https://stackoverflow.com/questions/59623819/compilation-of-two-files-from-different-compiler-one-is-using-other

Clang: How to get the macro name used for size of a constant size array declaration

邮差的信 提交于 2020-01-14 01:38:32
问题 TL;DR; How to get the macro name used for size of a constant size array declaration, from a callExpr -> arg_0 -> DeclRefExpr. Detailed Problem statement: Recently I started working on a challenge which requires source to source transformation tool for modifying specific function calls with an additional argument. Reasearching about the ways i can acheive introduced me to this amazing toolset Clang. I've been learning how to use different tools provided in libtooling to acheive my goal. But