How to compile object C with clang into llvm IR?

Following came from tools/clang/test/CodeGenObjC/message-arrays.m. But I don’t know how to compile it at terminal command since no clang_cc1 executable file. Can some one help me? I am writing the llvm backend document –http://jonathan2251.github.com/lbd/index.html now. I use “clang -c hello.cpp -emit-llvm” to compile C++ but don’t know how to compile Object-C.

// RUN: %clang_cc1 -emit-llvm -o %t %s

void f0(id a) {
// This should have an implicit cast
[ a print: “hello” ];
}

@interface A
-(void) m: (int) arg0, …;
@end

int f1(A *a) {
// This should also get an implicit cast (for the vararg)
[a m: 1, “test”];
}

Jonathan

Look up --emit-llvm. I think it has to be used with -c.

I got the following compile error. Did the message-arrays.m can be compiled into .bc? Or need include something for Object C language compile.

Jonathan

118-165-76-229:CodeGenObjC Jonathan$ pwd
/Users/Jonathan/llvm/release/src/tools/clang/test/CodeGenObjC
118-165-76-229:CodeGenObjC Jonathan$ clang -emit-llvm -o 1.ll -c message-arrays.m
message-arrays.m:5:3: warning: instance method ‘-print:’ not found (return type
defaults to ‘id’) [-Wobjc-method-access]
[ a print: “hello” ];
^ ~~~~~
message-arrays.m:15:1: warning: control reaches end of non-void function
[-Wreturn-type]
}
^
2 warnings generated.
118-165-76-229:CodeGenObjC Jonathan$ clang -emit-llvm -o 1.ll -c ivars.m
ivars.m:18:12: warning: class ‘R’ defined without specifying a base class
[-Wobjc-root-class]
@interface R {
^
ivars.m:18:13: note: add a super class to fix this problem
@interface R {
^
1 warning generated.

I got the following compile error. Did the message-arrays.m can be compiled into .bc? Or need include something for Object C language compile.

Those are warnings, not errors. They otherwise compiled just fine. You should have a bitcode file named ‘1.ll’ from each of those commands.

Chip

Thank you. Yes, I got the output.

Jonathan