summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Unify two diagnostics into one.Anders Carlsson2010-04-223-10/+9
| | | | llvm-svn: 102040
* Call PerformCopyInitialization to properly initialize the exception temporaryJohn McCall2010-04-221-15/+12
| | | | | | | | | in a throw expression. Use EmitAnyExprToMem to emit the throw expression, which magically elides the final copy-constructor call (which raises a new strict-compliance bug, but baby steps). Give __cxa_throw a destructor pointer if the exception type has a non-trivial destructor. llvm-svn: 102039
* Whenever we complain about a failed initialization of a function orDouglas Gregor2010-04-224-4/+37
| | | | | | | | | | | | | | | | | 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
* Remove an unused declaration.Anders Carlsson2010-04-211-1/+0
| | | | llvm-svn: 102037
* Switch the initialization of Objective-C message parameters (as occursDouglas Gregor2010-04-213-23/+25
| | | | | | | | | 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
* Migrate the responsibility for turning the receiver name in anDouglas Gregor2010-04-212-11/+25
| | | | | | | | | 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-213-230/+424
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* CXXNamedCastExpr is actually an abstract expression.Zhongxing Xu2010-04-211-0/+1
| | | | llvm-svn: 101994
* Overhaul the AST representation of Objective-C message sendDouglas Gregor2010-04-213-111/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Factor some common code out into a separate function.Anders Carlsson2010-04-201-37/+40
| | | | llvm-svn: 101952
* push some source location information down through the compiler,Chris Lattner2010-04-201-2/+1
| | | | | | | | 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
* Remove dead code.Benjamin Kramer2010-04-202-30/+0
| | | | llvm-svn: 101920
* Keep proper source location information for the type in an Objective-CDouglas Gregor2010-04-203-13/+17
| | | | | | @encode expression. llvm-svn: 101907
* Introduce a limit on the depth of the template instantiation backtraceDouglas Gregor2010-04-201-1/+21
| | | | | | | | | | | | | | | | 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
* reapply john's patch, he broke mainline again by changing the test.Chris Lattner2010-04-201-1/+1
| | | | llvm-svn: 101871
* 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
* 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
* Don't bother looking for (or diagnosing problems with) the 'operator delete'John McCall2010-04-201-0/+7
| | | | | | associated with a new expression if -fno-exceptions is set. llvm-svn: 101841
* Do not diagnose unused-parameter errors in template instantiations. WeDouglas Gregor2010-04-191-1/+7
| | | | | | will already have done so when the template is declared. llvm-svn: 101838
* Keep track of the actual storage specifier written on a variable orDouglas Gregor2010-04-1910-48/+108
| | | | | | | | function declaration, since it may end up being changed (e.g., "extern" can become "static" if a prior declaration was static). Patch by Enea Zaffanella and Paolo Bolzoni. llvm-svn: 101826
* Only suppress the "extern variable has an initializer" warning when the ↵Douglas Gregor2010-04-191-1/+1
| | | | | | extern entity being initialized is const. llvm-svn: 101821
* Disable the "'extern' variable has an initializer" warning in C++,Douglas Gregor2010-04-191-1/+2
| | | | | | | since it makes sense there to have const extern variables. Fixes PR6495. llvm-svn: 101818
* When normal name lookup to disambiguiate an Objective-C message sendDouglas Gregor2010-04-191-0/+10
| | | | | | | fails to find anything, perform ivar lookup and, if we find one, consider this an instance message. llvm-svn: 101810
* Remove the argument number from the constant integer diagnostic.Eric Christopher2010-04-191-1/+1
| | | | | | Update all of the testcases accordingly. llvm-svn: 101795
* When searching for code-completion and typo-correction candidates,Douglas Gregor2010-04-191-0/+15
| | | | | | | | look from an Objective-C class or category to its implementation, to pick up synthesized ivars. Fixes a problem reported by David Chisnall. llvm-svn: 101792
* Fix -Wcast-qual warnings.Dan Gohman2010-04-191-1/+2
| | | | llvm-svn: 101786
* Make sure that we don't visit redeclarations of nested classes whileDouglas Gregor2010-04-181-1/+4
| | | | | | | | instantiating class members as part of an explicit instantiation. Addresses a compilation problem in Boost.Serialization. llvm-svn: 101725
* C++ [namespace.memdef]p3 only applies when the friend is not named viaDouglas Gregor2010-04-181-15/+17
| | | | | | | | | a qualified name. We weren't checking for an empty nested-name-specifier when dealing with friend class templates (although we were checking in the other places where we deal with this paragraph). Fixes a Boost.Serialization showstopper. llvm-svn: 101724
* Bail out early to avoid comparing the internals of two conversion sequences ofBenjamin Kramer2010-04-181-0/+5
| | | | | | | | | different kinds (aka garbage). This happens if we're comparing a standard conversion sequence to an ambiguous one which have the same KindRank. Found by valgrind. llvm-svn: 101717
* When performing reference initialization for the purposes of overloadDouglas Gregor2010-04-181-7/+17
| | | | | | | | | | | resolution ([over.ics.ref]), we take some shortcuts required by the standard that effectively permit binding of a const volatile reference to an rvalue. We have to treat lightly here to avoid infinite recursion. Fixes PR6177. llvm-svn: 101712
* Binding a reference to an rvalue is a direct binding in C++0x but notDouglas Gregor2010-04-181-20/+17
| | | | | | in C++03. llvm-svn: 101707
* Fix the access checking of function and function template argument types,Chandler Carruth2010-04-181-2/+9
| | | | | | | return types, and default arguments. This fixes PR6855 along with several similar cases where we rejected valid code. llvm-svn: 101706
* When checking the copy constructor for the optional copy during aDouglas Gregor2010-04-181-3/+19
| | | | | | | | | reference binding to an rvalue of reference-compatible type, check parameters after the first for complete parameter types and build any required default function arguments. We're effectively simulating the type-checking for a call without building the call itself. llvm-svn: 101705
* In C++98/03, when binding a reference to an rvalue ofDouglas Gregor2010-04-183-16/+95
| | | | | | | | | | | | | | | | | reference-compatible type, the implementation is permitted to make a copy of the rvalue (or many such copies, even). However, even though we don't make that copy, we are required to check for the presence of a suitable copy constructor. With this change, we do. Note that in C++0x we are not allowed to make these copies, so we test both dialects separately. Also note the FIXME in one of the C++03 tests, where we are not instantiating default function arguments for the copy constructor we pick (but do not call). The fix is obvious; eliminating the infinite recursion it causes is not. Will address that next. llvm-svn: 101704
* Allow the 'ibaction' attribute to be attached to method declarations (and ↵Ted Kremenek2010-04-181-2/+12
| | | | | | not issue a warning). llvm-svn: 101699
* Do not consider explicit constructors when performing a copy to aDouglas Gregor2010-04-181-1/+2
| | | | | | | | | temporary object. This is blindingly obvious from reading C++ [over.match.ctor]p1, but somehow I'd missed it and it took DR152 to educate me. Adjust one test that was relying on this non-standard behavior. llvm-svn: 101688
* Improve our handling of user-defined conversions as part of overloadDouglas Gregor2010-04-174-77/+138
| | | | | | | | | | | | | | | | | resolution. There are two sources of problems involving user-defined conversions that this change eliminates, along with providing simpler interfaces for checking implicit conversions: - It eliminates a case of infinite recursion found in Boost. - It eliminates the search for the constructor needed to copy a temporary generated by an implicit conversion from overload resolution. Overload resolution assumes that, if it gets a value of the parameter's class type (or a derived class thereof), there is a way to copy if... even if there isn't. We now model this properly. llvm-svn: 101680
* Vtable -> VTable renames across the board.Anders Carlsson2010-04-171-2/+2
| | | | llvm-svn: 101666
* Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer2010-04-173-4/+3
| | | | | | | | users of getNameAsString on a stream. The next step is to print the name directly into the stream, avoiding a temporary std::string copy. llvm-svn: 101632
* Consolidate most of the integer constant expression builtin requirementEric Christopher2010-04-172-70/+52
| | | | | | | | checking into a single function and use that throughout. Remove some now unnecessary diagnostics and update tests with now more accurate diagnostics. llvm-svn: 101610
OpenPOWER on IntegriCloud