summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rework parsing of pseudo-destructor expressions and explicitDouglas Gregor2010-02-241-2/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | destructor calls, e.g., p->T::~T We now detect when the member access that we've parsed, e.g., p-> or x. may be a pseudo-destructor expression, either because the type of p or x is a scalar or because it is dependent (and, therefore, may become a scalar at template instantiation time). We then parse the pseudo-destructor grammar specifically: ::[opt] nested-name-specifier[opt] type-name :: ∼ type-name and hand those results to a new action, ActOnPseudoDestructorExpr, which will cope with both dependent member accesses of destructors and with pseudo-destructor expressions. This commit affects the parsing of pseudo-destructors, only; the semantic actions still go through the semantic actions for member access expressions. That will change soon. llvm-svn: 97045
* Implement crazy destructor name lookup semantics differently inDouglas Gregor2010-02-231-14/+56
| | | | | | | | | | C++98/03 and C++0x, since the '0x semantics break valid C++98/03 code. This new mess is tracked by core issue 399, which is still unresolved. Fixes PR6358 and PR6359. llvm-svn: 96836
* Eliminate the default arguments to ASTContext::getFunctionType(),Douglas Gregor2010-02-211-1/+1
| | | | | | | | fixing up a few callers that thought they were propagating NoReturn information but were in fact saying something about exception specifications. llvm-svn: 96766
* Implement support for parsing pseudo-destructor expression with a ↵Douglas Gregor2010-02-211-2/+3
| | | | | | | | | | | | nested-name-specifier, e.g., typedef int Int; int *p; p->Int::~Int(); This weakens the invariant that the only types in nested-name-specifiers are tag types (restricted to class types in C++98/03). However, we weaken this invariant as little as possible, accepting arbitrary types in nested-name-specifiers only when we're in a member access expression that looks like a pseudo-destructor expression. llvm-svn: 96743
* Commiting a revert from dgregor of a bit of destructor logic until we canChandler Carruth2010-02-211-17/+11
| | | | | | | figure out how not to break lots of code using this. See PR6358 and PR6359 for motivating examples. FIXME's left in the code and the test. llvm-svn: 96733
* Fixed a crash specific to blocks in c++ uncovered by an internalFariborz Jahanian2010-02-181-1/+3
| | | | | | test suite. llvm-svn: 96608
* Improve parsing and instantiation of destructor names, so that we canDouglas Gregor2010-02-161-0/+226
| | | | | | | | | | | | | | | | | | | | | | | now cope with the destruction of types named as dependent templates, e.g., y->template Y<T>::~Y() Nominally, we implement C++0x [basic.lookup.qual]p6. However, we don't follow the letter of the standard here because that would fail to parse template<typename T, typename U> X0<T, U>::~X0() { } properly. The problem is captured in core issue 339, which gives some (but not enough!) guidance. I expect to revisit this code when the resolution of 339 is clear, and/or we start capturing better source information for DeclarationNames. Fixes PR6152. llvm-svn: 96367
* Fix leak in CXXNewExpr where the SubExprs array would get allocated directly ↵Ted Kremenek2010-02-111-4/+7
| | | | | | using 'new[]' instead of the allocator associated with ASTContext. llvm-svn: 95933
* Eliminate a bunch of unnecessary ASTContexts from members functions ofDouglas Gregor2010-02-111-1/+1
| | | | | | Decl subclasses. No functionality change. llvm-svn: 95841
* Thread a source location into the template-argument deduction routines. ThereJohn McCall2010-02-081-2/+2
| | | | | | | may be some other places that could take advantage of this new information, but I haven't really looked yet. llvm-svn: 95600
* When we're parsing an expression that may have looked like aDouglas Gregor2010-02-051-1/+3
| | | | | | | | | declaration, we can end up with template-id annotation tokens for types that have not been converted into type annotation tokens. When this is the case, translate the template-id into a type and parse as an expression. llvm-svn: 95404
* Extract a common structure for holding information about the definitionJohn McCall2010-02-041-11/+15
| | | | | | | | of a C++ record. Exposed a lot of problems where various routines were silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order) when presented with a non-definition. Also cuts down on memory usage. llvm-svn: 95330
* Teach the allocation function overload handling to deal with templates, andChandler Carruth2010-02-031-12/+21
| | | | | | | | | | | prevent a crash on templates when looking for an existing declaration of the predefined global operators. This fixes PR5918. Added an easy test case for the overload handling, but testing the crash is a bit trickier. Created a new test that can use multiple runs with a define to trigger which test case is used so we can test this type of issue. llvm-svn: 95220
* Implement the lvalue-to-rvalue conversion where needed. TheDouglas Gregor2010-02-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class type to rvalue expressions of the unqualified variant of that type. For example, given: const int i; (void)(i + 17); the lvalue-to-rvalue conversion for the subexpression "i" will turn it from an lvalue expression (a DeclRefExpr) with type 'const int' into an rvalue expression with type 'int'. Both C and C++ mandate this conversion, and somehow we've slid through without implementing it. We now have both DefaultFunctionArrayConversion and DefaultFunctionArrayLvalueConversion, and which gets used depends on whether we do the lvalue-to-rvalue conversion or not. Generally, we do the lvalue-to-rvalue conversion, but there are a few notable exceptions: - the left-hand side of a '.' operator - the left-hand side of an assignment - a C++ throw expression - a subscript expression that's subscripting a vector Making this change exposed two issues with blocks: - we were deducing const-qualified return types of non-class type from a block return, which doesn't fit well - we weren't always setting the known return type of a block when it was provided with the ^return-type syntax Fixes the current Clang-on-Clang compile failure and PR6076. llvm-svn: 95167
* Switch expressions like T() and T(1,2) over to new-style initialization. I'mEli Friedman2010-01-311-23/+12
| | | | | | | not quite sure what we want to do about the AST representation; comments welcome. llvm-svn: 94967
* Fix a major oversight in the comparison of standard conversionDouglas Gregor2010-01-271-2/+2
| | | | | | | | | | | | | | sequences, where we would occasionally determine (incorrectly) that one standard conversion sequence was a proper subset of another when, in fact, they contained completely incomparable conversions. This change records the types in each step within a standard conversion sequence, so that we can check the specific comparison types to determine when one sequence is a proper subset of the other. Fixes this testcase (thanks, Anders!), which was distilled from PR6095 (also thanks to Anders). llvm-svn: 94660
* Pass access specifiers around in overload resolution.John McCall2010-01-261-1/+1
| | | | llvm-svn: 94485
* Give UnresolvedSet the ability to store access specifiers for each declaration.John McCall2010-01-201-2/+2
| | | | | | | Change LookupResult to use UnresolvedSet. Also extract UnresolvedSet into its own header and make it templated over an inline capacity. llvm-svn: 93959
* Make the AST explicitly represent the cast of the first operand of a Eli Friedman2010-01-161-3/+5
| | | | | | pointer-to-member operator. llvm-svn: 93592
* Preserve type source information in explicit cast expressions.John McCall2010-01-151-3/+5
| | | | | | Patch by Enea Zaffanella. llvm-svn: 93522
* Record some basic information about bad conversion sequences. Use thatJohn McCall2010-01-131-1/+2
| | | | | | | information to feed diagnostics instead of regenerating it. Much room for improvement here, but fixes some unfortunate problems reporting on method calls. llvm-svn: 93316
* So I was sitting around, trying vainly to think of something to commit, and thenJohn McCall2010-01-121-3/+3
| | | | | | | | I said to myself, self, why don't you go add a couple of parameters to a method and then fail to use them, and I thought that sounded like a pretty good idea, so I did it. llvm-svn: 93233
* Introduce a specific representation for the ambiguous implicit conversionJohn McCall2010-01-121-36/+33
| | | | | | | sequence. Lots of small relevant changes. Fixes some serious problems with ambiguous conversions; also possibly improves associated diagnostics. llvm-svn: 93214
* Change the printing of OR_Deleted overload results to print all the candidates,John McCall2010-01-081-3/+3
| | | | | | | | | | | | | | | not just the viable ones. This is reasonable because the most common use of deleted functions is to exclude some implicit conversion during calls; users therefore will want to figure out why some other options were excluded. Started sorting overload results. Right now it just sorts by location in the translation unit (after putting viable functions first), but we can do better than that. Changed bool OnlyViable parameter to PrintOverloadCandidates to an enum for better self-documentation. llvm-svn: 92990
* Add an "implicit" bit to CXXThisExpr, so that we can trackDouglas Gregor2010-01-071-1/+2
| | | | | | | implicitness without losing track of the (logical or actual) location where "this" would occur in the source. llvm-svn: 92958
* Improve the diagnostics used to report implicitly-generated class membersJohn McCall2010-01-061-1/+1
| | | | | | | | | as parts of overload sets. Also, refer to constructors as 'constructors' rather than functions. Adjust a lot of tests. llvm-svn: 92832
* Get rid of more unnecessary code.Eli Friedman2010-01-021-77/+6
| | | | llvm-svn: 92429
* Get rid of some unnecessary code.Eli Friedman2010-01-021-115/+0
| | | | llvm-svn: 92428
* When transforming CXXExprWithTemporaries and CXXBindTemporaryExprDouglas Gregor2009-12-241-0/+2
| | | | | | | | | expressions (e.g., for template instantiation), just transform the subexpressions and return those, since the temporary-related nodes will be implicitly regenerated. Fixes PR5867, but I said that before... llvm-svn: 92135
* There is no such thing as typeinfo for a cv-qualified type. AssertDouglas Gregor2009-12-231-2/+9
| | | | | | | | that this is true when mangling, then fix up the various places in Sema and/or CodeGen that need to remove qualifiers. Addresses a linking issue when building LLVM with Clang. llvm-svn: 92064
* Diagnose the use of incomplete types in C++ typeid expressionsDouglas Gregor2009-12-231-2/+18
| | | | llvm-svn: 92045
* Remove cv-qualifiers from the argument to typeidDouglas Gregor2009-12-231-11/+30
| | | | llvm-svn: 92041
* Allow the first parameter of operator new to be a cv-qualifiedDouglas Gregor2009-12-221-1/+2
| | | | | | | | size_t. Also, fix an issue with initialization of parameters in calls, where we weren't removing the cv-qualifiers on the parameter type itself. Fixes PR5823. llvm-svn: 91941
* 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
OpenPOWER on IntegriCloud