Commit Graph

177 Commits

Author SHA1 Message Date
Benjamin Kramer b11416d061 Add raw_ostream operators to NamedDecl for convenience. Switch over all users of getNameAsString on a stream.
The next step is to print the name directly into the stream, avoiding a temporary std::string copy.

llvm-svn: 101632
2010-04-17 09:33:03 +00:00
Fariborz Jahanian d9235dbc02 Implement method type encoding in the presense
of c-style arguments. Completes radar 7445205.

llvm-svn: 100813
2010-04-08 21:29:11 +00:00
Daniel Dunbar 89947ea894 AST: Add ObjCIvarDecl::getContainingInterface().
llvm-svn: 100227
2010-04-02 21:13:59 +00:00
Daniel Dunbar fe3ead7c48 Sema/Obj-C: Narrow type of ObjCIvarDecl::Create, and check additional invariants on the provided DeclContext.
- Doug, please see the FIXME in DeclObjC.cpp -- I am not sure what the right fix is.

llvm-svn: 100213
2010-04-02 20:10:03 +00:00
Ted Kremenek e184ac5a66 Make the CIndex API more resilient to being used on invalid code.
llvm-svn: 98981
2010-03-19 20:39:03 +00:00
Ted Kremenek d133a86aa3 Move method FindPropertyVisibleInPrimaryClass() from ObjCContainerDecl to ObjCInterfaceDecl.
Also change this method to lookup property declarations using DeclContext::lookup().

llvm-svn: 98574
2010-03-15 20:30:07 +00:00
Ted Kremenek ddcd1093a4 Change ObjCCategoryDecl::FindPropertyDeclaration() to lookup
property decls using DeclContext::lookup().

llvm-svn: 98571
2010-03-15 20:11:53 +00:00
Ted Kremenek 4fb821ec0d Make 'findPropertyDecl()' a static method of ObjCPropertyDecl.
llvm-svn: 98570
2010-03-15 20:11:46 +00:00
Ted Kremenek e0966be5ce Remove unused 'IVars' field from ObjCInterfaceDecl. That functionality
has migrated to DeclContext.

llvm-svn: 98213
2010-03-11 00:36:10 +00:00
Douglas Gregor 12852d9521 Keep track of type source information in the return type of an
Objective-C method declaration, e.g., for 

  - (Foo *)myMethod;

we now have TypeSourceInfo for the Foo*.

llvm-svn: 97942
2010-03-08 14:59:44 +00:00
Fariborz Jahanian afe1386ed9 More support for ivars in class extension.
llvm-svn: 96850
2010-02-23 01:26:30 +00:00
Fariborz Jahanian 30a42923d3 Class continuation now has its own property ast for
those declared in it. This is to allow duplicate
property diagnostics for properties declared in class extensions
multiple times (radar 7629420) and for future use.

llvm-svn: 96276
2010-02-15 21:55:26 +00:00
Fariborz Jahanian da8ec2bc9e Patch to implement rewriting of properties.
Fixes radar 7562952.

llvm-svn: 94087
2010-01-21 17:36:00 +00:00
Douglas Gregor 071676f422 Improve location information for Objective-C category declarations. We
previously only had a single location (the @ in @interface); now we
know where the @ is (for the start of the declaration), where the
class name is (that's the normal "location" now for diagnostics), and
where the category name is. Also, eliminated the redundant "end"
location, since ObjCContainerDecl already has better @end information.

The only XFAIL'd test is temporary; will un-XFAIL-it once I've taught
CIndex how to use the new locations.

llvm-svn: 93639
2010-01-16 16:38:58 +00:00
Douglas Gregor 002b671055 Keep track of the source locations for each protocol reference in
Objective-C classes, protocol definitions, forward protocol
declarations, and categories. This information isn't actually used
yet; that's coming next.

llvm-svn: 93636
2010-01-16 15:02:53 +00:00
John McCall bcd035061d DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated variables,
but the results are imperfect.

For posterity, I did:

cat <<EOF > $cmdfile
s/DeclaratorInfo/TypeSourceInfo/g
s/DInfo/TInfo/g
s/TypeTypeSourceInfo/TypeSourceInfo/g
s/SourceTypeSourceInfo/TypeSourceInfo/g
EOF

find lib -name '*.cpp' -not -path 'lib/Parse/*' -exec sed -i '' -f $cmdfile '{}' \;
find lib -name '*.h' -exec sed -i '' -f $cmdfile '{}' \;
find include -name '*.h' -not -path 'include/clang/Parse/*' -not -path 'include/clang/Basic/*' -exec sed -i '' -f $cmdfile '{}' \;

llvm-svn: 90743
2009-12-07 02:54:59 +00:00
Ted Kremenek 49939c2914 Add ObjCClassDecl::getSourceRange().
llvm-svn: 89179
2009-11-18 01:26:56 +00:00
Ted Kremenek 9b124e10a4 Add SourceLocations to ObjCClassDecl for the class identifiers referenced by @class.
llvm-svn: 89170
2009-11-18 00:28:11 +00:00
Fariborz Jahanian de8db16a7d Property declared in continuation class can only be used to
change a readonly property declared in the class (and its inherited protocols)
to writable property. (Fixes radar 7350645).

llvm-svn: 85836
2009-11-02 22:45:15 +00:00
Steve Naroff f406f4d99b - Add/tweak some comments.
- change ObjCCategoryImplDecl::getCategoryClass() to getCategoryDecl().

No functionality change.

llvm-svn: 85528
2009-10-29 21:11:04 +00:00
Fariborz Jahanian 8764c74784 tweaked my last patch to 1) preserve the protocol in
extension class's protocol list so its AST is complete.
2) Because of this no need to issue warning on unimplemeted
methods coming from the extended class protocols
because warning is issued when class definition is seen.

llvm-svn: 83326
2009-10-05 21:32:49 +00:00
Fariborz Jahanian 092cd6e624 Patch to implement Protocols on class extensions.
<rdar://problem/7269631> Protocols on class extensions don't work

llvm-svn: 83322
2009-10-05 20:41:32 +00:00
Steve Naroff bb69c94798 - Remove Sema::FindMethodInNestedImplementations().
- Add ObjCInterfaceDecl::lookupPrivateInstanceMethod().
- Convert clients.

No functionality change - One less method in Sema:-)

llvm-svn: 83224
2009-10-01 23:46:04 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Anders Carlsson 2fb0824197 Vastly improve PredefinedExpr output, both in Sema and CodeGen. Patch by Sam Weinig!
llvm-svn: 81237
2009-09-08 18:24:21 +00:00
Argyrios Kyrtzidis 60ed560428 Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema interfaces.
DeclaratorDecl contains a DeclaratorInfo* to keep type source info.
Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl.
EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo.

Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet.

llvm-svn: 79392
2009-08-19 01:27:57 +00:00
Fariborz Jahanian 3f8917abf6 Patch to warn if a property which is 'assign' by default
may not implement NSCopying protocol in -fobjc-gc[-only] mode.

llvm-svn: 78726
2009-08-11 22:02:25 +00:00
Argyrios Kyrtzidis f390c43c3c Implement ObjCMethodDecl::getCanonicalDecl().
llvm-svn: 77298
2009-07-28 05:11:17 +00:00
Argyrios Kyrtzidis a56fa19ac6 -Add ObjCCategoryImplDecl::getCategoryClass() which returns the category interface decl.
-Correct ObjCMethodDecl::getNextRedeclaration(); A method in a ObjCCategoryImplDecl should point to
a method in the associated ObjCCategoryDecl, not the ObjCInterfaceDecl.

llvm-svn: 77297
2009-07-28 05:11:05 +00:00
Argyrios Kyrtzidis 2cee40daa7 Use ObjCImplDecl in place of ObjCCategoryImplDecl/ObjCImplementationDecl.
llvm-svn: 77296
2009-07-28 05:10:52 +00:00
Argyrios Kyrtzidis 067c407c48 Make ObjCImplDecl inherit from ObjCContainerDecl.
ObjCContainerDecl now is the root class for objc decls that contain methods.

llvm-svn: 77235
2009-07-27 19:04:32 +00:00
Argyrios Kyrtzidis 39c348d915 Refactor ObjCImplDecl::getInstanceMethod/getClassMethod into one
ObjCImplDecl::getMethod.

llvm-svn: 77094
2009-07-25 22:16:03 +00:00
Argyrios Kyrtzidis 553376be19 Refactor ObjCInterfaceDecl::lookupInstanceMethod/lookupClassMethod into one
ObjCInterfaceDecl::lookupMethod.

llvm-svn: 77093
2009-07-25 22:15:51 +00:00
Argyrios Kyrtzidis e6ed65bee0 Refactor ObjCProtocolDecl::lookupInstanceMethod/lookupClassMethod into one
ObjCProtocolDecl::lookupMethod.

llvm-svn: 77092
2009-07-25 22:15:38 +00:00
Argyrios Kyrtzidis 6de0560b97 Refactor ObjCContainerDecl::getInstanceMethod/getClassMethod into one
ObjCContainerDecl::getMethod.

Avoids code duplication.

llvm-svn: 77091
2009-07-25 22:15:22 +00:00
Duncan Sands 49c29ee43f Disambiguate an if statement.
llvm-svn: 76547
2009-07-21 07:56:29 +00:00
Argyrios Kyrtzidis a8cf0beeef Implement the virtual getNextRedeclaration() for ObjCMethodDecl.
If it's in an ObjCContainerDecl, its "redeclaration" is the method definition in the corresponding ObjCImplDecl.
If it's in an ObjCImplDecl, its "redeclaration" is the method in the interface.

llvm-svn: 76512
2009-07-21 00:06:36 +00:00
Argyrios Kyrtzidis 1559d67b7a Remove the ObjCCategoryImpls vector from Sema class.
Use ObjCInterfaceDecl::getCategoryClassMethod() and ObjCInterfaceDecl::getCategoryInstanceMethod() for the same functionality.

llvm-svn: 76510
2009-07-21 00:06:20 +00:00
Argyrios Kyrtzidis 6d9fab7619 - Introduce ASTContext::getObjCImplementation() and ASTContext::setObjCImplementation() which use a DenseMap to associate
an interface/category with its implementation (if one exists).

- Introduce ObjCInterfaceDecl::get/setImplementation() and ObjCCategoryDecl::get/setImplementation() that use the above methods.

- Add a compiler error for when a category is reimplemented.

llvm-svn: 76508
2009-07-21 00:05:53 +00:00
Steve Naroff 7cae42b07a This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.

llvm-svn: 75314
2009-07-10 23:34:53 +00:00
Argyrios Kyrtzidis cfbfe78e9e De-ASTContext-ify DeclContext.
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

llvm-svn: 74506
2009-06-30 02:36:12 +00:00
Fariborz Jahanian 28c5a8ba4a Adds synthesize ivars to DeclContext.
llvm-svn: 73000
2009-06-06 16:36:41 +00:00
Fariborz Jahanian 6845383426 Use of DeclContext for objc's ivars. No functionality
change. More to follow.

llvm-svn: 72951
2009-06-05 18:16:35 +00:00
Fariborz Jahanian db3a4c1388 (Next runtime only) check to see if class implements forwardInvocation method
and objects of this class are derived from 'NSProxy'.
Under such conditions, which means that every method possible is 
implemented in the class, we should not issue "Method definition not found" 
warnings.

llvm-svn: 72267
2009-05-22 17:12:32 +00:00
Douglas Gregor 5f66205233 The ivars in an ObjCImplementationDecl are now stored in the
DeclContext rather than in a separate list. This makes PCH
(de-)serialization trivial, so that ivars can be loaded lazily.

llvm-svn: 69857
2009-04-23 03:23:08 +00:00
Douglas Gregor 9a13efd5b2 PCH (de-)serialization for ObjCImplDecl. This can't be tested yet.
llvm-svn: 69855
2009-04-23 02:42:49 +00:00
Douglas Gregor 29bd76fd04 Eliminate the three SmallVectors in ObjCImplDecl (for instance
methods, class methods, and property implementations) and instead
place all of these entities into the DeclContext.

This eliminates more linear walks when looking for class or instance
methods and should make PCH (de-)serialization of ObjCDecls trivial
(and lazy).

llvm-svn: 69849
2009-04-23 01:02:12 +00:00
Daniel Dunbar 202f3dc5b3 Remove lookupFieldDeclFromIvar from ObjCIvarDecl interface.
- This is only used by CGObjCRuntime now.

llvm-svn: 69800
2009-04-22 12:00:04 +00:00
Daniel Dunbar 658ba85820 Revert r69771, I missed some (obvious) details. :/
llvm-svn: 69773
2009-04-22 04:39:47 +00:00
Daniel Dunbar aefc2b9be3 Mark another TypeForDecl const and make getObjCInterfaceType's argument const.
llvm-svn: 69772
2009-04-22 04:34:53 +00:00