Commit Graph

21 Commits

Author SHA1 Message Date
Douglas Gregor d507d77432 Fix handling of property and ivar lookup in typo correction; the two
kinds of lookup into Objective-C classes were tangled together, a
situation that was compounded by automatically synthesized ivars.

llvm-svn: 116907
2010-10-20 03:06:34 +00:00
Douglas Gregor 87074f19e8 Introduce a simple cache for unqualified typo corrections, so that we
don't repeatedly loop through identifiers, correcting the same typo'd
identifier over and over again. 

We still bail out after 20 typo corrections, but this should help
improve performance in the common case where we're typo-correcting
because the user forgot to include a header.

llvm-svn: 116901
2010-10-20 01:32:02 +00:00
Douglas Gregor 0c78ad9665 Rework the Parser-Sema interaction for Objective-C message
sends. Major changes include:

  - Expanded the interface from two actions (ActOnInstanceMessage,
    ActOnClassMessage), where ActOnClassMessage also handled sends to
    "super" by checking whether the identifier was "super", to three
    actions (ActOnInstanceMessage, ActOnClassMessage,
    ActOnSuperMessage). Code completion has the same changes.
  - The parser now resolves the type to which we are sending a class
    message, so ActOnClassMessage now accepts a TypeTy* (rather than
    an IdentifierInfo *). This opens the door to more interesting
    types (for Objective-C++ support).
  - Split ActOnInstanceMessage and ActOnClassMessage into parser
    action functions (with their original names) and semantic
    functions (BuildInstanceMessage and BuildClassMessage,
    respectively). At present, this split is onyl used by
    ActOnSuperMessage, which decides which kind of super message it
    has and forwards to the appropriate Build*Message. In the future,
    Build*Message will be used by template instantiation.
  - Use getObjCMessageKind() within the disambiguation of Objective-C
    message sends vs. array designators.

Two notes about substandard bits in this patch:
  - There is some redundancy in the code in ParseObjCMessageExpr and
  ParseInitializerWithPotentialDesignator; this will be addressed
  shortly by centralizing the mapping from identifiers to type names
  for the message receiver.
  - There is some #if 0'd code that won't likely ever be used---it
  handles the use of 'super' in methods whose class does not have a
  superclass---but could be used to model GCC's behavior more
  closely. This code will die in my next check-in, but I want it in
  Subversion.

llvm-svn: 102021
2010-04-21 19:57:20 +00:00
Chris Lattner 5ff40fc7ab tighten the check for cast of super to avoid rejecting valid code,
rdar://7853261

llvm-svn: 101048
2010-04-12 17:09:27 +00:00
Chris Lattner 08e774b7ef fix rdar://7852959 - Use of super within a block is actually ok.
(aka, Fariborz was right ;-)

llvm-svn: 101046
2010-04-12 17:03:29 +00:00
Chris Lattner 3adb17d44f fix a bug I noticed by inspection, correcting two reject-valid bugs.
llvm-svn: 101026
2010-04-12 06:36:00 +00:00
Chris Lattner 3ab8ca2894 fix a rejects-valid bug that I introduced, pointed out
by David Chisnall

llvm-svn: 101024
2010-04-12 06:27:57 +00:00
Chris Lattner cd963185f0 fix a rejects-valid testcase involving super that I dreamt up.
This also fixes cases where super is used in a block in a
method which isn't valid.

llvm-svn: 101021
2010-04-12 06:20:33 +00:00
Chris Lattner c2ebb03297 Have the parser decide whether a message to super is a variable or
type, instead of having sema do it.

llvm-svn: 101016
2010-04-12 05:38:43 +00:00
Chris Lattner 6033be79b3 avoid double negatives
llvm-svn: 100976
2010-04-11 18:53:08 +00:00
Chris Lattner a36ec4243b fix PR6811 by not parsing 'super' as a magic expression in
LookupInObjCMethod.  Doing so allows all sorts of invalid code
to slip through to codegen.  This patch does not change the 
AST representation of super, though that would now be a natural
thing to do since it can only be in the receiver position and
in the base of a ObjCPropertyRefExpr.

There are still several ugly areas handling super in the parser,
but this is definitely a step in the right direction.

llvm-svn: 100959
2010-04-11 08:28:14 +00:00
Fariborz Jahanian 935f041243 outside a method, 'super' should resolve in a normal name look up
to mimic gcc's behavior. Fixes radar 7400691.

llvm-svn: 94246
2010-01-22 23:04:44 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Fariborz Jahanian 0399c1c9c0 Change tests to use clang -cc1...
llvm-svn: 91297
2009-12-14 17:36:25 +00:00
Mike Stump 753d120975 Prep for new warning.
llvm-svn: 76709
2009-07-22 00:43:08 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Chris Lattner 6e76e592a3 Improve the "bad receiver" warning for ObjC message sends to be less confusing.
llvm-svn: 66635
2009-03-11 03:47:47 +00:00
Chris Lattner 1897de1c38 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.

llvm-svn: 66468
2009-03-09 21:19:16 +00:00
Steve Naroff 8676e08730 Fix <rdar://problem/6248764> parser rejects: bad receiver type 'CFStringRef'.
Downgrade an error to a warning (for GCC compatibility).

llvm-svn: 65779
2009-03-01 17:14:31 +00:00
Steve Naroff 9e4ac111f0 Fix <rdar://problem/6150376> [sema] crash on invalid message send.
The core fix in Sema::ActOnClassMessage(). All the other changes have to do with passing down the SourceLocation for the receiver (to properly position the cursor when producing an error diagnostic).

llvm-svn: 59639
2008-11-19 15:54:23 +00:00
Steve Naroff 773cdc7c0d Fix <rdar://problem/6333904> [sema] message lookup on super is incorrect
Missing special lookup rule in Sema::ActOnInstanceMessage().

llvm-svn: 59467
2008-11-17 22:29:32 +00:00