llvm

mac 下 clang++ 找不到头文件 stdlib.h

匿名 (未验证) 提交于 2019-12-02 22:56:40
因为要用 openmp库,用 clang++ 编译 c++程序,出现了如下报错: clang++ xx.cpp -o xx -fopenmp /usr/local/Cellar/llvm/7.0.0/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found #include_next <stdlib.h> ^ 探究原因: include_next是在当前文件所在的路径后面的路径(一般有多个搜索路径)里搜索头文件。 报错说明 clang++的 include 搜索路径里 /usr/local/Cellar/llvm/7.0.0/include/c++/v1/ 后面的路径中不存在stdlib.h文件。 网上的解决方案 xcode-select install 没有用。 使用命令查看 clang++的 include 搜索路径(#include <...> search starts here: 后面)。 clang++ -E -x c++ - -v < /dev/null 可以看到这些 /usr/local/Cellar/llvm/7.0.0/include/c++/v1 /usr/include/c++/v1 /usr/local/include /usr/local/Cellar/llvm/7.0.0

lldb: Breakpoint on exceptions (equivalent of gdb's catch throw)

南楼画角 提交于 2019-12-02 20:01:27
I am trying to use lldb for c++ debugging and I want to halt if an exception is thrown, like gdb's catch throw , and I cannot find an equivalent in the lldb documentation. Jason Molenda In Xcode, you can set an Exception breakpoint (View > Navigators > Show Breakpoint Navigator, hit the + button in the bottom of the breakpoint list window to add a new breakpoint). If you're using command line lldb, put a breakpoint on __cxa_throw for C++ exception throws, objc_exception_throw for Objective-C exception throws. For all c++ exceptions: break set -E C++ . Use break set -E c++ to break on all

How can I implement a string data type in LLVM?

≡放荡痞女 提交于 2019-12-02 18:43:17
I have been looking at LLVM lately, and I find it to be quite an interesting architecture. However, looking through the tutorial and the reference material, I can't see any examples of how I might implement a string data type. There is a lot of documentation about integers, reals, and other number types, and even arrays, functions and structures, but AFAIK nothing about strings. Would I have to add a new data type to the backend? Is there a way to use built-in data types? Any insight would be appreciated. What is a string? An array of characters. What is a character? An integer. So while I'm

Setting disassembly flavour to Intel in LLDB

旧巷老猫 提交于 2019-12-02 17:12:55
Is there a way to set the disassembly flavour like there is in GDB within LLDB so that it spits out Intel style assembly rather than AT&T style? set disassembly-flavor intel # GDB but for LLDB. No, not yet. Intel format disassembly is a feature I'm sure will be implemented eventually, but I don't think anyone is working on it today. UPDATE : the ability to select the assembly style was added to the top of tree sources (v. http://lldb.llvm.org ) March 1st, 2013 with the -F or --flavor option to disassemble or the target.x86-disassembly-flavor setting in your ~/.lldbinit file. This will be

How to get LLVM bitcode line number from CPP source code line number?

匆匆过客 提交于 2019-12-02 17:04:16
问题 I have a cpp file and the bitcode using clang 9. Now, I select a cpp line number from the source code and I want to get the LLVM bit code line number for this source code line instead of manually doing disassembly of bit code file and reading the file line by line. Please tell me if it is possible and how. 回答1: There may not be a set of IR instructions that correspond clearly to that exact line... but it's possible, mostly. There is a function called Instruction::getDebugLoc() that returns

Instrumenting C/C++ codes using LLVM

孤街醉人 提交于 2019-12-02 14:44:16
I just read about the LLVM project and that it could be used to do static analysis on C/C++ codes using the analyzer Clang which the front end of LLVM. I wanted to know if it is possible to extract all the accesses to memory(variables, local as well as global) in the source code using LLVM. Is there any inbuilt library present in LLVM which I could use to extract this information. If not please suggest me how to write functions to do the same.(existing source code, reference, tutorial, example...) Of what i have thought, is I would first convert the source code into LLVM bc and then instrument

How to affect Delphi XEx code generation for Android/ARM targets?

不问归期 提交于 2019-12-02 14:07:18
Update 2017-05-17. I no longer work for the company where this question originated, and do not have access to Delphi XEx. While I was there, the problem was solved by migrating to mixed FPC+GCC (Pascal+C), with NEON intrinsics for some routines where it made a difference. (FPC+GCC is highly recommended also because it enables using standard tools, particularly Valgrind.) If someone can demonstrate, with credible examples, how they are actually able to produce optimized ARM code from Delphi XEx, I'm happy to accept the answer. Embarcadero's Delphi compilers use an LLVM backend to produce native

compiling nested functions with clang versus gcc

最后都变了- 提交于 2019-12-02 12:40:16
问题 I have a c file that I can compile with no problem using GCC like below: gcc foo.c however using the same file I am receiving error of having defined functions inside main using clang : clang foo.c foo:230:1: error: function definition is not allowed here { ^ foo.c:241:1: error: function definition is not allowed here { ^ foo.c:253:1: error: function definition is not allowed here these instances of errors are the definitions of a new function inside the main section of the code. I want to

What does this LLVM 1.5 warning mean? “protocol qualifiers without 'id' is archaic”

六眼飞鱼酱① 提交于 2019-12-02 11:56:23
问题 I've just tried compiling an iOS project using the the LLVM 1.5 compiler (included in XCode 3.2.3), and I got a lot of new warnings, including several like this: protocol qualifiers without 'id' is archaic For instance, this happens on lines like this: - (id)initWithContext:(NSManagedObjectContext *)context coordinator:(NSPersistentStoreCoordinator *)coordinator delegate:(<NSFetchedResultsControllerDelegate>)delegate; Now, I think this is probably a "naming conventions" warning, but anyone