Commit Graph

110 Commits

Author SHA1 Message Date
Fariborz Jahanian 161848a030 ObjClang++: Allow declaration of block variable in a collection
statement header (fixes radar 8295106).

llvm-svn: 112443
2010-08-29 17:20:53 +00:00
Gabor Greif e6523ea915 suppress annoying textual repetition as 'aka'
llvm-svn: 112365
2010-08-28 10:40:52 +00:00
Chris Lattner 1ba644575d handle :: in selectors in objc++ mode, rdar://8366474
llvm-svn: 112307
2010-08-27 22:32:41 +00:00
Argyrios Kyrtzidis 421ad5e1e6 In Sema::AddBuiltinOperatorCandidates, candidate pointer types set can also contain a ObjCObjectPointerType since r111699.
Don't assume that they are only PointerTypes or we will crash.

llvm-svn: 111798
2010-08-23 07:12:16 +00:00
Fariborz Jahanian 7a3f3a0402 Contributed test case for PR7936
by Jean-Daniel Dupas.

llvm-svn: 111700
2010-08-21 00:17:33 +00:00
Fariborz Jahanian e4151b590e patch to support comparison involving
objctive-c pointer conversions. Fixes pr7936.

llvm-svn: 111699
2010-08-21 00:10:36 +00:00
Fariborz Jahanian 68e69ca9f9 Patch to issue warning when colllection expresion's type
does not implement 'countByEnumeratingWithState' API.
Implements radar 7634669.

llvm-svn: 110964
2010-08-12 22:25:42 +00:00
Fariborz Jahanian 6fdc171414 Fix test to not depend on objc.h header.
llvm-svn: 110729
2010-08-10 20:59:58 +00:00
Fariborz Jahanian d52543ee22 an objective-c++ test for -Wstrict-selector-match
(radar 8127244).

llvm-svn: 110702
2010-08-10 18:32:37 +00:00
Douglas Gregor 22da8ebafc Add some more tests for reference binding of Objective-C objects
llvm-svn: 110514
2010-08-07 11:56:45 +00:00
Douglas Gregor 8b2d2fe234 Allow reference binding of a reference of Objective-C object type to
an lvalue of another, compatible Objective-C object type (e.g., a
subclass). Introduce a new initialization sequence step kind to
describe this binding, along with a new cast kind. Fixes PR7741.

llvm-svn: 110513
2010-08-07 11:51:51 +00:00
John McCall dc9796e23a Properly pop out of Objective-C method declarations when they are (ill-formedly)
found within contexts other than the translation unit.

llvm-svn: 110417
2010-08-06 00:46:05 +00:00
John McCall da518417fa Permit template argument deduction to add qualifiers within ObjC object
pointers like it can with normal and member pointers.

llvm-svn: 110313
2010-08-05 05:30:45 +00:00
Douglas Gregor 0bdcb8a239 When taking the address of a value of Objective-C object type (e.g.,
one because we're referencing a variable of type NSString &), the
resulting type is an ObjCObjectPointerType.

llvm-svn: 109753
2010-07-29 16:05:45 +00:00
John McCall 2ca705eb13 Support catching Objective C pointers in C++ under the non-fragile NeXT runtime.
Diagnose attempts to do this under the GNU or fragile NeXT runtimes.

llvm-svn: 109298
2010-07-24 00:37:23 +00:00
Douglas Gregor fb0c0d37b7 Extend the "cannot convert from base class pointer to derived class
pointer" diagnostic to handle references, too.

llvm-svn: 107372
2010-07-01 02:14:45 +00:00
Douglas Gregor 56f2e34a6a Improve diagnostic when we fail to pick an overload because it would
require a base-to-derived pointer conversion.

llvm-svn: 107349
2010-06-30 23:01:39 +00:00
Daniel Dunbar 8452ef0798 tests: Use %clangxx when using driver for C++, in case C++ support is disabled.
llvm-svn: 107153
2010-06-29 16:52:24 +00:00
Douglas Gregor f7d7771812 Fix the recently-added warning about 'typename' and 'template'
disambiguation keywords outside of templates in C++98/03. Previously,
the warning would fire when the associated nested-name-specifier was
not dependent, but that was a misreading of the C++98/03 standard:
now, we complain only when we're outside of any template.

llvm-svn: 106161
2010-06-16 22:31:08 +00:00
Fariborz Jahanian 1d44608cc1 Make sure result type of objc++ message expression is
complete before attempting to bind it to a temporary.
Fixes PR7386.

llvm-svn: 106130
2010-06-16 18:56:04 +00:00
Douglas Gregor c9d2682df3 Warn when a 'typename' or a 'template' keyword refers to a
non-dependent type or template name, respectively, in C++98/03. Fixes
PR7111 and <rdar://problem/8002682>.

llvm-svn: 105968
2010-06-14 22:07:54 +00:00
John McCall 6d1116ac49 Conversions from Objective C object pointers to bool are "pointer conversions
to bool" in the sense of C++ [over.ics.rank]p4 bullet 1.  I have decreed it.

llvm-svn: 105817
2010-06-11 10:04:22 +00:00
Douglas Gregor 959d5a0cbd Implement support for variable length arrays in C++. VLAs are limited
in several important ways:

  - VLAs of non-POD types are not permitted.
  - VLAs cannot be used in conjunction with C++ templates.

These restrictions are intended to keep VLAs out of the parts of the
C++ type system where they cause the most trouble. Fixes PR5678 and
<rdar://problem/8013618>.

llvm-svn: 104443
2010-05-22 16:17:30 +00:00
Douglas Gregor 3e51e173b6 Reinstate r104117, Chandler Carruth's change that "[provides] a naming
class for UnresolvedLookupExprs, even when occuring on template
names" along with a fix for an Objective-C++ crasher it introduced.

llvm-svn: 104277
2010-05-20 20:58:56 +00:00
Douglas Gregor 527786ea3a Various small fixes for construction/destruction of Objective-C++
instance variables:
  - Use isRecordType() rather than isa<RecordType>(), so that we see
  through typedefs in ivar types.
  - Mark the destructor as referenced
  - Perform C++ access control on the destructor

llvm-svn: 104206
2010-05-20 02:24:22 +00:00
Fariborz Jahanian f633ebd961 Adds support for ObjC++'s GC attribute on declaration of
object variables and functions returning such objects.

llvm-svn: 104168
2010-05-19 21:37:30 +00:00
John McCall 0e704f7fcd Permit Objective C object pointers to be const_casted.
llvm-svn: 104019
2010-05-18 09:35:29 +00:00
John McCall 8b07ec253d Substantially alter the design of the Objective C type AST by introducing
ObjCObjectType, which is basically just a pair of
  one of {primitive-id, primitive-Class, user-defined @class}
with
  a list of protocols.
An ObjCObjectPointerType is therefore just a pointer which always points to
one of these types (possibly sugared).  ObjCInterfaceType is now just a kind
of ObjCObjectType which happens to not carry any protocols.

Alter a rather large number of use sites to use ObjCObjectType instead of
ObjCInterfaceType.  Store an ObjCInterfaceType as a pointer on the decl rather
than hashing them in a FoldingSet.  Remove some number of methods that are no
longer used, at least after this patch.

By simplifying ObjCObjectPointerType, we are now able to easily remove and apply
pointers to Objective-C types, which is crucial for a certain kind of ObjC++
metaprogramming common in WebKit.

llvm-svn: 103870
2010-05-15 11:32:37 +00:00
Fariborz Jahanian 1bd96d13b2 Objective-C++ Sema. Fix a bug in instantiation of receivers.
Completes radar 7963410.

llvm-svn: 103719
2010-05-13 17:19:25 +00:00
John McCall 01f21ad97c Rebuild builtin_id * as an ObjCObjectPointerType, where builtin_id is the
magic type that 'id' is a pointer to.

llvm-svn: 103708
2010-05-13 08:39:13 +00:00
John McCall bb4ea81ab9 When performing template argument deduction, match Objective C pointers
against pointer patterns.

llvm-svn: 103706
2010-05-13 07:48:05 +00:00
Fariborz Jahanian cac49a8f8a Objective-C++ Sema. Support for conversion of a C++
class object used as a receiver to an objective-c
pointer via a converwsion function. wip.

llvm-svn: 103672
2010-05-12 23:29:11 +00:00
Fariborz Jahanian b0901b7951 Objective-C++ Sema - Allow static_cast of one objc pointer to
another.

llvm-svn: 103630
2010-05-12 18:16:59 +00:00
Fariborz Jahanian eee1669adb Allow static_cast to objective-c pointers.
Fixes radar 7952457.

llvm-svn: 103447
2010-05-10 23:46:53 +00:00
Fariborz Jahanian ce7ddf7bf7 Test for my last patch.
llvm-svn: 102956
2010-05-03 21:06:59 +00:00
Fariborz Jahanian 0103d67f98 Diagnose declaration of reference typed ivars.
llvm-svn: 102390
2010-04-26 22:07:03 +00:00
Douglas Gregor b7e20eb883 Implement template instantiation for implicit property references in
Objective-C++. This is the last bit of (non-blocks-related) template
instantiation logic for Objective-C++. Yay! 

llvm-svn: 102382
2010-04-26 21:04:54 +00:00
Douglas Gregor 9faee21f67 Implement template instantiation for ObjCPropertyRefExpr.
llvm-svn: 102379
2010-04-26 20:47:02 +00:00
Douglas Gregor d51d90dd04 Implement template instantiation for value-dependent Objective-C ivar
references and isa expressions. Also, test template instantiation of
unresolved member references to Objective-C ivar references and isa
expressions.

llvm-svn: 102374
2010-04-26 20:11:03 +00:00
Douglas Gregor f4e837f66c Implement template instantiation for Objective-C @catch
statements. This is the last of the Objective-C statements.

llvm-svn: 102356
2010-04-26 17:57:08 +00:00
Douglas Gregor 306de2f6a1 Template instantiation for @try and @finally (but not @catch, yet).
llvm-svn: 102147
2010-04-22 23:59:56 +00:00
Douglas Gregor f68a508586 Template instantiation for the Objective-C "fast enumeration"
statement, i.e., 

  for (element in collection) {
    // do something
  }

llvm-svn: 102138
2010-04-22 23:10:45 +00:00
Douglas Gregor 6148de71dd Template instantiation for Objective-C++ @synchronized statements.
llvm-svn: 102134
2010-04-22 22:01:21 +00:00
Douglas Gregor 2900c16b92 Implement template instantiation for Objective-C++ @throw statements.
llvm-svn: 102133
2010-04-22 21:44:01 +00:00
Douglas Gregor c298ffcb8b Implement template instantiation for Objective-C++ message sends. We
support dependent receivers for class and instance messages, along
with dependent message arguments (of course), and check as much as we
can at template definition time.

This commit also deals with a subtle aspect of template instantiation
in Objective-C++, where the type 'T *' can morph from a dependent
PointerType into a non-dependent ObjCObjectPointer type.

llvm-svn: 102071
2010-04-22 16:44:27 +00:00
Douglas Gregor 4f4946aaaa Whenever we complain about a failed initialization of a function or
method parameter, provide a note pointing at the parameter itself so
the user does not have to manually look for the function/method being
called and match up parameters to arguments. For example, we now get:

t.c:4:5: warning: incompatible pointer types passing 'long *' to
parameter of
      type 'int *' [-pedantic]
  f(long_ptr);
    ^~~~~~~~
t.c:1:13: note: passing argument to parameter 'x' here
void f(int *x);
            ^

llvm-svn: 102038
2010-04-22 00:20:18 +00:00
Douglas Gregor 6b7f12c039 Switch the initialization of Objective-C message parameters (as occurs
during message sends) over to the new initialization code and away
from the C-only CheckSingleAssignmentConstraints. The enables the use
of C++ types in method parameters and message arguments, as well as
unifying more initialiation code overall.

llvm-svn: 102035
2010-04-21 23:24:10 +00:00
Douglas Gregor 8d4de67e1d Implement parsing for message sends in Objective-C++. Message sends in
Objective-C++ have a more complex grammar than in Objective-C
(surprise!), because

  (1) The receiver of an instance message can be a qualified name such
  as ::I or identity<I>::type.
  (2) Expressions in C++ can start with a type.

The receiver grammar isn't actually ambiguous; it just takes a bit of
work to parse past the type before deciding whether we have a type or
expression. We do this in two places within the grammar: once for
message sends and once when we're determining whether a []'d clause in
an initializer list is a message send or a C99 designated initializer.

This implementation of Objective-C++ message sends contains one known
extension beyond GCC's implementation, which is to permit a
typename-specifier as the receiver type for a class message, e.g.,

  [typename compute_receiver_type<T>::type method];

Note that the same effect can be achieved in GCC by way of a typedef,
e.g.,

  typedef typename computed_receiver_type<T>::type Computed;
  [Computed method];

so this is merely a convenience.

Note also that message sends still cannot involve dependent types or
values.

llvm-svn: 102031
2010-04-21 22:36:40 +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
Douglas Gregor 26380d493b More tests for Objective-C-related name lookup weirdness. Yes, it's
weird; yes, it's what GCC does. Almost.

llvm-svn: 101803
2010-04-19 19:10:40 +00:00