llvm-clang

How to compile #include <experimental/any> for clang on OSX

杀马特。学长 韩版系。学妹 提交于 2019-12-08 01:57:49
问题 I am trying to get the #include <experimental/any> to compile in my C++ program on clang OSX // test.cpp #include <experimental/any> int main() { return 0; } Tried following commands/options as learnt from here clang++ -std=c++14 test.cpp -o test -std=c++1z -stdlib=libc++ clang++ -std=c++1x test.cpp -o test -std=c++1z -stdlib=libc++ clang++ -std=c++1y test.cpp -o test -std=c++1z -stdlib=libc++ clang++ -std=c++1z test.cpp -o test -std=c++1z -stdlib=libc++ But it doesn't compile & complains of

Linker error with implicit instantiation of private C++ template with LLVM-Clang

社会主义新天地 提交于 2019-12-07 12:24:39
问题 Disclaimer: I know that templates are usually implemented in the header file. Please read through. I have a C++ template-related issue. My code builds with MSVC under Windows but doesn't with LLVM-Clang under Mac OSX, but I'm not sure which one is wrong. Here is a simple test case, composed of three source files: main.cpp #include "templ.h" int main() { templ(1); return 0; } templ.h template<typename T> T templ(const T&); templ.cpp #include "templ.h" template<typename T> T templ(const T& t) {

Getting actual value of local variables in llvm

旧城冷巷雨未停 提交于 2019-12-07 11:45:21
问题 If I have this example: int a=0, b=0; a and b are local variables and make any modifications in their values, such as: a++; b++; I need to get the value in this line code during running MCJIT. I mean by value not Value class, but the actual integer or any type value. 回答1: You need to return the value from a JITed LLVM function in order to retrieve it from the code invoking MCJIT. Check out this Kaleidoscope example. The relevant code is in HandleTopLevelExpression(): if (FunctionAST *F =

Undefined symbols for architecture x86_64: “std::terminate()”, when building kaleidoscope llvm

房东的猫 提交于 2019-12-07 02:46:26
I'm doing the kaleidoscope tutorial. I'm on step two. https://github.com/westymatt/creole But I get this error when building with clang++ clang++ -Wno-c++11-extensions -g -std=c++11 -I/usr/local/Cellar/llvm/3.6.1/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS src/lexer.cc src/parser.cc -L/usr/local/Cellar/llvm/3.6.1/lib/ -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMX86Desc -lLLVMObject

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:

Clang: Retrieving public methods

冷暖自知 提交于 2019-12-06 14:27:55
问题 I want to define a function that will return a pointer to the last defined public method using the Clang LibTooling library. Currently I have a CXXRecordDecl pointer *decl and the following line to get the source location of the first method. const SourceLocation method_begin_location = decl->method_begin()->getLocation(); Ideally, I want to replace this with a function to get the location of the last defined public method or the location of the beginning of the public declaration if there

How to change LLVMPass long opt command to a simple Command

你说的曾经没有我的故事 提交于 2019-12-06 14:26:01
问题 I am working on LLVM obfuscation project. I have written a llvm pass(lets say flow flattening pass) which i am running on source (test.c) with following command: clang -emit-llvm test.c -c -o test.bc opt -load ../../.. LLVMFlattening.so -fla <test.bc>/dev/null But i have seen that in O-LLVM project they achieved same thing using: clang -emit-llvm test.c -c -o test.bc -mllvm -fla Can someone tell me what is -mllvm here and how this changed to a simple command? 回答1: -mllvm means Additional

Using NEON multiply accumulate on iOS

寵の児 提交于 2019-12-06 10:29:27
问题 Even though I am compiling for armv7 only, NEON multiply-accumulate intrinsics appear to be being decomposed into separate multiplies and adds. I've experienced this with several versions of Xcode up to the latest 4.5, with iOS SDKs 5 through 6, and with different optimisation settings, both building through Xcode and through the commandline directly. For instance, building and disassembling some test.cpp containing #include <arm_neon.h> float32x4_t test( float32x4_t a, float32x4_t b,

How to tell clang that my LLVM Target should use 16-bit 'int'?

笑着哭i 提交于 2019-12-06 08:49:12
For my PIC Backend, I want 'int' to be 16 bits. How can I / my target tell clang what should be the size of 'int'? Defining 16-bit registers only seems not sufficient. Currently "clang -O2 -emit-llvm -target pic" converts int foo(int a, int b) { return a + b; } to this IR code, using 32-bit integers: ; ModuleID = '../test/sum.c' source_filename = "../test/sum.c" target datalayout = "e-m:e-p:16:16-i16:16-a:0:16-n16-S16" target triple = "pic" ; Function Attrs: norecurse nounwind readnone define i32 @foo(i32 %a, i32 %b) local_unnamed_addr #0 { entry: %add = add nsw i32 %b, %a ret i32 %add }

How to get the filename and directory from a LLVM Instruction?

六眼飞鱼酱① 提交于 2019-12-06 06:50:18
问题 I need to extract the directory and filename during a llvm pass. The current version of llvm moved getFilename and getDirectory from DebugLoc to DebugInfoMetadata . I can't find a class member getFilename directly in the DebugLoc header. Thus, how to do I go from an instruction to source code filename and directory? http://llvm.org/docs/doxygen/html/classllvm_1_1DebugLoc.html Additionally, there is a print function that might help but it only takes a llvm::raw_ostream and can't be redirected