Commit Graph

208 Commits

Author SHA1 Message Date
Chris Lattner 1780a85602 Add a new InsertText method that does the check to see if the insertion was valid. This
fixes crashes where the insertion point was in a macro.  Instead of crashing, we want
to emit a warning.

llvm-svn: 46621
2008-01-31 19:42:41 +00:00
Chris Lattner 187f626a7c move a large method out of line
llvm-svn: 46620
2008-01-31 19:38:44 +00:00
Chris Lattner 2e0d2600a2 Make rewriter::inserttext return a bool to indicate if it failed.
Add a RewriteTest::ReplaceStmt method to factor the 'checking for
rewrite failed + emitting diagnostic if so' code.

llvm-svn: 46619
2008-01-31 19:37:57 +00:00
Chris Lattner a779d69029 Fix a rewriter crash when the whole body of a foreach is itself
rewritten, as in Sema/rewrite-foreach-6.m.  Fariborz/Steve,
please review this to see if it is sane.

llvm-svn: 46600
2008-01-31 05:10:40 +00:00
Steve Naroff 7b3579b8de Abolish a bunch of Xcode inserted tabs.
llvm-svn: 46566
2008-01-30 19:17:43 +00:00
Fariborz Jahanian 284011b462 Rewriting of @synchronized. This has one FIXME in it. But this should allow @sychronized to be rewritten.
llvm-svn: 46533
2008-01-29 22:59:37 +00:00
Steve Naroff 909651a6ed Add -Wno-rewrite-macros to silence the following warning when using -rewrite-test:
xx.m:10:3: warning: rewriting sub-expression within a macro (may not be correct)

llvm-svn: 46462
2008-01-28 21:34:52 +00:00
Fariborz Jahanian 60a901621f Fixed a nasty bug which took a while to come up with a test case,
diagnose, and took even longer to fix. It has to do with rewriting of a message
receiver which is an 'ivar' reference. Fix, however, is to remove a code which
was not doing the right thing and no longer needed.

llvm-svn: 46279
2008-01-23 20:34:40 +00:00
Fariborz Jahanian 0a71ad2e07 Problem with ObjC's type-encoding of nested structs causing infinit recursion.
llvm-svn: 46260
2008-01-22 22:44:46 +00:00
Fariborz Jahanian eab81cd03f Synthesize methods with va-arg list correctly.
llvm-svn: 46212
2008-01-21 20:14:23 +00:00
Fariborz Jahanian 137d693e09 Fixed comment.
llvm-svn: 46185
2008-01-19 01:03:17 +00:00
Steve Naroff c7d2df23f8 Fix two bugs with an @throw that doesn't have a statement.
- ObjCAtThrowStmt::getSourceRange() needs to check if it has a statement (and not go "boom":-)
- RewriteTest::RewriteObjCThrowStmt() needs to generate refer to the current exception. 

llvm-svn: 46184
2008-01-19 00:42:38 +00:00
Fariborz Jahanian 802583656e Patch to replace #import with #include.
llvm-svn: 46183
2008-01-19 00:30:35 +00:00
Fariborz Jahanian 159ee39f4d Insert #pragma once when rewriting a header file.
llvm-svn: 46155
2008-01-18 01:15:54 +00:00
Fariborz Jahanian 19d42bf0a5 Typo.
llvm-svn: 46038
2008-01-16 00:09:11 +00:00
Fariborz Jahanian b860cbf052 Added support for rewriting of continue/break statements inside ObjC2's foreach-stmt.
llvm-svn: 46037
2008-01-15 23:58:23 +00:00
Steve Naroff d32419de0d Record if a compound literal expression is @ file scope. This allows us to implement C99 6.5.2.5p6. This could have been done without modifying the AST (by checking the decl type and passing the info down to isContextExpr), however we concluded this is more desirable.
Bug/patch by Eli Friedman!

llvm-svn: 45966
2008-01-14 18:19:28 +00:00
Fariborz Jahanian af5d80cba5 Avoid redefinition of __objcFastEnumerationState
llvm-svn: 45842
2008-01-10 23:04:06 +00:00
Fariborz Jahanian 7262fca0a6 Put return type of synthesize method on same line as method declaration, space after method declaration header.
llvm-svn: 45806
2008-01-10 01:39:52 +00:00
Fariborz Jahanian 82ae0152a7 Allow messaging expression as foreach's collection expression.
llvm-svn: 45793
2008-01-10 00:24:29 +00:00
Fariborz Jahanian 6fa7516bc9 Type-cast RHS of assignment to prevent warning compiling rewritten foreach code.
llvm-svn: 45777
2008-01-09 18:15:42 +00:00
Fariborz Jahanian 22f2347791 Fixed a bug whereby a parethesized collection expression was not being rewritten correctly.
llvm-svn: 45776
2008-01-09 17:50:00 +00:00
Fariborz Jahanian b7e7ee9ff3 Typo fixed.
llvm-svn: 45771
2008-01-09 01:25:54 +00:00
Fariborz Jahanian 965a8961c7 Patch to rewrite ObjC2's foreach-stmt.
llvm-svn: 45760
2008-01-08 22:06:28 +00:00
Fariborz Jahanian dc917b9e07 Patch to start rewriting of ObjC2's foreach statement (work in progress).
llvm-svn: 45721
2008-01-07 21:40:22 +00:00
Ted Kremenek 1b0ea82459 Substituted all instances of the string "Objc" for "ObjC". This fixes
some naming inconsistencies in the names of classes pertaining to Objective-C
support in clang.

llvm-svn: 45715
2008-01-07 19:49:32 +00:00
Chris Lattner 266a2ff3ac Compute the proper sourcerange for an CompoundLiteralExpr.
llvm-svn: 45504
2008-01-02 21:46:24 +00:00
Chris Lattner 5b12ab8c93 Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.

llvm-svn: 45410
2007-12-29 19:59:25 +00:00
Chris Lattner b907c3fca1 remove use of alloca.
llvm-svn: 45329
2007-12-23 01:40:15 +00:00
Anton Korobeynikov 03f8a3630d Unbreak mingw build
llvm-svn: 45328
2007-12-23 01:19:32 +00:00
Ted Kremenek 230bd918b2 Interned MainFileID within SourceManager. Since SourceManager is referenced by
both Preprocessor and ASTContext, we no longer need to explicitly pass
MainFileID around in function calls that also pass either Preprocessor or
ASTContext. This resulted in some nice cleanups in the ASTConsumers and the
driver.

llvm-svn: 45228
2007-12-19 22:51:13 +00:00
Steve Naroff 7e718bb3fd Soften the macro rewrite error to a warning (and change the text).
llvm-svn: 45209
2007-12-19 19:16:49 +00:00
Steve Naroff 55cb4be8ae Emit errors when attempting to rewrite ObjC expressions that originate from a macro expansion.
We plan on fixing this and removing this restriction after the break...

llvm-svn: 45200
2007-12-19 14:32:56 +00:00
Fariborz Jahanian 9f0e310861 Refactoring work. ObjcQualifiedIdType is now derived from 'Type'.
llvm-svn: 45174
2007-12-18 21:33:44 +00:00
Fariborz Jahanian 24cb52c9b0 Patch to implemented objective-c's dynamic object pointer qualified with
the protocol list (id<P,...> types).

llvm-svn: 45121
2007-12-17 21:03:50 +00:00
Fariborz Jahanian 77b713b5d3 Also fixed similar regression for class methods, as well as more indentations.
llvm-svn: 45107
2007-12-17 18:07:01 +00:00
Fariborz Jahanian 5f6409532b Fixed a regression caused by refactoring of some meta-data generation routines using iteratgors.
Also fixed indentation problems.

llvm-svn: 45105
2007-12-17 17:56:10 +00:00
Steve Naroff 3ce37a6b8e - Remove getInstanceMethods/getClassMethods API on ObjcInterfaceDecl, ObjcProtocolDecl, and ObjcCategoryDecl. These methods are replaced by the respective iterators on each class.
- Add getInstanceMethodForSelector to ObjcInterfaceDecl, ObjcProtocolDecl, and ObjcCatgoryDecl. This hook will do a "shallow" lookup. This is a convenience method that reducing some of the iterator usage.
- Various changes to convert all clients to the above API's...
 

llvm-svn: 45046
2007-12-14 23:37:57 +00:00
Ted Kremenek 1daa3cfbae TargetInfo no longer includes a reference to SourceManager.
Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation.
Added many utility methods to FullSourceLoc to provide shorthand for:

    FullLoc.getManager().someMethod(FullLoc.getLocation());
    
instead we have:

    FullLoc.someMethod();
    
Modified TextDiagnostics (and related classes) to use this short-hand.

llvm-svn: 44957
2007-12-12 22:39:36 +00:00
Chris Lattner 30d23e8289 more cleanups changing things like getInstanceVariables to iterators.
llvm-svn: 44930
2007-12-12 07:56:42 +00:00
Chris Lattner 31bc07e6cf resolve some fixmes and clean up some code by eliminating the get*Vars apis to some classes and use iterators instead.
llvm-svn: 44927
2007-12-12 07:46:12 +00:00
Fariborz Jahanian 16e703ade5 80-column please.
llvm-svn: 44888
2007-12-11 23:04:08 +00:00
Fariborz Jahanian 4e56ed5fab Implemented rewriting of protocol-qualified global variable types.
Re-implemented some of rewriting of protocol-qualified function 
argument types to support it in its generality.

llvm-svn: 44886
2007-12-11 22:50:14 +00:00
Ted Kremenek d4e5fbacab Mega-patch: ripped SourceManager out of Diagnostic/DiagnosticClient. Now
SourceManager is passed by reference, allowing the SourceManager to be
associated with a specific translation unit, and not the entire execution
of the driver.

Modified all users of Diagnostics to comply with this new interface.

Integrated SourceManager as a member variable of TargetInfo. TargetInfo will
eventually be associated with a single translation unit (just like
SourceManager).

Made the SourceManager reference in ASTContext private. Provided accessor
getSourceManager() for clients to use instead. Modified clients to comply with
new interface.

llvm-svn: 44878
2007-12-11 21:27:55 +00:00
Fariborz Jahanian c86ee9ce90 Refactor Rewritetest::RewriteObjcQualifiedInterfaceTypes in preparation for more
general use.

llvm-svn: 44876
2007-12-11 19:56:36 +00:00
Steve Naroff 1f6ed92dbb Omit the field name when including the super class structure template.
This allows us to access a superclasses ivars without deriving the absolute path.

The comments below say a bit more...

llvm-svn: 44688
2007-12-07 22:15:58 +00:00
Fariborz Jahanian ff6a455c12 Implemented when static typing is combined with protocols and use as receiver
type.

llvm-svn: 44685
2007-12-07 21:21:21 +00:00
Fariborz Jahanian 33c0e815f3 Patch for rewriting of @protocol.
llvm-svn: 44681
2007-12-07 18:47:10 +00:00
Steve Naroff b2f8ff153d Rewrite 'super' within a class method. This required some minor tweaks to the front-end.
llvm-svn: 44673
2007-12-07 03:50:46 +00:00
Fariborz Jahanian 227c0d13bc On Steve's suggestion, moved handling of use of undeclared method in a message
to rewriter (my previous patch).

llvm-svn: 44665
2007-12-06 19:49:56 +00:00
Steve Naroff ff9f8efe4d Make sure the class methods get attached to the metaclass object.
Need to query the implementation, not the interface...

llvm-svn: 44633
2007-12-05 21:49:40 +00:00
Fariborz Jahanian d5db92ba97 Changed type-cast of "struct objc_super"'s 2nd initializer to match definition of
"struct objc_super".

llvm-svn: 44616
2007-12-05 17:29:46 +00:00
Steve Naroff 0317aeb4b6 Add the definition of objc_super...
llvm-svn: 44588
2007-12-04 23:59:30 +00:00
Fariborz Jahanian 1e34ce1045 Type-cast initializers for "struct objc_super" parameter to avoid warning.
llvm-svn: 44583
2007-12-04 22:32:58 +00:00
Fariborz Jahanian 31e1850694 Don't assert if objc.h not declared when rewriting.
llvm-svn: 44580
2007-12-04 21:47:40 +00:00
Fariborz Jahanian f256b48bc7 Removed a "TODO" comment as objc1 runtime does not need to do the "TODO".
llvm-svn: 44577
2007-12-04 19:31:56 +00:00
Fariborz Jahanian 68c06b2d2c Change <Objc/objc.h> to <objc/objc.h>
llvm-svn: 44556
2007-12-03 23:04:29 +00:00
Fariborz Jahanian d0d2bd5089 Fixed a bug exposed by referencing an ivar field using component reference syntax.
llvm-svn: 44553
2007-12-03 22:25:42 +00:00
Fariborz Jahanian 4f76f22975 Support for rewriteing of messaging of methods which return float.
llvm-svn: 44548
2007-12-03 21:26:48 +00:00
Fariborz Jahanian 9e7b848ac8 Added support for messagings which return a structure-value.
(Also fixed a regression caused by recent changes to synthesis of structs).

llvm-svn: 44540
2007-12-03 19:17:29 +00:00
Chris Lattner f3a59a1fb8 fix a crash when the rewriter would scan off the beginning of the file.
llvm-svn: 44499
2007-12-02 01:13:47 +00:00
Chris Lattner e6535cfdd2 add support for custom client-specific diagnostics. As a testcase, make the
rewriter emit this error if it fails to rewrite an @encode:

t.m:17:9: error: rewriter could not replace sub-expression due to macros
    c = ENC(char *)[2] + 4;
        ^~~~~~~~~~~

... where ENC is: #define ENC @encode

llvm-svn: 44498
2007-12-02 01:09:57 +00:00
Chris Lattner 4431a1b19b start partitioning the diagnostics into two classes: those
that are builtin and those that are aren't.  This is a bunch
of API refactoring that will make this possible, but there is
no functionality change yet.

llvm-svn: 44473
2007-11-30 22:53:43 +00:00
Chris Lattner e9c810c87c pass diagnostics into the rewrite test client.
llvm-svn: 44468
2007-11-30 22:25:36 +00:00
Fariborz Jahanian 96502afb6f Fixed a rewrite bug in class synthesis (which I first thought was a rewrite API bug).
llvm-svn: 44335
2007-11-26 20:59:57 +00:00
Fariborz Jahanian a883d6ed89 Patch to fix a regression caused by recent rewrite changes.
A potential API bug in ReplaceText pending (A FIXME is added).

llvm-svn: 44333
2007-11-26 19:52:57 +00:00
Steve Naroff c8fcbe09d0 No need to forward declare definition of objc_super...
llvm-svn: 44173
2007-11-15 17:06:21 +00:00
Steve Naroff d8ea1ac576 Implement support for variadic methods (work in progress).
llvm-svn: 44171
2007-11-15 12:35:21 +00:00
Steve Naroff 05caa48fb4 Extend RewriteTest::RewriteObjCIvarRefExpr() to cope with static typing (when using -> on a type which corresponds to the implementation type).
llvm-svn: 44170
2007-11-15 11:33:00 +00:00
Steve Naroff 44864e48bd Tweak funky cast to accommodate messaging 'super'. This removes any spurious warnings.
llvm-svn: 44169
2007-11-15 10:43:57 +00:00
Steve Naroff 7fa2f040f3 Rewrite for messaging 'super'.
The code gen. results in some spurious warnings...a cast is forthcoming.

llvm-svn: 44168
2007-11-15 10:28:18 +00:00
Steve Naroff f60782b8c9 - Implement ivar rewrite (patch by Fariborz).
- RewriteMessageExpr()...make implicit casts explicit with synthesizing call (removing warnings when calling objc_msgSend()).

llvm-svn: 44156
2007-11-15 02:58:25 +00:00
Steve Naroff 909d666681 Refinement to previous commit. Always cast the first argument to "id"...no need to special case self.
llvm-svn: 44149
2007-11-15 00:00:21 +00:00
Steve Naroff e7f181986a Cast implicit "self" argument to "id". This removes all warnings associated with implicit references to self. It doesn't yet deal withexplicit references to self...
llvm-svn: 44148
2007-11-14 23:54:14 +00:00
Steve Naroff 03f2767368 Always generate a typedef for @class. The typedef removal logic that I'm removing only made sense when we were operating on preprocess files without typedef guards. Now that we have guards, it is incorrect to ever remove one (since it may increase the likelihood that the rewritten header can't be included stand alone).
llvm-svn: 44145
2007-11-14 23:02:56 +00:00
Chris Lattner 174a825f01 Fix a rewriter bug that steve noticed. Don't skip arbitrary things
between an @ and a p, just skip whitespace.

llvm-svn: 44144
2007-11-14 22:57:51 +00:00
Fariborz Jahanian c6225532c3 Patch to comment out use of protocol qualifiers when rewriting ivars.
llvm-svn: 44142
2007-11-14 22:26:25 +00:00
Steve Naroff dde78986fb Fairly major surgery to RewriteTest::SynthesizeObjcInternalStruct().
This allows us to handle funky stuff like...

#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
@interface NSLayoutManager : NSObject <NSCoding, NSGlyphStorage> {
#else /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */
@interface NSLayoutManager : NSObject <NSCoding> {
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */

...which now rewrites to...

#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
#ifndef _REWRITER_typedef_NSLayoutManager
#define _REWRITER_typedef_NSLayoutManager
typedef struct objc_object NSLayoutManager;
#endif

struct NSLayoutManager {
    struct NSObject _NSObject;

#else /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */
// @interface NSLayoutManager : NSObject <NSCoding> {
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */

llvm-svn: 44129
2007-11-14 19:25:57 +00:00
Fariborz Jahanian 794793ec1c Removed unused variabel.
llvm-svn: 44123
2007-11-14 17:35:46 +00:00
Steve Naroff a509f04034 Fix yesterday's regression with rewriting @optional/@required.
llvm-svn: 44119
2007-11-14 15:03:57 +00:00
Steve Naroff 58ed6c04f2 Rewrite methods that span multiple lines.
llvm-svn: 44118
2007-11-14 14:34:23 +00:00
Steve Naroff c17b056427 Comment out recent regression r44096.
llvm-svn: 44098
2007-11-14 03:37:28 +00:00
Fariborz Jahanian fe38ba24af Rewrite @optional/@required directives used inside protocol definitions.
llvm-svn: 44096
2007-11-14 01:37:46 +00:00
Fariborz Jahanian da6165c3dc Rewrite of forward protocol declaration.
llvm-svn: 44095
2007-11-14 00:42:16 +00:00
Steve Naroff 7b8fa4746a Rewrite method definition bodies. Also renamed a method to distinguish between method declarations and definitions.
llvm-svn: 44080
2007-11-13 23:01:27 +00:00
Fariborz Jahanian 989e03989b Fixed a rewrite of metadata bug when category implementation has no matching interface.
llvm-svn: 44072
2007-11-13 22:09:49 +00:00
Fariborz Jahanian 5633835d17 Populate metadata with adrress of method code.
llvm-svn: 44066
2007-11-13 21:02:00 +00:00
Fariborz Jahanian c54d8462fb Rewrite of method definitions in categories.
llvm-svn: 44062
2007-11-13 20:04:28 +00:00
Fariborz Jahanian 98ba6cde3d Order of methods are OK and generated .c file can be compiled.
llvm-svn: 44060
2007-11-13 19:21:13 +00:00
Fariborz Jahanian 1e5f64e2ea First patch in rewrie of method definitions. This is work in progress.
llvm-svn: 44055
2007-11-13 18:44:14 +00:00
Steve Naroff e3d1ab29da - Minor cleanup to yesterday's changes to Sema::ObjcActOnStartOfMethodDef();
- Add Sema::CurMethodDecl, in preparation for adding ObjcIvarRefExpr.
- Add ObjcInterfaceDecl::lookupInstanceVariable(), in prep for adding ivars.
- A couple renames in ObjcInterfaceDecl, while I was in the vicinity:-)

llvm-svn: 44015
2007-11-12 13:56:41 +00:00
Steve Naroff cac26f4f5f This is the last 5% of the solution to teaching Sema::ActOnInstanceMessage() about private methods (r43989).
While the diff is large, the idea is very simple. When we parse method definitions (in an @implementation), we need to add them incrementally (rather than wait until the @end).

Other details...

- Renamed Sema::ActOnAddMethodsToObjcDecl() to Sema::ActOnAtEnd(). The methods are now optional arguments.
- Removed Parser::AllImplMethods (a nice cleanup).
- Added location info to ObjcImplementationDecl (since we will need it very soon:-)
- Modified message.m test to no longer allow the bogus diagnostic.

llvm-svn: 43995
2007-11-11 17:19:15 +00:00
Steve Naroff 2011338446 Rewrite global variable initializers.
llvm-svn: 43947
2007-11-09 15:20:18 +00:00
Steve Naroff 1b232132ad - add typedef guards.
- tweak scanForProtocolRefs heuristic.
- disable RewriteInclude() for now.

llvm-svn: 43942
2007-11-09 12:50:28 +00:00
Steve Naroff 265a6b9693 Rewrite RewriteObjCStringLiteral(). This version is simpler (and unlike the previous one, works:-)
llvm-svn: 43890
2007-11-08 14:30:50 +00:00
Chris Lattner dc0cfc9fe3 use insert instead of replacing 0 bytes with text :)
llvm-svn: 43882
2007-11-08 04:41:51 +00:00
Chris Lattner 9fd5890e52 use std::copy instead of memcpy for abstraction.
Disable rewrite-tabs.  This speeds up processing of the commentified huge
crazy testcase steve gave me from 20s to 6.6s in a release build.

llvm-svn: 43880
2007-11-08 04:27:23 +00:00
Steve Naroff 1601858de5 Finishing touches on code generation for @try and friends.
- declare functions we use.
- cast arguments to objc_exception_match().
- don't take the & of _stack.buf.

llvm-svn: 43831
2007-11-07 18:43:40 +00:00
Fariborz Jahanian 1299a92327 Emit objective-c's meta-data at the end of rewriting to stdout.
llvm-svn: 43830
2007-11-07 18:40:28 +00:00
Steve Naroff a733c7ffe4 Implement rewrite for @throw.
llvm-svn: 43820
2007-11-07 15:32:26 +00:00