Steve Naroff
bf478ece48
Rewrite ObjC @try/@catch/@finally. Some minor tweaks to the AST nodes...
...
Still need to rewrite @throw (and do more testing)...
llvm-svn: 43803
2007-11-07 04:08:17 +00:00
Fariborz Jahanian
e8a3016ac7
Rewrite for properties.
...
llvm-svn: 43791
2007-11-07 00:09:37 +00:00
Fariborz Jahanian
63ac80e76a
Misc. fixes. 1) Resurrect meta-data generation turned off by a previous patch.
...
2) Fixed a regression in meta-data generation caused by removal of '_interface' prefix from synthesize class name.
3) Added stubs for @try/@catch/@finally statements.
llvm-svn: 43716
2007-11-05 17:47:33 +00:00
Steve Naroff
bd72289baa
Declare objc_selector outside the prototype for objc_msgSend(), removing a silly warning.
...
llvm-svn: 43706
2007-11-05 14:55:35 +00:00
Steve Naroff
e4f9b23458
Rewrite @selector(sel).
...
llvm-svn: 43705
2007-11-05 14:50:49 +00:00
Steve Naroff
98eb8d1275
- change the synthesized typedef (for classes) to be of type "objc_object".
...
- fix a couple bugs in RewriteObjCStringLiteral.
- convert "Class" -> "id" in RewriteMessageExpr.
llvm-svn: 43704
2007-11-05 14:36:37 +00:00
Steve Naroff
3865e4d8b4
Remove HandleObjcMetaDataEmission(), I inadvertantly resurrected it.
...
llvm-svn: 43690
2007-11-05 00:25:00 +00:00
Steve Naroff
f36987c79b
Two additions...
...
- Synthesize the funky cast for objc_msgSend(). For the basic case, it looks like...
((id (*)(id, SEL))(void *)objc_msgSend)(obj, sel);
The "void *" cast is needed to workaround a GCC "bandaid" (Chris says it has something to do with the inliner). Without the extra "void *" cast, we get spurious warnings/notes that look like...
xx.m:17: warning: function called through a non-compatible type
xx.m:17: note: if this code is reached, the program will abort
- Add prototypes for the ObjC functions we call, objc_msgSend/objc_getClass for now (don't depend on them being included).
llvm-svn: 43685
2007-11-04 22:37:50 +00:00
Steve Naroff
a397efd915
Implement rewrite rules for ObjC string constants.
...
llvm-svn: 43665
2007-11-03 11:27:19 +00:00
Chris Lattner
376cdaf50b
Fix ownership model of ParseAST to allow the dtor of
...
ASTConsumer to process the AST before it is destroyed.
This allows elimination of HandleObjcMetaDataEmission.
llvm-svn: 43659
2007-11-03 06:24:16 +00:00
Steve Naroff
63006473d5
- Remove _interface_ prefix for the synthesized tag names.
...
- Also removed a tab from the generated struct (minor).
llvm-svn: 43616
2007-11-01 17:12:31 +00:00
Steve Naroff
50d4205ff9
Implement rewrite rule for commenting out protocol references. For example:
...
extern id /*<NSObject>*/ NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
extern void NSDeallocateObject(id /*<NSObject>*/object);
extern id /*<NSObject>*/ NSCopyObject(id /*<NSObject>*/object, unsigned extraBytes, NSZone *zone);
llvm-svn: 43612
2007-11-01 13:24:47 +00:00
Steve Naroff
2f55b98725
Tweak RewriteInterfaceDecl() to generate a typedef (if one hasn't already been generated).
...
llvm-svn: 43600
2007-11-01 03:35:41 +00:00
Fariborz Jahanian
7a9c47480d
1) More additions for objective-c's qualifier type.
...
2) Fixed a test failure (which should have failed all along!).
llvm-svn: 43589
2007-10-31 23:53:01 +00:00
Fariborz Jahanian
c3cda76362
Fixed a bug exposed by fixing the assert in previous patch (one of the tests asserted).
...
llvm-svn: 43586
2007-10-31 23:08:24 +00:00
Fariborz Jahanian
aa9a95ca4f
Changed direction of assert. Added more comments.
...
llvm-svn: 43585
2007-10-31 22:57:04 +00:00
Steve Naroff
9c4fdddd0c
Fix two rewriter bugs:
...
- For @class , don't generate multiple typedefs.
- Handle the following edge case interface...
@interface NSMiddleSpecifier : NSObject {}
@end
...which was incorrectly being rewritten to...
struct _interface_NSMiddleSpecifier {
struct _interface_NSObject _NSObject;
};
{}
llvm-svn: 43582
2007-10-31 22:11:35 +00:00
Fariborz Jahanian
aff228dfc7
Rewriteing of ivars changed to just copy directly from the source.
...
llvm-svn: 43560
2007-10-31 17:29:28 +00:00
Steve Naroff
ac0216385f
Checking in some code that is still under construction.
...
I need to (finally) change the way Class/id/SEL/IMP are built-in...the current approach of doing it in the preprocessor is "broken". The other problem is Sema::GetObjcIdType/GetObjcSelType/GetObjcClassType, the hooks that initialize ASTContext lazily. These built-in types need to be done up front...
llvm-svn: 43557
2007-10-31 16:03:04 +00:00
Steve Naroff
37e011ce43
Add some plumbing to help cope with rewriting "id<p>", "Class<p>*".
...
llvm-svn: 43543
2007-10-31 04:38:33 +00:00
Steve Naroff
5cdcd9b61c
Stop pre-defining objc_msgSend/objc_getClass in the preprocessor. Instead, I generate these declaration on the fly when rewriting a message expression.
...
llvm-svn: 43529
2007-10-30 23:14:51 +00:00
Steve Naroff
f921385f40
Rewrite protocols.
...
llvm-svn: 43503
2007-10-30 16:42:30 +00:00
Steve Naroff
5448cf6d61
- Add location info to category/protocol AST's
...
- Rewrite categories.
llvm-svn: 43501
2007-10-30 13:30:57 +00:00
Steve Naroff
4cd61acc33
Remove a couple FIXME's for rewriting ObjC interfaces (which are now being rewritten properly).
...
llvm-svn: 43494
2007-10-30 03:43:13 +00:00
Steve Naroff
c54840433f
More support for rewriting ObjC intefaces. Still some edge cases to handle...
...
llvm-svn: 43493
2007-10-30 02:23:23 +00:00
Fariborz Jahanian
797f24cd7e
Encoding for objectiive-c methods.
...
llvm-svn: 43481
2007-10-29 22:57:28 +00:00
Fariborz Jahanian
bc2759372b
Do the encoding of ivar types in the ivar metadata.
...
llvm-svn: 43454
2007-10-29 17:16:25 +00:00
Anders Carlsson
d849982e84
Add (partial) support for @encode.
...
llvm-svn: 43439
2007-10-29 05:01:08 +00:00
Fariborz Jahanian
801b63525d
Path to synthesize 'instance' size field of _objc_class metadata.
...
llvm-svn: 43409
2007-10-26 23:09:28 +00:00
Steve Naroff
161a92b976
Start rewriting ObjC interfaces. As a start, we comment out all the methods. This involved refining how the parser/AST passes/manages SourceLocations for ObjcMethodDecl's.
...
llvm-svn: 43404
2007-10-26 20:53:56 +00:00
Fariborz Jahanian
99e96b0f11
Patch to synthesize computation of Ivar offset in rewritten c file.
...
Thanks to Steve N. to point out using of offsetof for this.
llvm-svn: 43391
2007-10-26 19:46:17 +00:00
Fariborz Jahanian
51f2182338
Refactored several meta data for reusability.
...
Changed the entire rewrite of metadata to write to std::string
object instead of stdout.
llvm-svn: 43360
2007-10-25 20:55:25 +00:00
Chris Lattner
211f8b8352
Convert one type of metadata to use std::string instead of
...
printf as an example.
llvm-svn: 43346
2007-10-25 17:07:24 +00:00
Fariborz Jahanian
3df412a6ea
Refactored RewriteObjcMethodsMetaData to better rewrite
...
instance/class methods metadata.
llvm-svn: 43320
2007-10-25 00:14:44 +00:00
Steve Naroff
574440fa58
More work on translating message expressions.
...
Still to do:
- Chris will fix a bug in the rewriting engine for nested stmts. For example, the following:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
tranlates to:
NSAutoreleasePool * pool = objc_msgSend(objc_msgSend(objc_getClass("NSAutoreleasePool"), sel_getUid("alloc")), sel_getUid("init"))utoreleasePool"), sel_getUid("alloc")) init];
...which is correct, except there is garbage after sel_getUid("init"). This is because the rewriter isn't updating the extent of the containing message expression.
- Do the crazy cast thang.
llvm-svn: 43316
2007-10-24 22:48:43 +00:00
Fariborz Jahanian
aa29fb4be8
Remove explicit use of size of known structs in metadata generation.
...
llvm-svn: 43313
2007-10-24 21:25:12 +00:00
Fariborz Jahanian
486f718f14
Couple of minor changes. 1) Metaclass metadata also has a reference to
...
protocol meta-data (unlike what documentation says). 2) Include objc.h so,
we can compile the generated metadata with both gcc and clang.
llvm-svn: 43311
2007-10-24 20:54:23 +00:00
Fariborz Jahanian
b2f525dabc
Refactord instance and class metadata emission. Refactored protocols metadata emission.
...
Implemented emission of category metadata,
llvm-svn: 43308
2007-10-24 19:23:36 +00:00
Chris Lattner
3c799d7e9a
Fix some long lines, move code around into logical groups.
...
llvm-svn: 43299
2007-10-24 17:06:59 +00:00
Chris Lattner
6953469880
Use Ted's new mutable child iterators to update the tree as we rewrite it.
...
This will make nested subexprs work.
llvm-svn: 43296
2007-10-24 16:57:36 +00:00
Steve Naroff
c77380b46f
Incorporate some feedback from Chris...
...
llvm-svn: 43285
2007-10-24 01:09:48 +00:00
Steve Naroff
db1ab1c2b0
Add some plumbing to rewrite message expressions (still under construction).
...
llvm-svn: 43274
2007-10-23 23:50:29 +00:00
Steve Naroff
e670dbb9e6
- Add rewrite rule for @class .
...
- Add setter/getter to ObjcClassDecl.
- Predefined key runtime functions.
llvm-svn: 43257
2007-10-23 20:20:08 +00:00
Fariborz Jahanian
f3d5a54722
Patch to complete metadata generation for each implemented class.
...
llvm-svn: 43255
2007-10-23 18:53:48 +00:00
Fariborz Jahanian
d752eae488
Patch for initialization of class's Meta-class metadata.
...
llvm-svn: 43235
2007-10-23 00:02:02 +00:00
Fariborz Jahanian
6eafb030f0
This patch generates protocol metadata and all its sub-metadata.
...
llvm-svn: 43233
2007-10-22 21:41:37 +00:00
Fariborz Jahanian
74a1cfaf21
rewrite of metadata for implemented instance methods.
...
llvm-svn: 43159
2007-10-19 00:36:46 +00:00
Fariborz Jahanian
c34409c281
Patch to rewrite ivar tables metadata for classes defined.
...
llvm-svn: 43151
2007-10-18 22:09:03 +00:00
Fariborz Jahanian
93191afdef
First patch toward rewriting of objective-c's meta data.
...
llvm-svn: 43143
2007-10-18 19:23:00 +00:00
Chris Lattner
c6d91c0f6d
Add new API to rewrite one stmt/expr with another.
...
llvm-svn: 43101
2007-10-17 22:35:30 +00:00
Chris Lattner
9515625d0c
Add rewriter support for @encode expressions. For example,
...
we currently turn:
c = @encode(char *)[2] + 4;
into:
c = "foo"[2] + 4;
Right now the foo string is hard coded, but you can imagine a world
where it wouldn't be :)
llvm-svn: 43093
2007-10-17 21:28:00 +00:00
Chris Lattner
37390bed4d
Fix location processing of @encode: the range should include the @ sign.
...
@selector probably gets this wrong also.
llvm-svn: 43048
2007-10-16 22:51:17 +00:00
Chris Lattner
a7c19feca2
Add a new Rewriter::getRangeSize method.
...
Rename SourceRange::Begin()/End() to getBegin()/getEnd() for
consistency with other code.
Start building the rewriter towards handling @encode.
llvm-svn: 43047
2007-10-16 22:36:42 +00:00
Chris Lattner
0bd1c97293
Push the rewriter forward a bit more. Now it rewrites
...
#import to #include's as a test.
llvm-svn: 43041
2007-10-16 21:07:07 +00:00
Chris Lattner
6a91cc03ad
haha, my devious plot is complete:
...
$ clang rewrite.c -rewrite-test
prints:
int foo() {
b: foo();
f: foo();
foo();
}
for:
int foo() {
b: foo();
f: foo();
foo();
}
amazing.
llvm-svn: 42944
2007-10-13 00:46:29 +00:00
Chris Lattner
2fcf1b83c1
another step forward in rewriter stuff. This still has
...
some incredibly subtle details that I'm working on getting
right.
llvm-svn: 42940
2007-10-13 00:11:23 +00:00
Chris Lattner
16a0de468f
Push the rewriting APIs along. Build a trivial client that replaces tabs
...
with x's for now. The APIs are all unimplemented, so it doesn't do
anything yet! :)
llvm-svn: 42868
2007-10-11 18:38:32 +00:00
Chris Lattner
e99c8329af
add scafolding to play around with and bring up the code rewriter.
...
llvm-svn: 42855
2007-10-11 00:43:27 +00:00