llvm-clang

Clang VS VC++:“error: declaration of 'T' shadows template parameter”

守給你的承諾、 提交于 2019-12-01 05:24:11
I was trying to compile the following code for the classic copy&swap idiom on my Mac with clang 3.3 template<typename T> class node{ private: node<T>* left; node<T>* right; T value; public: friend void swap(node<T>&, node<T>&); // other stuff } Yet the linker complained. I now understand that I should declare the function as a template. But error would occur if I follow the style as suggested here from MSDN: template <class T> class Array { T* array; int size; public:template<class T> //... template <class T> friend Array<T>* combine(Array<T>& a1, Array<T>& a2); }; I did copy-paste but got the

What is proper LLVM header guard style?

家住魔仙堡 提交于 2019-12-01 04:17:40
问题 In clang tidy, the check [llvm-header-guard] looks for LLVM style header guards, but I can't find any examples of proper LLVM header guard style, specifically the structure of the name given to the define, the coding standards pages does not mention anything. 回答1: Looking at the unit tests: https://github.com/llvm-mirror/clang-tools-extra/blob/master/unittests/clang-tidy/LLVMModuleTest.cpp it seems to accept a few variations on the commonly used patterns. For a file named include/llvm/ADT/foo

Clang VS VC++:“error: declaration of 'T' shadows template parameter”

主宰稳场 提交于 2019-11-30 17:03:42
问题 I was trying to compile the following code for the classic copy&swap idiom on my Mac with clang 3.3 template<typename T> class node{ private: node<T>* left; node<T>* right; T value; public: friend void swap(node<T>&, node<T>&); // other stuff } Yet the linker complained. I now understand that I should declare the function as a template. But error would occur if I follow the style as suggested here from MSDN: template <class T> class Array { T* array; int size; public:template<class T> //...

What is the LLVM version bundled with Xcode?

只谈情不闲聊 提交于 2019-11-30 12:36:48
Up to Xcode 6 when typing clang --version we got the information on what LLVM version it was built: Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) But now with Xcode 7 we only get the following: Apple LLVM version 7.0.0 (clang-700.0.72) See https://gist.github.com/yamaya/2924292 in which an interesting comment says: Looking at the sources (src/CMakeLists.txt), it appears AppleClang is based on (approximately) the following LLVM branches: clang-700.0.72 => LLVM 3.7.0 clang-700.1.76 => LLVM 3.7.0 clang-700.1.81 => LLVM 3.7.0 clang-703.0.29 => LLVM 3.8.0 clang-703.0.31 => LLVM

Cmake and clang tooling linking error (outside of source tree)

怎甘沉沦 提交于 2019-11-30 11:40:42
问题 I am trying to compile the RecursiveASTVisitor example of Clang using a CMake file. Building the project goes well, however linking C++ executable fails with multiple undefined reference to LLVM and Clang libraries. I am building the example outside of the LLVM/Clang source file tree. Here is my CMakeLists.txt (I am using FindClang.cmake and FindLLVM.cmake from this project): cmake_minimum_required(VERSION 2.8.4) project(ifcount) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules

Why does objective-c not have API availability checking?

不羁岁月 提交于 2019-11-30 11:06:20
问题 Swift 2 have API availability checking. The compiler will give you an error when using an API too new for your minimum target OS Why can't the objective-c compiler do the equivalent? I googled objective c API availability checking and only swift 2 results came out so I assume the compiler for objective c can't do that. 回答1: The warning (Swift makes it an error) just hadn't been implemented in the Clang compiler for years, but it's not an inherent Objective-C limitation (although due to its

Compile protobuf with xCode 5

时间秒杀一切 提交于 2019-11-30 06:53:06
问题 I want to use protobuf(https://code.google.com/p/protobuf/) in my project Did you successfully compile protobuf with xCode 5, Please help to share your experience? Thanks. 回答1: If you don't mind building Google Protobuf yourself then a good alternative to using Cocoapods is to run the bash script here. https://gist.github.com/BennettSmith/7150245 This script will produce a proper build of Google Protobuf that supports the i386, armv7, armv7s, arm64 and x86_64 architectures. It will produce a

Cmake and clang tooling linking error (outside of source tree)

拜拜、爱过 提交于 2019-11-30 02:24:31
I am trying to compile the RecursiveASTVisitor example of Clang using a CMake file. Building the project goes well, however linking C++ executable fails with multiple undefined reference to LLVM and Clang libraries. I am building the example outside of the LLVM/Clang source file tree. Here is my CMakeLists.txt (I am using FindClang.cmake and FindLLVM.cmake from this project ): cmake_minimum_required(VERSION 2.8.4) project(ifcount) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) message(STATUS "CMAKE module path: ${CMAKE_MODULE_PATH}") find_path(LibClang

Adding a function call in my IR code in llvm

感情迁移 提交于 2019-11-30 01:36:53
Can you give me an example ,how to add a simple call of a function foo(x); on my IR code with my pass in llvm? A simple way is to learn is to use ELLCC with Output Options as LLVM C++ API Code . Two key notes: Make sure foo 's definition is available; otherwise you need to define it firstly. Typically you need to get the prototype by using getOrInsertFunction and then use IRBuilder to insert the body for the function. Create the CallInst , an easy way is to use CallInst*IRBuilder::CreateCall(Value*, ArrayRef<Value*>, const Twine &) . Here is a segment I wrote before for llvm3.4; hope it can

Why does objective-c not have API availability checking?

我与影子孤独终老i 提交于 2019-11-29 23:14:11
Swift 2 have API availability checking . The compiler will give you an error when using an API too new for your minimum target OS Why can't the objective-c compiler do the equivalent? I googled objective c API availability checking and only swift 2 results came out so I assume the compiler for objective c can't do that. The warning (Swift makes it an error) just hadn't been implemented in the Clang compiler for years, but it's not an inherent Objective-C limitation (although due to its dynamic nature, you won't be able to catch all cases), nor Swift terminology. The Apple macros (e.g., NS