llvm

if(self = [super init]) - LLVM warning! How are you dealing with it?

匆匆过客 提交于 2019-11-26 23:14:59
问题 Prior to Xcode 4 with LLVM this passed the compiler unnoticed. Assignment within the conditional is perfectly intentional and a Cocoa idiom. Xcode 4 with LLVM compiler selected never fails to complain, and not just at compile time, as soon as you type it the yellow warning icon appears. Turning off warnings as errors and just ignoring the warning doesn't seem like a good idea. Moving the assignment out of the parentheses wastes space. Having to turn off this warning with a pragma for every

How to generate machine code with llvm

谁都会走 提交于 2019-11-26 22:50:40
问题 I'm currently working on a compiler project using llvm. I have followed various tutorials to the point where I have a parser to create a syntax tree and then the tree is converted into an llvm Module using the provided IRBuilder. My goal is to create an executable, and I am confused as what to do next. All the tutorials I've found just create the llvm module and print out the assembly using Module.dump(). Additionally, the only documentation I can find is for llvm developers, and not end

Is there any way to use LLVM 3 in Xcode 4.1?

折月煮酒 提交于 2019-11-26 22:09:27
问题 I wonder, since LLVM 3.0 is readily available and officially released, is there a way to compile with LLVM 3 when using Xcode 4.1. It would help alot since I used ARC and my app development turned out to be finished sooner than planned. So I don't have to wait until next Xcode 4.2 is released to upload my app to Apple review. Thanks 回答1: You can easily compile with any compiler you want with Xcode; see http://mattrajca.com/post/8749868513/llvm-code-coverage-and-xcode-4 , for example. IIRC,

Is my book's discussion of lambda return types wrong?

放肆的年华 提交于 2019-11-26 22:01:15
问题 My book says this: Lambdas with function bodies that contain anything other than a single return statement that do not specify a return type return void. but this: auto f = []{ int i=0; i++; return std::string("foo"); }; std::cout << f() << std::endl; actually compiles and prints out "foo", but that lambda expr has more than just a single return statement so it should return void, because it does not manually specify "-> std::string" as a return type. What's going on here? I'm using Apple's

How to switch off LLVM's integrated assembler?

强颜欢笑 提交于 2019-11-26 21:31:15
问题 I have a project involving hand-written assembly—AT&T syntax, works fine with GCC, but not done by me plus I know very little about assembly—which exhibits a weird problem when trying to build it with Clang. LLVM documentation mentions that "most X86 targets" use LLVM's integrated assembler as opposed to the system assembler; as a possible workaround I would like to explicitly use the latter. I (well, Google) haven't been successful in finding information on how to do this. Question: Is there

How to make clang compile to llvm IR

半世苍凉 提交于 2019-11-26 21:15:24
I want clang to compile my C/C++ code to LLVM bytecode rather than binary executable. How can I achieve that? And if I get the LLVM bytecode, how can I take it to further compile it to binary executable. Basically I want to add some of my own code to the LLVM bytecode before compiling to binary executable. Given some C/C++ file foo.c : > clang -S -emit-llvm foo.c Produces foo.ll which is an LLVM IR file. The -emit-llvm option can also be passed to the compiler front-end directly, and not the driver by means of -cc1 : > clang -cc1 foo.c -emit-llvm Produces foo.ll with the IR. -cc1 adds some

How to update LLVM & Clang on Mac OSX?

吃可爱长大的小学妹 提交于 2019-11-26 20:37:43
问题 On my version of Mac OSX (Lion 10.7.1, XCode 4.1), there is LLVM 3.0svn and Clang 2.1. The current versions are LLVM 3.0 and Clang 3.0. From the XCode web site, it seems that the latest version (4.2.1) still uses LLVM 2.0, and this seems to be a mistake. Do you know if installing the latest XCode I will get a more recent version of LLVM/Clang? Do you know of any possible issues installing Clang manually? Once installed, will the new Clang be used automatically by all the IDEs I have (e.g.

Switching between GCC and Clang/LLVM using CMake

喜欢而已 提交于 2019-11-26 19:10:41
I have a number of projects built using CMake and I'd like to be able to easily switch between using GCC or Clang/LLVM to compile them. I believe (please correct me if I'm mistaken!) that to use Clang I need to set the following: SET (CMAKE_C_COMPILER "/usr/bin/clang") SET (CMAKE_C_FLAGS "-Wall -std=c99") SET (CMAKE_C_FLAGS_DEBUG "-g") SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG") SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") SET (CMAKE_CXX_COMPILER "/usr/bin/clang++") SET (CMAKE_CXX_FLAGS "-Wall") SET (CMAKE_CXX_FLAGS_DEBUG "-g") SET (CMAKE_CXX_FLAGS

How is LLVM isa<> implemented?

混江龙づ霸主 提交于 2019-11-26 19:10:27
问题 From http://llvm.org/docs/CodingStandards.html#ci_rtti_exceptions LLVM does make extensive use of a hand-rolled form of RTTI that use templates like isa<>, cast<>, and dyn_cast<>. This form of RTTI is opt-in and can be added to any class. It is also substantially more efficient than dynamic_cast<>. How is isa and the others implemented? 回答1: First of all, the LLVM system is extremely specific and not at all a drop-in replacement for the RTTI system. Premises For most classes, it is

any C/C++ refactoring tool based on libclang? (even simplest “toy example” ) [closed]

断了今生、忘了曾经 提交于 2019-11-26 18:49:15
问题 As I've pointed out - here - it seems clang's libclang should be great for implementing the hard task that is C/C++ code analysis and modifications (check out video presentation and slides). Do you know of any C/C++ refactoring tool based on libclang ? "Any" includes even simple alpha state project, with support of one refactoristation technique. It can be without preprocessor support. As an example of the functionally about which I'm talking: changing method names, whether it supports