clang++

Can LTO for clang optimize across C and C++ methods [duplicate]

旧巷老猫 提交于 2019-12-02 04:33:59
问题 This question already has an answer here : Can LTO for gcc or clang optimize across C and C++ methods (1 answer) Closed last year . If link-time optimization (LTO) is being used with clang, is it possible that code can be optimized across the C and C++ language boundary? For example, can a C function be inlined into a C++ caller, or vice-versa? 回答1: AFAIK, yes since Clang produces LLVM intermediate representation, and LTO happens on that LLVM bytecode. BTW any kind of link-time-optimization

No luck compiling __thread using ndk clang 3.4/3.5

拈花ヽ惹草 提交于 2019-12-02 04:24:51
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 -gcc-toolchain /Users/padlar/android/android-ndk-r10c/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin

Trouble with C++ Regex POSIX character class

倖福魔咒の 提交于 2019-12-02 03:32:43
问题 I'm trying to create a regex that is capable of analysing something like this: 002561-1415179671591i.jpg The second part is a unix timestamp (before the i), and I need to extract that. I came up with the following syntax, but std::regex keeps throwing a regex_error before I even check for a match and I'm not too sure what's wrong. Here's what I've got so far: ([:d:])*-[[:d:]]*([:alpha:])\.jpg The C++ code line that throws the error is the constructor to regex std::regex reg(regex_expr); where

Can LTO for clang optimize across C and C++ methods [duplicate]

风格不统一 提交于 2019-12-02 01:32:51
This question already has an answer here: Can LTO for gcc or clang optimize across C and C++ methods 1 answer If link-time optimization (LTO) is being used with clang , is it possible that code can be optimized across the C and C++ language boundary? For example, can a C function be inlined into a C++ caller, or vice-versa? AFAIK, yes since Clang produces LLVM intermediate representation, and LTO happens on that LLVM bytecode. BTW any kind of link-time-optimization happens on some intermediate representation (of the compiled code), not just on machine code with relocation , as kept in every

Trouble with C++ Regex POSIX character class

不想你离开。 提交于 2019-12-02 00:07:26
I'm trying to create a regex that is capable of analysing something like this: 002561-1415179671591i.jpg The second part is a unix timestamp (before the i), and I need to extract that. I came up with the following syntax, but std::regex keeps throwing a regex_error before I even check for a match and I'm not too sure what's wrong. Here's what I've got so far: ([:d:])*-[[:d:]]*([:alpha:])\.jpg The C++ code line that throws the error is the constructor to regex std::regex reg(regex_expr); where regex_expr is a string that has been read in from a file. Really appreciate any help you can give.

Ambiguous overload when writing an enum with an enum-base, but only with clang

左心房为你撑大大i 提交于 2019-12-01 20:36:43
问题 I would like to use operator<< to write an enum with a specified base type. To my surprise, it seems I must write out the operator myself. For example, the code I would like to write is #include <iostream> enum myenum : uint16_t { X = 0, }; int main () { std::cout << "Value is" << X << std::endl; return 0; } gcc 4.8 and visual studio 2015 have no problems with this. clang++-3.6 errors with # clang++-3.6 -std=c++11 -O0 ostream.cpp -o test.exe ostream.cpp:18:29: error: use of overloaded

clang++ fstreams 10X slower than g++

你说的曾经没有我的故事 提交于 2019-12-01 20:15:01
Q: Is there a way to speed up clang++ STD Library fstreams? (And does anybody know why it is so much slower than g++?) I am trying to process very large (many GBs) binary data files and was surprised to find the performance was so poor. At first, I thought it was something to do with my code. But I am seeing the same slow performance in a boiled down example. I even tried allocating different size buffers via rdbuf()->pubsetbuf() but this didn't seem to have much effect. Here is a simple input/output example: #include <fstream> int main() { std::ifstream is {"bigSourceFile"}; std::ofstream os

clang++ - treat template class name as template in the class scope

浪子不回头ぞ 提交于 2019-12-01 18:45:27
It seems that clang++ (I tried clang 3.2) treats the name of a template class as a instantiated class, not a template for any occurence within the class scope. For example, the following codes template <template <class> class T> class A {}; template <typename T> class B { A<B> member; // ^---- clang++ treats B as an instantiated class // but I want it to be a template here // this code could compile in g++ }; int main() { B<int> b; return 0; } What should I do to compile that? C++03 Resolving B that way (called the injected-class-name , an implicitly-declared member of every class including

Can't assign a `std::unique_ptr` to a base class in clang when using an alias template

柔情痞子 提交于 2019-12-01 15:26:05
The following code compiles and runs just fine on gcc 4.9.3 and clang 3.7.1 // std::unique_ptr #include <memory> // Template class for template-template arguments template <typename Real> struct Bar {}; // Base class template <typename T,template <typename> class XX> struct Base {}; // Derived class that operates only on Bar template <typename Real> struct Derived : public Base <Real,Bar> {}; // Holds the unique_ptr template <typename T,template <typename> class XX> struct Foo { std::unique_ptr <Base <T,XX>> foo; }; // Create an alias template template <typename Real> using Buz = Bar <Real>;

Can't assign a `std::unique_ptr` to a base class in clang when using an alias template

不问归期 提交于 2019-12-01 14:18:49
问题 The following code compiles and runs just fine on gcc 4.9.3 and clang 3.7.1 // std::unique_ptr #include <memory> // Template class for template-template arguments template <typename Real> struct Bar {}; // Base class template <typename T,template <typename> class XX> struct Base {}; // Derived class that operates only on Bar template <typename Real> struct Derived : public Base <Real,Bar> {}; // Holds the unique_ptr template <typename T,template <typename> class XX> struct Foo { std::unique