Граф коммитов

105 Коммитов

Автор SHA1 Сообщение Дата
Steve Naroff ebaa768521 Tweak Sema::ActOnInstanceMessage() to look for a class method when dealing with qualified id's. This change is motivated by our desire to not support the "Class<foo>" idiom. Note that the change makes perfect sense (since all ObjC classes are also id/instances).
This allow us to document a simple migration path...change "Class <foo>" to "id <foo>".

This effects: 
- <rdar://problem/6761939> TASK: File source change radars for "qualified Class" errors
- <rdar://problem/6761864> Protocol qualified Class is unsupported


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68517 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 15:07:57 +00:00
Steve Naroff d9fd7647e2 Change the type of ObjC @ string constants (from NSConstantString->NSString).
This fixes <rdar://problem/6757102> clang type for @"xxx" is "NSConstantString *" (GCC type is "NSString *").


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68514 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 14:18:33 +00:00
Chris Lattner 64540d71b4 various cleanups
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67981 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-29 05:01:10 +00:00
Steve Naroff fdc92b7877 Simplify SelectorTable::constructSetterName() usage...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66551 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 17:24:38 +00:00
Chris Lattner 0c73f37f0a Fix PR3766, a really nasty silent miscompilation case where we emitted
a warning and then threw away the AST.  While I'm in there, tighten up the
code to actually reject completely bogus cases (sending a message to a 
struct).  We still allow sending a message to an int, which doesn't make
sense but GCC allows it and is easy to support.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66468 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-09 21:19:16 +00:00
Steve Naroff 61f72cbd03 Implement property '.' notation on Factory/Class objects. Parser changes aren't very pretty:-(
This fixes <rdar://problem/6496506> Implement class setter/getter for properties.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66465 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-09 21:12:44 +00:00
Steve Naroff 64949d3a2e Remove dead clause (we decided not to support protocol qualified 'Class').
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66385 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-08 19:04:05 +00:00
Steve Naroff 5609ec04ed Improvements to private method lookup.
Patch by Jean-Daniel Dupas. Thanks!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66383 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-08 18:56:13 +00:00
Fariborz Jahanian e61b988feb Removed an unfortunate cut and paste left-over.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 23:00:40 +00:00
Fariborz Jahanian 175ba1e818 Some refactoring of recent code. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66041 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 18:15:57 +00:00
Fariborz Jahanian b1006c7f56 Fix a corner case of message lookup looking for class methods.
If all else failed, find the message in class's root's
list of instacne methods!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66040 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 17:50:39 +00:00
Steve Naroff 6b9dfd4257 Finish up some fixes related to <rdar://problem/6497631> Message lookup is sometimes different than gcc's.
- Disallow casting 'super'. GCC allows this, however it doesn't make sense (super isn't an expression and the cast won't alter lookup/dispatch).
- Tighten up lookup when messaging 'self'.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66033 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 15:11:40 +00:00
Fariborz Jahanian 268bc8c1f3 Implement an important missing warning when a selector
is searched for in the global pool. It already uncovered 
a clang bug in message selection.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65974 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-03 22:19:15 +00:00
Steve Naroff 15edf0de6b Fix <rdar://problem/6497242> Inherited overridden protocol declared objects don't work.
Change Sema::DiagnosePropertyMismatch() to check for type compatibility (rather than type equivalence, which is too strict).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65949 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-03 15:43:24 +00:00
Steve Naroff 8e2945ad91 Fix <rdar://problem/6248764> parser rejects: bad receiver type 'CFStringRef'.
Downgrade an error to a warning (for GCC compatibility).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65779 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-01 17:14:31 +00:00
Steve Naroff 1f484f4aef Fix <rdar://problem/6614945> method not found.
This was a fairly recent regression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65547 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 18:16:19 +00:00
Steve Naroff f1afaf6fe2 Fix http://llvm.org/bugs/show_bug.cgi?id=3544.
The code for looking up local/private method in Sema::ActOnInstanceMessage() was not handling categories properly. Sema::ActOnClassMessage() didn't have this bug.
Created a helper with the correct logic and changed both methods to use it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65532 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 15:55:06 +00:00
Chris Lattner eaf2bb89eb first wave of fixes for @encode sema support. This is part of PR3648.
The big difference here is that (like string literal) @encode has 
array type, not pointer type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65391 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 22:18:39 +00:00
Steve Naroff 279d896d49 Remove isSuperExpr(), which ignores any casts on 'super'.
I don't think casting super makes any sense (since it won't effect method lookup).
Will discuss with other offline and decide what to do.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65317 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 15:40:48 +00:00
Steve Naroff d526c2f2ef Sema::ActOnInstanceMessage(): Tighen up the lookup rules for handling messages to 'Class'. Also improve "super" handling.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65300 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 02:25:40 +00:00
Steve Naroff ac1337d331 Minor cleanup, replace bool with qual_empty().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65293 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22 19:41:00 +00:00
Steve Naroff 0de21fd85d Contains the following (related to problems found while investigting <rdar://problem/6497631> Message lookup is sometimes different than gcc's).
- Implement instance/class overloading in ObjCContainerDecl (removing a FIXME). This involved hacking NamedDecl::declarationReplaces(), which took awhile to figure out (didn't realize replace was the default).
- Changed Sema::ActOnInstanceMessage() to remove redundant warnings when dealing with protocols. For now, I've omitted the "protocol" term in the diagnostic. It simplifies the code flow and wan't always 100% accurate (e.g. "Foo<Prot>" looks in the class interface, not just the protocol).
- Changed several test cases to jive with the above changes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65292 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22 19:35:57 +00:00
Steve Naroff 8b1527b7b9 Remove debugging statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65257 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22 02:19:47 +00:00
Steve Naroff f7f52e7bf5 More work to integrate newly added ObjCQualifiedClassType into the type system.
This is necessary 'plumbing' to fix <rdar://problem/6497631> Message lookup is sometimes different than gcc's.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65248 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21 21:17:01 +00:00
Chris Lattner 89951a86b5 remove some more methods from objc decls, using the iterator
interfaces more consistently.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65138 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 18:43:26 +00:00
Douglas Gregor 48f3bb9f78 Downgrade complaints about calling unavailable functions to a warning
(as GCC does), except when we've performed overload resolution and
found an unavailable function: in this case, we actually error.

Merge the checking of unavailable functions with the checking for
deprecated functions. This unifies a bit of code, and makes sure that
we're checking for unavailable functions in the right places. Also,
this check can cause an error. We may, eventually, want an option to
make "unavailable" warnings into errors.

Implement much of the logic needed for C++0x deleted functions, which
are effectively the same as "unavailable" functions (but always cause
an error when referenced). However, we don't have the syntax to
specify deleted functions yet :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64955 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 21:56:37 +00:00
Chris Lattner 39c28bbbf2 fix the ownership issues and location tracking in
Sema::ParseObjCStringLiteral.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64900 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 06:48:40 +00:00
Chris Lattner 2085fd6cd2 privatize all of the string literal memory allocation/creation
stuff behind a private static function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64898 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 06:40:38 +00:00
Chris Lattner f4b136fb40 add some comments describing what is happening here.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64896 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 06:13:04 +00:00
Chris Lattner a0af1fe67d simplify the code used to compute the type of an objc string. This makes
it faster in the common case when NSConstantString is around.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64895 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 06:06:56 +00:00
Chris Lattner 690398188e rename CheckBuiltinCFStringArgument -> CheckObjCString
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64894 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 06:01:06 +00:00
Chris Lattner 726e168dc0 change the StringLiteral AST node to track all of the SourceLocations of
the various PPTokens that are pasted together to make it.  In the course
of working on this, I discovered ParseObjCStringLiteral which needs some
work.  I'll tackle it next.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64892 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 05:49:11 +00:00
Chris Lattner 76a642ff4f Refactor the deprecated and unavailable checks into a new
DiagnoseUseOfDeprecatedDecl method.  This ensures that they
are treated consistently.  This gets us 'unavailable' support
on a few new types of decls, and makes sure we consistently
silence deprecated when the caller is also deprecated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64612 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 22:43:40 +00:00
Chris Lattner 1251bb85d2 implement support for attribute(unavailable) on objc methods.
This implements gcc/testsuite/objc.dg/method-attribute-1.m


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64581 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-15 07:50:52 +00:00
Anders Carlsson 59843ad883 Add support for deprecated Obj-C methods. The semantics mostly match what gcc has.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64562 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 19:08:58 +00:00
Anders Carlsson ff975cfab9 Pass the location of the start of the selector to ActOnClassMessage/ActOnInstanceMessage.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64560 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14 18:21:46 +00:00
Steve Naroff 389bf46ae4 Several cleanups:
- rename isObjCIdType/isObjCClassType -> isObjCIdStructType/isObjCClassStructType. The previous name didn't do what you would expect.
- add back isObjCIdType/isObjCClassType to do what you would expect. Not currently used, however many of the isObjCIdStructType/isObjCClassStructType clients could be converted over time.
- move static Sema function areComparableObjCInterfaces to ASTContext (renamed to areComparableObjCPointerTypes, since it now operates on pointer types).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64385 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12 17:52:19 +00:00
Ted Kremenek 8189cde56b Overhaul of Stmt allocation:
- Made allocation of Stmt objects using vanilla new/delete a *compiler
  error* by making this new/delete "protected" within class Stmt.
- Now the only way to allocate Stmt objects is by using the new
  operator that takes ASTContext& as an argument.  This ensures that
  all Stmt nodes are allocated from the same (pool) allocator.
- Naturally, these two changes required that *all* creation sites for
  AST nodes use new (ASTContext&).  This is a large patch, but the
  majority of the changes are just this mechanical adjustment.
- The above changes also mean that AST nodes can no longer be
  deallocated using 'delete'.  Instead, one most do
  StmtObject->Destroy(ASTContext&) or do
  ASTContextObject.Deallocate(StmtObject) (the latter not running the
  'Destroy' method).

Along the way I also...
- Made CompoundStmt allocate its array of Stmt* using the allocator in
  ASTContext (previously it used std::vector).  There are a whole
  bunch of other Stmt classes that need to be similarly changed to
  ensure that all memory allocated for ASTs comes from the allocator
  in ASTContext.
- Added a new smart pointer ExprOwningPtr to Sema.h.  This replaces
  the uses of llvm::OwningPtr within Sema, as llvm::OwningPtr used
  'delete' to free memory instead of a Stmt's 'Destroy' method.

Big thanks to Doug Gregor for helping with the acrobatics of making
'new/delete' private and the new smart pointer ExprOwningPtr!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63997 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 01:47:29 +00:00
Ted Kremenek 6e94ef5696 Move StringLiteral to allocate its internal string data using the allocator in
ASTContext. This required changing all clients to pass in the ASTContext& to the
constructor of StringLiteral. I also changed all allocations of StringLiteral to
use new(ASTContext&).

Along the way, I updated a bunch of new()'s in StmtSerialization.cpp to use the
allocator from ASTContext& (not complete).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63958 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06 19:55:15 +00:00
Douglas Gregor 47b9a1ca55 Some name-lookup-related fixes, from Piotr Rak!
- Changes Lookup*Name functions to return NamedDecls, instead of
Decls. Unfortunately my recent statement that it will simplify lot of
code, was not quite right, but it simplifies some...
- Makes MergeLookupResult SmallPtrSet instead of vector, following
Douglas suggestions.
- Adds %qN format for printing qualified names to Diagnostic.
- Avoids searching for using-directives in Scopes, which are not
DeclScope, during unqualified name lookup.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63739 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04 17:27:36 +00:00
Douglas Gregor 4c921ae760 Eliminated LookupCriteria, whose creation was causing a bottleneck for
LookupName et al. Instead, use an enum and a bool to describe its
contents.

Optimized the C/Objective-C path through LookupName, eliminating any
unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
some code and arguments that are no longer used.

Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
over to LookupName, LookupQualifiedName, or LookupParsedName, as
appropriate.

All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
-disable-free. Plus, we're down to three name-lookup routines.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63354 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-30 01:04:22 +00:00
Chris Lattner 500d3297d2 move library-specific diagnostic headers into library private dirs. Reduce
redundant #includes.  Patch by Anders Johnsen!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63271 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29 05:15:15 +00:00
Steve Naroff 3e8ffd2e96 Refactor Sema::LookupDecl() into 2 functions: LookupDeclInScope() and LookupDeclInContext().
The previous interface was very confusing. This is much more explicit, which will be easier to understand/optimize/convert.

The plan is to eventually deprecate both of these functions. For now, I'm focused on performance.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63256 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29 00:07:50 +00:00
Steve Naroff 133147d2d3 Remove 'NamespaceNameOnly' argument to Sema::LookupDecl(). It is unused.
Even though Sema::LookupDecl() is deprecated, it's still used all over the place. Simplifying the interface will make it easier to understand/optimize/convert.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 16:09:22 +00:00
Chris Lattner 20c6b3b85e Split the single monolithic DiagnosticKinds.def file into one
.def file for each library.  This means that adding a diagnostic
to sema doesn't require all the other libraries to be rebuilt.

Patch by Anders Johnsen!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63111 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-27 18:30:58 +00:00
Douglas Gregor 5ac8aff3d7 Some micro-optimizations for DISABLE_SMART_POINTERS:
- When it's safe, ActionResult uses the low bit of the pointer for
  the "invalid" flag rather than a separate "bool" value. This keeps
  GCC from generating some truly awful code, for a > 3x speedup in the
  result-passing microbenchmark.
  - When DISABLE_SMART_POINTERS is defined, store an ActionResult
  within ASTOwningResult rather than an ASTOwningPtr. Brings the
  performance benefits of the above to smart pointers with
  DISABLE_SMART_POINTERS defined.

Sadly, these micro-benchmark performance improvements don't seem to
make much of a difference on Cocoa.h right now. However, they're
harmless and might help with future optimizations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63061 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-26 22:44:13 +00:00
Fariborz Jahanian ebff1fed66 Don't ICE (issue diagnostics) when receiver is a non-objc
type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62355 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 20:35:09 +00:00
Anders Carlsson dce5e2cabf Use a single function for doing vararg argument promotion. Also, make sure to do the promotion before checking the type - fixes PR3340.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62323 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 16:48:51 +00:00
Anders Carlsson 906fed0fb5 Warn when someone tries to pass a variable with a non-POD type to a varargs function/method/block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62148 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 05:48:52 +00:00
Douglas Gregor f8d49f64ef Provide a new kind of iterator, the specific_decl_iterator, that
filters the decls seen by decl_iterator with two criteria: the dynamic
type of the declaration and a run-time predicate described by a member
function. This simplifies EnumDecl, RecordDecl, and ObjCContainerDecl
considerably. It has no measurable performance impact.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61994 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 17:18:27 +00:00