summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
* Implement parsing for message sends in Objective-C++. Message sends inDouglas Gregor2010-04-214-59/+216
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Migrate the responsibility for turning the receiver name in anDouglas Gregor2010-04-215-62/+59
| | | | | | | | | Objective-C class message expression into a type from the parser (which was doing so in two places) to Action::getObjCMessageKind() which, in the case of Sema, reduces the number of name lookups we need to perform. llvm-svn: 102026
* Diagnose access to fields with private constructors.Anders Carlsson2010-04-211-0/+7
| | | | llvm-svn: 102025
* Eliminate unused code in Sema::ActOnSuperMessage and use early exitsDouglas Gregor2010-04-211-68/+28
| | | | | | to reduce nesting. No functionality change. llvm-svn: 102022
* Rework the Parser-Sema interaction for Objective-C messageDouglas Gregor2010-04-216-269/+562
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Keep tack of whether a base in an InitializedEntity is an inherited virtual ↵Anders Carlsson2010-04-214-16/+45
| | | | | | base or not. Use this in CheckConstructorAccess. llvm-svn: 102020
* ABI/x86-32 & x86-64: Alignment on 'byval' must be set when when the alignmentDaniel Dunbar2010-04-211-19/+40
| | | | | | exceeds the minimum ABI alignment. llvm-svn: 102019
* IRgen/x86-32: Factor out getIndirectResult(), to match x86-64 factoring.Daniel Dunbar2010-04-211-9/+20
| | | | llvm-svn: 102015
* IRgen: Add checking that the LLVM and AST record layout offsets agree (forDaniel Dunbar2010-04-211-1/+20
| | | | | | non-bit-fields). llvm-svn: 102014
* Improve on source location of diagnostic when defaultFariborz Jahanian2010-04-211-1/+1
| | | | | | property synthesis is using a super class ivar. llvm-svn: 102011
* Pass the InitializedEntity to Sema::CheckConstructorAccess and use it to ↵Anders Carlsson2010-04-213-8/+20
| | | | | | report different diagnostics depending on which entity is being initialized. llvm-svn: 102010
* Comment out an assert for now.Anders Carlsson2010-04-211-0/+3
| | | | llvm-svn: 102007
* I failed to notice that my last patch wasn't doing as much as it couldJohn McCall2010-04-212-3/+6
| | | | | | | because EmitBranch actually clears the insert point. This version actually accomplishes what I initially wanted. llvm-svn: 101998
* Teach EmitBlock to put the target block immediately after the current blockJohn McCall2010-04-211-1/+6
| | | | | | | | | | | (if there's a current block). The chief advantage of doing this is that it lets us pick blocks (e.g. EH blocks) to push to the end of the function so that fallthrough happens consistently --- i.e. it gives us the flexibility of ordering blocks as we please without having to change the order in which we generate code. There are standard (?) optimization passes which can do some of that for us, but better to generate reasonable code to begin with. llvm-svn: 101997
* Miscellaneous codegen cleanups. Mostly, don't create new basic blocksJohn McCall2010-04-214-44/+66
| | | | | | | just to save the current insertion state! This change significantly simplifies the IR CFG in exceptions code. llvm-svn: 101996
* CXXNamedCastExpr is actually an abstract expression.Zhongxing Xu2010-04-213-2/+1
| | | | llvm-svn: 101994
* Sink the _GNU_SOURCE definition down into the target configuration,Douglas Gregor2010-04-212-24/+4
| | | | | | | and only define it where we know we need it---Linux and Cygwin. Thanks to Chris for the prodding. llvm-svn: 101989
* Use the right predecessor.Zhongxing Xu2010-04-211-1/+1
| | | | llvm-svn: 101981
* Add initial support for C++ delete expr.Zhongxing Xu2010-04-212-2/+17
| | | | llvm-svn: 101980
* Overhaul the AST representation of Objective-C message sendDouglas Gregor2010-04-2118-552/+802
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expressions, to improve source-location information, clarify the actual receiver of the message, and pave the way for proper C++ support. The ObjCMessageExpr node represents four different kinds of message sends in a single AST node: 1) Send to a object instance described by an expression (e.g., [x method:5]) 2) Send to a class described by the class name (e.g., [NSString method:5]) 3) Send to a superclass class (e.g, [super method:5] in class method) 4) Send to a superclass instance (e.g., [super method:5] in instance method) Previously these four cases where tangled together. Now, they have more distinct representations. Specific changes: 1) Unchanged; the object instance is represented by an Expr*. 2) Previously stored the ObjCInterfaceDecl* referring to the class receiving the message. Now stores a TypeSourceInfo* so that we know how the class was spelled. This both maintains typedef information and opens the door for more complicated C++ types (e.g., dependent types). There was an alternative, unused representation of these sends by naming the class via an IdentifierInfo *. In practice, we either had an ObjCInterfaceDecl *, from which we would get the IdentifierInfo *, or we fell into the case below... 3) Previously represented by a class message whose IdentifierInfo * referred to "super". Sema and CodeGen would use isStr("super") to determine if they had a send to super. Now represented as a "class super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). 4) Previously represented by an instance message whose receiver is a an ObjCSuperExpr, which Sema and CodeGen would check for via isa<ObjCSuperExpr>(). Now represented as an "instance super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). Note that ObjCSuperExpr only has one remaining use in the AST, which is for "super.prop" references. The new representation of ObjCMessageExpr is 2 pointers smaller than the old one, since it combines more storage. It also eliminates a leak when we loaded message-send expressions from a precompiled header. The representation also feels much cleaner to me; comments welcome! This patch attempts to maintain the same semantics we previously had with Objective-C message sends. In several places, there are massive changes that boil down to simply replacing a nested-if structure such as: if (message has a receiver expression) { // instance message if (isa<ObjCSuperExpr>(...)) { // send to super } else { // send to an object } } else { // class message if (name->isStr("super")) { // class send to super } else { // send to class } } with a switch switch (E->getReceiverKind()) { case ObjCMessageExpr::SuperInstance: ... case ObjCMessageExpr::Instance: ... case ObjCMessageExpr::SuperClass: ... case ObjCMessageExpr::Class:... } There are quite a few places (particularly in the checkers) where send-to-super is effectively ignored. I've placed FIXMEs in most of them, and attempted to address send-to-super in a reasonable way. This could use some review. llvm-svn: 101972
* Remove an unused parameter from isImplicitlyDefined.Anders Carlsson2010-04-201-2/+1
| | | | llvm-svn: 101962
* Fix comment to reflect recent code change.John Thompson2010-04-201-1/+1
| | | | llvm-svn: 101960
* Specify linkage for Objective-C declarations.Ted Kremenek2010-04-201-0/+23
| | | | llvm-svn: 101953
* Factor some common code out into a separate function.Anders Carlsson2010-04-201-37/+40
| | | | llvm-svn: 101952
* Fixes a code gen. bug by removing an assert.Fariborz Jahanian2010-04-201-2/+0
| | | | | | | It is ok to have c++-ness inside extern "C" block. Fixes pr6644. llvm-svn: 101948
* fix the ?: fixit that ted added to recover properly.Chris Lattner2010-04-201-5/+5
| | | | llvm-svn: 101943
* Fix crash on invalid code where a @throw statement is not followed by a ';'Ted Kremenek2010-04-201-1/+2
| | | | llvm-svn: 101941
* change FullSourceLoc to have a *const* SourceManager&, eliminatingChris Lattner2010-04-202-5/+2
| | | | | | a const_cast. llvm-svn: 101940
* push some source location information down through the compiler,Chris Lattner2010-04-2011-61/+62
| | | | | | | | into ContentCache::getBuffer. This allows it to produce diagnostics on the broken #include line instead of without a location. llvm-svn: 101939
* Patch to support transparent_union types onFariborz Jahanian2010-04-201-0/+5
| | | | | | objective-c methods. Fixes radar 7875968. llvm-svn: 101935
* enhance sourcemgr to detect various UTF BOM's and emit a fatal errorChris Lattner2010-04-201-0/+35
| | | | | | | | | about it instead of producing tons of garbage from the lexer. It would be even better for sourcemgr to dynamically transcode (e.g. from UTF16 -> UTF8). llvm-svn: 101924
* Back out r101911 and see if it makes the bots happy.Anders Carlsson2010-04-202-30/+13
| | | | llvm-svn: 101921
* Remove dead code.Benjamin Kramer2010-04-202-30/+0
| | | | llvm-svn: 101920
* IRgen: Always use i8 arrays to access union bit-fields. This is ugly, butDaniel Dunbar2010-04-201-15/+6
| | | | | | | matches how we currently handle structs, and this correctly handles -fno-bitfield-type-align. llvm-svn: 101918
* remove some extraneous qualifiers.Chris Lattner2010-04-201-2/+2
| | | | llvm-svn: 101912
* Fix a bug which triggered the assertion I added yesterday. Basically, when ↵Anders Carlsson2010-04-202-13/+30
| | | | | | we initialize the vtable pointer for a virtual base, and there was another path from the most derived class to another base with the same class type, we would use the wrong base. llvm-svn: 101911
* Move code to apply a non-virtual and virtual offset out into a separate ↵Anders Carlsson2010-04-201-19/+31
| | | | | | function. llvm-svn: 101909
* Keep proper source location information for the type in an Objective-CDouglas Gregor2010-04-205-15/+19
| | | | | | @encode expression. llvm-svn: 101907
* Introduce a limit on the depth of the template instantiation backtraceDouglas Gregor2010-04-205-2/+38
| | | | | | | | | | | | | | | | we will print with each error that occurs during template instantiation. When the backtrace is longer than that, we will print N/2 of the innermost backtrace entries and N/2 of the outermost backtrace entries, then skip the middle entries with a note such as: note: suppressed 2 template instantiation contexts; use -ftemplate-backtrace-limit=N to change the number of template instantiation entries shown This should eliminate some excessively long backtraces that aren't providing any value. llvm-svn: 101882
* don't slap noalias attribute on stret result arguments.Chris Lattner2010-04-201-2/+1
| | | | | | | | | This mirror's Dan's patch for llvm-gcc in r97989, and fixes the miscompilation in PR6525. There is some contention over whether this is the right thing to do, but it is the conservative answer and demonstrably fixes a miscompilation. llvm-svn: 101877
* Replace code with a method call. No functionality change.Zhongxing Xu2010-04-201-65/+8
| | | | llvm-svn: 101876
* Pass the nearest virtual base decl to InitializeVTablePointers. No ↵Anders Carlsson2010-04-202-14/+11
| | | | | | functionality change right now. llvm-svn: 101872
* reapply john's patch, he broke mainline again by changing the test.Chris Lattner2010-04-201-1/+1
| | | | llvm-svn: 101871
* Assert that the path from the derived to the base class in ↵Anders Carlsson2010-04-201-0/+7
| | | | | | CodeGenFunction::GetAddressOfBaseClass is not ambiguous. llvm-svn: 101869
* Use GetState() to get the possible cleaned state.Zhongxing Xu2010-04-201-3/+3
| | | | llvm-svn: 101867
* revert r101863, whcih is causing Sema/altivec-init.c to fail on a tonChris Lattner2010-04-201-1/+1
| | | | | | | | | | of buildbots with: error: 'error' diagnostics expected but not seen: Line 9: too few elements in vector initialization (expected 8 elements, have 2) 1 warning and 1 error generated. llvm-svn: 101864
* Altivec vector literal initializer count mismatch error removed.John Thompson2010-04-201-1/+1
| | | | llvm-svn: 101863
* Improve handling of CXXNewExpr.Zhongxing Xu2010-04-201-7/+62
| | | | llvm-svn: 101862
* Restore r101841 without modification. Also mark 'operator delete' as used forJohn McCall2010-04-201-0/+9
| | | | | | actual delete expressions, not just new expressions. llvm-svn: 101861
* Revert r101841 and follow-up.John McCall2010-04-201-7/+0
| | | | llvm-svn: 101859
OpenPOWER on IntegriCloud