Commit Graph

505 Commits

Author SHA1 Message Date
Erik Verbruggen c6c8d9356d Extend warnings for missing '@end'.
Fixes PR2709.

llvm-svn: 145928
2011-12-06 09:25:23 +00:00
Fariborz Jahanian 56f326e7f2 objc: put out more coherent warning when method definition
attributes don't match its declaration. // rdar://10529259.

llvm-svn: 145872
2011-12-06 00:02:41 +00:00
Douglas Gregor 11bb308457 When typo-correction an Objective-C superclass name, don't
typo-correct to ourselves.

llvm-svn: 145583
2011-12-01 15:37:53 +00:00
Argyrios Kyrtzidis 8ad3bab505 [libclang] Fix operations (token annotation, getting cursor, etc.) with a file region
inside an objc container that "contains" other file-level declarations.

When getting the array of file-level declarations that overlap with a file region,
we failed to report that the region overlaps with an objc container, if
the container had other file-level declarations declared lexically inside it.

Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST
and handling them appropriately.

llvm-svn: 145109
2011-11-23 20:27:36 +00:00
Argyrios Kyrtzidis 41fc05cad8 [libclang] Indexing API: Fix issues, mostly C++ related.
llvm-svn: 145107
2011-11-23 20:27:26 +00:00
Douglas Gregor 4123a86fae Use Sema::RequireCompleteType to check for the completeness of
Objective-C classes. This has two purposes: to consistently provide
"forward declaration here" notes when we hit an incomplete type, and
to give LLDB a chance to complete the type.

RequireCompleteType bits from Sean Callanan!

llvm-svn: 144573
2011-11-14 22:10:01 +00:00
Argyrios Kyrtzidis 95dfc12cd6 Don't crash when a duplicate interface/protocol is inside an extern "C" context.
llvm-svn: 144508
2011-11-13 22:08:30 +00:00
Argyrios Kyrtzidis 0ca3a8b6ef Add a method in ASTMutationListener for the last use of Decl's [is/set]ChangedSinceDeserialization
and remove them.

llvm-svn: 144466
2011-11-12 21:07:52 +00:00
Argyrios Kyrtzidis b97a4025ff [PCH] When completing an objc forward reference, do not serialize the chain of its categories because
it is going to be rewritten (and the chain will be serialized again), otherwise we may form a cycle in its
categories list when deserializing.

Also introduce ASTMutationListener::CompletedObjCForwardRef to notify that a forward reference
was completed; using Decl's isChangedSinceDeserialization/setChangedSinceDeserialization
is bug inducing and kinda gross, we should phase it out.

Fixes infinite loop in rdar://10418538.

llvm-svn: 144465
2011-11-12 21:07:46 +00:00
Argyrios Kyrtzidis f26b12ada0 For the "'@end' is missing in implementation context" point at the location of '@'.
llvm-svn: 143084
2011-10-27 00:09:29 +00:00
Fariborz Jahanian e96f9c816b Fixes a minor hick up to my last patch.
llvm-svn: 142711
2011-10-22 01:56:45 +00:00
Fariborz Jahanian 512a4cc967 objc: private methods can have their attributes, no diagnostic is required.
None private methods if their implementation have attribute, they must exactly 
match those in their declarations. // rdar://10271563

llvm-svn: 142709
2011-10-22 01:21:15 +00:00
Argyrios Kyrtzidis bd8b150dfc Introduce ASTConsumer::HandleTopLevelDeclInObjCContainer which accepts
top-level declarations that occurred inside an ObjC container.

This is useful to keep track of such decls otherwise when e.g. a function
is declared inside an objc interface, it is not passed to HandleTopLevelDecl
and it is not inside the DeclContext of the interface that is returned.

llvm-svn: 142232
2011-10-17 19:48:13 +00:00
Argyrios Kyrtzidis 1f4bee5601 Keep track when a ObjC interface/protocol was initially created as a forward reference.
llvm-svn: 142230
2011-10-17 19:48:06 +00:00
Argyrios Kyrtzidis dcaaa21fbe Really protect from infinite loop when there are objc method redeclarations.
Serialization part will come later.

llvm-svn: 141950
2011-10-14 08:02:31 +00:00
Argyrios Kyrtzidis c5e829cad2 Keep track of objc method redeclarations in the same interface.
Avoid possible infinite loop when iterating over an ObjCMethod's redeclarations.

llvm-svn: 141946
2011-10-14 06:48:06 +00:00
Richard Smith caf3390d44 Constant expression evaluation refactoring:
- Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions,
   and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert
   behaviour.
 - Factor out evaluation of bitfield bit widths.
 - Fix a few places which would evaluate an expression twice: once to determine
   whether it is a constant expression, then again to get the value.

llvm-svn: 141561
2011-10-10 18:28:20 +00:00
Fariborz Jahanian 9a81f848c8 objc: Some refactoring of overriding method decl. code
for future work.

llvm-svn: 141553
2011-10-10 17:53:29 +00:00
Argyrios Kyrtzidis c281c96675 Implicitly assume that a ObjC category to an unavailable interface is also unavailable;
only give an 'unavailable' error on the @implementation of the category. rdar://10234078

llvm-svn: 141335
2011-10-06 23:23:27 +00:00
Argyrios Kyrtzidis 9321ad3f97 When using an unavailable/deprecated interface Foo inside Foo's interface/implementation
don't emit unavailable errors.

llvm-svn: 141334
2011-10-06 23:23:20 +00:00
Argyrios Kyrtzidis 78181b4b45 Fix the rewriter, rdar://10234024.
llvm-svn: 141201
2011-10-05 19:37:56 +00:00
Argyrios Kyrtzidis 52f53fb303 Improve location fidelity of objc decls.
-Add the location of the class name to all objc container decls, not just ObjCInterfaceDecl.
-Make objc decls consistent with the rest of the NamedDecls and have getLocation() point to the
 class name, not the location of '@'.

llvm-svn: 141061
2011-10-04 04:48:02 +00:00
Argyrios Kyrtzidis b8c3aaf479 Allow getting all source locations of selector identifiers in a ObjCMethodDecl.
Instead of always storing all source locations for the selector identifiers
we check whether all the identifiers are in a "standard" position; "standard" position is

  -Immediately before the arguments: -(id)first:(int)x second:(int)y;
  -With a space between the arguments: -(id)first: (int)x second: (int)y;
  -For nullary selectors, immediately before ';': -(void)release;

In such cases we infer the locations instead of storing them.

llvm-svn: 140989
2011-10-03 06:37:04 +00:00
Argyrios Kyrtzidis dfd6570643 Pass from the parser the locations of selector identifiers when creating
objc method decls.

They are not stored in the AST yet.

llvm-svn: 140984
2011-10-03 06:36:36 +00:00
Argyrios Kyrtzidis 3849394b81 Don't keep NumSelectorArgs in the ObjCMethodDecl, the number can be derived from the selector.
llvm-svn: 140983
2011-10-03 06:36:29 +00:00
Ted Kremenek 3f443a71dc Tweak -Wobjc-missing-super-calls to not warning about missing [super dealloc] when in GC-only mode, and to not warning about missing [super finalize] when not using GC.
llvm-svn: 140713
2011-09-28 19:32:29 +00:00
Fariborz Jahanian ac8dbf0fc7 objcetive-c-arc: When overriding a method, its ns_consumed patameter
attribute must match its overriden method. Same also for
ns_returns_retained/not_retained on the result type.
This is one half of // rdar://10187884

llvm-svn: 140649
2011-09-27 22:35:36 +00:00
David Blaikie 9c902b5502 Rename Diagnostic to DiagnosticsEngine as per issue 5397
llvm-svn: 140478
2011-09-25 23:23:43 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
John McCall 9320b87cff Give conversions of block pointers to ObjC pointers a different cast kind
than conversions of C pointers to ObjC pointers.  In order to ensure that
we've caught every case, add asserts to CastExpr that strictly determine
which cast kind is used for which kind of bit cast.

llvm-svn: 139352
2011-09-09 05:25:32 +00:00
Douglas Gregor bab8a96f2f Implement the Objective-C 'instancetype' type, which is an alias of
'id' that can be used (only!) via a contextual keyword as the result
type of an Objective-C message send. 'instancetype' then gives the
method a related result type, which we have already been inferring for
a variety of methods (new, alloc, init, self, retain). Addresses
<rdar://problem/9267640>.

llvm-svn: 139275
2011-09-08 01:46:34 +00:00
Fariborz Jahanian 97d744bea4 objective-c: this patch (re)introduces objective-c's default property
synthesis. This new feature is currently placed under 
-fobjc-default-synthesize-properties option
and is off by default pending further testing.
It will become the default feature soon. 
// rdar://8843851

llvm-svn: 138913
2011-08-31 22:24:06 +00:00
Fariborz Jahanian bd0642fede objective-c - This patch buffers method implementations
and does the Sema on their body after the entire 
class/category @implementation is seen. This change allows messaging 
of forward private methods, as well as, access to 
synthesized ivars of properties with foward synthesize
declarations; among others. In effect, this patch removes
several restrictions placed on objective-c due to in-place
semantics processing of methods.
This is part of // rdar://8843851.

llvm-svn: 138865
2011-08-31 17:37:55 +00:00
Argyrios Kyrtzidis 3a5094b18c Remove a few mutating ObjCCategoryDecl methods.
Remove
  -setClassInterface
  -setNextClassCategory
  -insertNextClassCategory

and combine them in the Create function.

llvm-svn: 138817
2011-08-30 19:43:26 +00:00
Argyrios Kyrtzidis 342e08fbf1 Remove a couple of unnecessary objc method lookups.
llvm-svn: 138815
2011-08-30 19:43:21 +00:00
Nico Weber f926a45df5 Do not warn about [super finalize] in arc mode.
llvm-svn: 138776
2011-08-29 22:59:14 +00:00
Fariborz Jahanian 4327b32654 Minor clean up of objc's decl context stuff.
No change in functionality.

llvm-svn: 138742
2011-08-29 17:33:12 +00:00
Nico Weber 1fb82667dd Warn on missing [super finalize] calls.
This matches gcc's logic. Second half of PR10661.

llvm-svn: 138730
2011-08-28 22:35:17 +00:00
Fariborz Jahanian 3a039e339f objective-c: Treat top-level objective-c declarations
, such as list of forward @class decls, in a DeclGroup
node. Deal with its consequence throught clang. This
is in preparation for more Sema work ahead. // rdar://8843851.
Feel free to reverse if it breaks something important
and I am unavailable.

llvm-svn: 138709
2011-08-27 20:50:59 +00:00
Fariborz Jahanian 5cc730cdef Don't warn on category implementing a method, if
declated method in the class belongs to a synthesized
property getter/setter. // rdar://10014946

llvm-svn: 138598
2011-08-25 22:58:42 +00:00
Fariborz Jahanian 371376010f objc - fix a bug exposed by my recent decl context
changes. // rdar://10015110

llvm-svn: 138594
2011-08-25 22:26:53 +00:00
Fariborz Jahanian d8114f7560 Reverse r138567 until a buildbot failure is investigated.
llvm-svn: 138584
2011-08-25 21:09:22 +00:00
Fariborz Jahanian 35d0e66bee Fixes a typo in my last patch.
llvm-svn: 138571
2011-08-25 18:01:27 +00:00
Fariborz Jahanian 73d5f67f5a objc -arse: Use DeclGroup for forward class declarations;
as in @class foo, bar. More cleanup to follow.

llvm-svn: 138567
2011-08-25 17:47:31 +00:00
Ted Kremenek 618e574253 Do not perform check for missing '[super dealloc]' under ARC as calling -dealloc is illegal in that mode.
llvm-svn: 138261
2011-08-22 19:07:43 +00:00
Fariborz Jahanian f36734dd2a objc - minor comment fix up and cleanup.
llvm-svn: 138253
2011-08-22 18:34:22 +00:00
Nico Weber 715abaf213 Warn on missing [super dealloc] calls.
This matches gcc's logic. Half of PR10661.

llvm-svn: 138240
2011-08-22 17:25:57 +00:00
Fariborz Jahanian 8d382dc781 Restore patch I reversed in r138040. Known buildbot
failures are resolved.

llvm-svn: 138234
2011-08-22 15:54:49 +00:00
Fariborz Jahanian 9a3b269ea1 Revers r138040. Need to look at a few buildbot failures.
llvm-svn: 138049
2011-08-19 18:02:47 +00:00
Fariborz Jahanian d6d866d6fa objective-c: Bring objective-c handling of decl context
to modernity. Instead of passing down individual
context objects from parser to sema, establish decl
context in parser and have sema access current context
as needed. I still need to take of Doug's comment for
minor cleanups.

llvm-svn: 138040
2011-08-19 16:06:57 +00:00