summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Switch Sema::AddCXXDirectInitializerToDecl over to InitializationSequenceDouglas Gregor2009-12-221-0/+8
| | | | llvm-svn: 91927
* Switch InitializedEntity from TypeLoc down to just QualTypes, since we don't ↵Douglas Gregor2009-12-221-10/+1
| | | | | | use the location information but we did spend a bunch of time building faked-up TypeLocs llvm-svn: 91905
* Switch the initialization required by return statements over to theDouglas Gregor2009-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | new InitializationSequence. This fixes some bugs (e.g., PR5808), changed some diagnostics, and caused more churn than expected. What's new: - InitializationSequence now has a "C conversion sequence" category and step kind, which falls back to - Changed the diagnostics for returns to always have the result type of the function first and the type of the expression second. CheckSingleAssignmentConstraints to peform checking in C. - Improved ASTs for initialization of return values. The ASTs now capture all of the temporaries we need to create, but intentionally do not bind the tempoary that is actually returned, so that it won't get destroyed twice. - Make sure to perform an (elidable!) copy of the class object that is returned from a class. - Fix copy elision in CodeGen to properly see through the subexpressions that occur with elidable copies. - Give "new" its own entity kind; as with return values and thrown objects, we don't bind the expression so we don't call a destructor for it. Note that, with this patch, I've broken returning move-only types in C++0x. We'll fix it later, when we tackle NRVO. llvm-svn: 91669
* implement PR5654: add -fassume-sane-operator-new, which is enabled by ↵Nuno Lopes2009-12-161-3/+9
| | | | | | | | default, and adds the malloc attribute to the global function new() and to the overloaded new operators. feel free to chage the name to this lengthy argument llvm-svn: 91543
* Fix semantic diagnostics that embed English works, from Nicola Gigante!Douglas Gregor2009-12-161-26/+24
| | | | llvm-svn: 91503
* Check in a rudimentary FullExpr class that isn't used anywhere yet. Rename ↵Anders Carlsson2009-12-161-0/+16
| | | | | | Action::FullExpr to Action::MakeFullExpr to avoid name clashes. llvm-svn: 91494
* Switch the C++ new expression over to InitializationSequence, ratherDouglas Gregor2009-12-161-58/+54
| | | | | | | | | | | | | | | | | | | | | than using its own partial implementation of initialization. Switched CheckInitializerTypes over to InitializedEntity/InitializationKind, to help move us closer to InitializationSequence. Added InitializedEntity::getName() to retrieve the name of the entity, for diagnostics that care about such things. Implemented support for default initialization in InitializationSequence. Clean up the determination of the "source expressions" for an initialization sequence in InitializationSequence::Perform. Taught CXXConstructExpr to store more location information. llvm-svn: 91492
* ShouldDestroyTemporaries? I don't think so.Anders Carlsson2009-12-151-7/+3
| | | | llvm-svn: 91450
* Add support for finding composite type of twp objective-c pointersFariborz Jahanian2009-12-101-0/+5
| | | | | | in objective-c++ mode. llvm-svn: 91059
* Reimplement reference initialization (C++ [dcl.init.ref]) using theDouglas Gregor2009-12-091-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new notion of an "initialization sequence", which encapsulates the computation of the initialization sequence along with diagnostic information and the capability to turn the computed sequence into an expression. At present, I've only switched one CheckReferenceInit callers over to this new mechanism; more will follow. Aside from (hopefully) being much more true to the standard, the diagnostics provided by this reference-initialization code are a bit better than before. Some examples: p5-var.cpp:54:12: error: non-const lvalue reference to type 'struct Derived' cannot bind to a value of unrelated type 'struct Base' Derived &dr2 = b; // expected-error{{non-const lvalue reference to ... ^ ~ p5-var.cpp:55:9: error: binding of reference to type 'struct Base' to a value of type 'struct Base const' drops qualifiers Base &br3 = bc; // expected-error{{drops qualifiers}} ^ ~~ p5-var.cpp:57:15: error: ambiguous conversion from derived class 'struct Diamond' to base class 'struct Base': struct Diamond -> struct Derived -> struct Base struct Diamond -> struct Derived2 -> struct Base Base &br5 = diamond; // expected-error{{ambiguous conversion from ... ^~~~~~~ p5-var.cpp:59:9: error: non-const lvalue reference to type 'long' cannot bind to a value of unrelated type 'int' long &lr = i; // expected-error{{non-const lvalue reference to type ... ^ ~ p5-var.cpp:74:9: error: non-const lvalue reference to type 'struct Base' cannot bind to a temporary of type 'struct Base' Base &br1 = Base(); // expected-error{{non-const lvalue reference to ... ^ ~~~~~~ p5-var.cpp:102:9: error: non-const reference cannot bind to bit-field 'i' int & ir1 = (ib.i); // expected-error{{non-const reference cannot ... ^ ~~~~~~ p5-var.cpp:98:7: note: bit-field is declared here int i : 17; // expected-note{{bit-field is declared here}} ^ llvm-svn: 90992
* Look through using declarations when searching for allocation overloads.Anders Carlsson2009-12-091-1/+2
| | | | llvm-svn: 90961
* Fix for PR5730: make sure to consistently callEli Friedman2009-12-091-11/+5
| | | | | | PerformObjectArgumentInitialization from BuildCXXMemberCallExpr. llvm-svn: 90950
* Implemented an implicit conversion from "noreturn" function types (andDouglas Gregor2009-12-091-0/+10
| | | | | | | | | | | | | | pointers thereof) to their corresponding non-noreturn function types. This conversion is considered an exact match for overload-resolution purposes. Note that we are a little more strict that GCC is, because we encode noreturn in the type system, but that's a Good Thing (TM) because it does not allow us to pretend that potentially-returning function pointers are non-returning function pointers. Fxies PR5620. llvm-svn: 90913
* Patch to allow matching 0 with an objective-c pointer typeFariborz Jahanian2009-12-081-2/+2
| | | | | | in objective-c++ mode. Fixes radar 7443165 llvm-svn: 90874
* DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated ↵John McCall2009-12-071-5/+5
| | | | | | | | | | | | | | | | | | | | | variables, but the results are imperfect. For posterity, I did: cat <<EOF > $cmdfile s/DeclaratorInfo/TypeSourceInfo/g s/DInfo/TInfo/g s/TypeTypeSourceInfo/TypeSourceInfo/g s/SourceTypeSourceInfo/TypeSourceInfo/g EOF find lib -name '*.cpp' -not -path 'lib/Parse/*' -exec sed -i '' -f $cmdfile '{}' \; find lib -name '*.h' -exec sed -i '' -f $cmdfile '{}' \; find include -name '*.h' -not -path 'include/clang/Parse/*' -not -path 'include/clang/Basic/*' -exec sed -i '' -f $cmdfile '{}' \; llvm-svn: 90743
* When we're building a CXXExprWithTemporaries, only include thoseDouglas Gregor2009-12-031-4/+7
| | | | | | | | | | | temporaries that are within our current evaluation context. That way, nested evaluation contexts (e.g., within a sizeof() expression) won't see temporaries from outer contexts. Also, make sure to push a new evaluation context when instantiating the initializer of a variable; this may be an unevaluated context or a potentially-evaluated context, depending on whether it's an in-class initializer or not. Fixes PR5672. llvm-svn: 90460
* In Sema, whenever we think that a function is going to cause a vtable to be ↵Anders Carlsson2009-12-021-4/+1
| | | | | | generated, we mark any virtual implicit member functions as referenced. llvm-svn: 90327
* Rip out the last remaining implicit use of OverloadedFunctionDecl in Sema:John McCall2009-12-021-2/+1
| | | | | | | LookupResult::getAsSingleDecl() is no more. Shift Sema::LookupSingleName to return null on overloaded results. llvm-svn: 90309
* Fix a code gen. crash synthesizing a destructor.Fariborz Jahanian2009-12-011-1/+4
| | | | | | Fixes pr5660. llvm-svn: 90283
* Eliminate the use of OverloadedFunctionDecl in member expressions.John McCall2009-11-301-29/+11
| | | | | | | | Create a new UnresolvedMemberExpr for these lookups. Assorted hackery around qualified member expressions; this will all go away when we implement the correct (i.e. extremely delayed) implicit-member semantics. llvm-svn: 90161
* More work on ScalarExprEmitter::EmitCastExpr: for every cast kind, eitherEli Friedman2009-11-271-11/+15
| | | | | | | | | | | implement it explicitly or assert that it doesn't make sense for a scalar. This caught a couple interesting issues: one, CK_BaseToDerivedMemberPointer casts were getting silently miscompiled, and two, Sema was constructing some strange implicit casts of type CK_UserDefinedConversion. The change in SemaExprCXX makes sure the cast kinds are getting set correctly. llvm-svn: 89987
* Refactor our handling of expression evaluation contexts, so that SemaDouglas Gregor2009-11-261-3/+4
| | | | | | | | | | | | maintains a stack of evaluation contexts rather than having the parser do it. This change made it simpler to track in which contexts temporaries were created, so that we could... "Forget" about temporaries created within unevaluated contexts, so that we don't build a CXXExprWithTemporaries and, therefore, destroy the integral-constness of our expressions. Fixes PR5609. llvm-svn: 89908
* Eliminate CXXConditionDeclExpr with extreme prejudice.Douglas Gregor2009-11-251-59/+0
| | | | | | | | | | | | | | | | | All statements that involve conditions can now hold on to a separate condition declaration (a VarDecl), and will use a DeclRefExpr referring to that VarDecl for the condition expression. ForStmts now have such a VarDecl (I'd missed those in previous commits). Also, since this change reworks the Action interface for if/while/switch/for, use FullExprArg for the full expressions in those expressions, to ensure that we're emitting Note that we are (still) not generating the right cleanups for condition variables in for statements. That will be a follow-on commit. llvm-svn: 89817
* Refactor argument collection of constructor calls usingFariborz Jahanian2009-11-241-1/+1
| | | | | | the common routine. llvm-svn: 89802
* More cleanup of argument call collection.Fariborz Jahanian2009-11-241-1/+3
| | | | llvm-svn: 89789
* Rip out TemplateIdRefExpr and make UnresolvedLookupExpr and John McCall2009-11-241-1/+1
| | | | | | | | | | | | DependentScopeDeclRefExpr support storing templateids. Unite the common code paths between ActOnDeclarationNameExpr and ActOnTemplateIdExpr. This gets us to a point where we don't need to store function templates in the AST using TemplateNames, which is critical to ripping out OverloadedFunction. Also resolves a few FIXMEs. llvm-svn: 89785
* Refactor collection of call arguments in common code.Fariborz Jahanian2009-11-241-20/+9
| | | | | | | Add support for variadic collection functions. More to do here. llvm-svn: 89781
* Un-break instantiation of if statements with conditional variablesDouglas Gregor2009-11-241-1/+10
| | | | llvm-svn: 89767
* Explicitly track the condition variable within an "if" statement,Douglas Gregor2009-11-231-0/+21
| | | | | | | | | rather than burying it in a CXXConditionDeclExpr (that occassionally hides behind implicit conversions). Similar changes for switch, while, and do-while will follow, then the removal of CXXConditionDeclExpr. This commit is the canary. llvm-svn: 89717
* Handle converting member pointers to bool.Anders Carlsson2009-11-231-2/+7
| | | | llvm-svn: 89692
* Do not mark declarations as used when performing overload resolution. Fixes ↵Douglas Gregor2009-11-231-4/+4
| | | | | | PR5541 llvm-svn: 89652
* "Incremental" progress on using expressions, by which I mean totally rippingJohn McCall2009-11-211-8/+8
| | | | | | | | | | | | | | | | | | | | | | into pretty much everything about overload resolution in order to wean BuildDeclarationNameExpr off LookupResult::getAsSingleDecl(). Replace UnresolvedFunctionNameExpr with UnresolvedLookupExpr, which generalizes the idea of a non-member lookup that we haven't totally resolved yet, whether by overloading, argument-dependent lookup, or (eventually) the presence of a function template in the lookup results. Incidentally fixes a problem with argument-dependent lookup where we were still performing ADL even when the lookup results contained something from a block scope. Incidentally improves a diagnostic when using an ObjC ivar from a class method. This just fell out from rewriting BuildDeclarationNameExpr's interaction with lookup, and I'm too apathetic to break it out. The only remaining uses of OverloadedFunctionDecl that I know of are in TemplateName and MemberExpr. llvm-svn: 89544
* When checking the base object of a member access expression (b.foo,Douglas Gregor2009-11-201-3/+3
| | | | | | b->foo), don't look through pointers unless we have an -> operator. llvm-svn: 89480
* Don't build an explicit conversion to a reference typeDouglas Gregor2009-11-201-2/+3
| | | | llvm-svn: 89441
* When we have a non-dependent expression such asDouglas Gregor2009-11-201-5/+0
| | | | | | | | | | | | | | | | A::f that occurs within a non-static member function with a type-dependent "this", don't consider this to be a case for introduction of an implicit "(*this)." to refer to a specific member function unless we know (at template definition time) that A is a base class of *this. There is some disagreement here between GCC, EDG, and Clang about the handling of this case. I believe that Clang now has the correct, literal interpretation of the standard, but have asked for clarification (c++std-core-15483). llvm-svn: 89425
* Patch to implement new-operators with default args.Fariborz Jahanian2009-11-191-3/+31
| | | | | | Fixes pr5547. llvm-svn: 89370
* ignore parens surounding the type when diagnosingFariborz Jahanian2009-11-181-1/+1
| | | | | | pointer-to-member cast types used in expressions. llvm-svn: 89255
* This patch fixes a bug in misdiagnosing correctFariborz Jahanian2009-11-181-0/+6
| | | | | | use of pointer to data member. llvm-svn: 89251
* Split LookupResult into its own header.John McCall2009-11-181-0/+1
| | | | llvm-svn: 89199
* Require the object type of a member access expression ("." or "->") toDouglas Gregor2009-11-171-1/+8
| | | | | | be complete. llvm-svn: 89042
* Carry lookup configuration throughout lookup on the LookupResult. GiveJohn McCall2009-11-171-9/+7
| | | | | | | | | | | | | LookupResult RAII powers to diagnose ambiguity in the results. Other diagnostics (e.g. access control and deprecation) will be moved to automatically trigger during lookup as part of this same mechanism. This abstraction makes it much easier to encapsulate aliasing declarations (e.g. using declarations) inside the lookup system: eventually, lookup will just produce the aliases in the LookupResult, and the standard access methods will naturally strip the aliases off. llvm-svn: 89027
* First part of changes to eliminate problems with cv-qualifiers andDouglas Gregor2009-11-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sugared types. The basic problem is that our qualifier accessors (getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at the current QualType and not at any qualifiers that come from sugared types, meaning that we won't see these qualifiers through, e.g., typedefs: typedef const int CInt; typedef CInt Self; Self.isConstQualified() currently returns false! Various bugs (e.g., PR5383) have cropped up all over the front end due to such problems. I'm addressing this problem by splitting each qualifier accessor into two versions: - the "local" version only returns qualifiers on this particular QualType instance - the "normal" version that will eventually combine qualifiers from this QualType instance with the qualifiers on the canonical type to produce the full set of qualifiers. This commit adds the local versions and switches a few callers from the "normal" version (e.g., isConstQualified) over to the "local" version (e.g., isLocalConstQualified) when that is the right thing to do, e.g., because we're printing or serializing the qualifiers. Also, switch a bunch of Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType() expressions over to Context.hasSameUnqualifiedType(T1, T2) llvm-svn: 88969
* Repair broken FindCompositePointerType. Correct early termination condition. ↵Sebastian Redl2009-11-161-12/+14
| | | | | | Get CVR qualifiers from canonical types. Traverse collected qualifiers in reverse order on rebuilding the pointer, so that we don't swap inner and outer qualifiers. That last one fixes PR5509. llvm-svn: 88960
* Factor finding a deallocation function for a record type out into a separate ↵Anders Carlsson2009-11-151-40/+62
| | | | | | function. llvm-svn: 88857
* If we find a deallocation function in the class scope, but it is a placement ↵Anders Carlsson2009-11-151-1/+16
| | | | | | function we should not look for a deallocation function in the global scope. llvm-svn: 88851
* - Have TryStaticImplicitCast set the cast kind to NoOp when binding a ↵Sebastian Redl2009-11-141-7/+10
| | | | | | | | | reference. CheckReferenceInit already inserts implicit casts to the necessary types. This fixes an assertion in CodeGen for some casts and brings a fix for PR5453 close, if I understand that bug correctly. - Also, perform calculated implicit cast sequences if they're determined to work. This finally diagnoses static_cast to ambiguous or implicit bases and fixes two long-standing fixmes in the test case. For the C-style cast, this requires propagating the access check suppression pretty deep into other functions. - Pass the expressions for TryStaticCast and TryStaticImplicitCast by reference. This should lead to a better AST being emitted for such casts, and also fixes a memory leak, because CheckReferenceInit and PerformImplicitConversion wrap the node passed to them. These wrappers were previously lost. llvm-svn: 88809
* Diagnose ambiguity of operator delete and operator delete[]. Sebastian, ↵Anders Carlsson2009-11-141-1/+6
| | | | | | please review. llvm-svn: 88747
* Improve source-location information for implicitly-generated member call ↵Douglas Gregor2009-11-121-1/+1
| | | | | | expressions llvm-svn: 86989
* Fix use-after-free bug.Eli Friedman2009-11-081-3/+2
| | | | llvm-svn: 86485
* When we encounter a derived-to-base conversion when performing anDouglas Gregor2009-11-061-1/+11
| | | | | | | implicit conversion sequence, check the validity of this conversion and then perform it. llvm-svn: 86210
OpenPOWER on IntegriCloud