summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Kill off two more uses of Sema::CheckReferenceInit in favor of the newDouglas Gregor2010-03-251-20/+18
| | | | | | | | initialization code. Exposed a bug where we were not marking an implicit conversion as an lvalue when we were forming a call to a conversion function whose return type is a reference. llvm-svn: 99459
* Remember the "found declaration" for an overload candidate, which is theJohn McCall2010-03-191-12/+13
| | | | | | | | | | | | | | | | entity (if applicable) which was actually looked up. If a candidate was found via a using declaration, this is the UsingShadowDecl; otherwise, if the candidate is template specialization, this is the template; otherwise, this is the function. The point of this exercise is that "found declarations" are the entities we do access control for, not their underlying declarations. Broadly speaking, this patch fixes access control for using declarations. There is a *lot* of redundant code calling into the overload-resolution APIs; we really ought to clean that up. llvm-svn: 98945
* from code inspection, we were treating placement news with one argument asJohn McCall2010-03-181-7/+16
| | | | | | | | non-placement news when selecting the corresponding operator delete; this is fixed. Access and ambiguity control for calls to operator new and delete. Also AFAICT llvm-svn: 98818
* Warn about comparing an unsigned expression with 0 in tautological ways.John McCall2010-03-111-1/+1
| | | | | | Patch by mikem! llvm-svn: 98279
* Create a new InjectedClassNameType to represent bare-word references to the John McCall2010-03-101-18/+2
| | | | | | | | | | | | | injected class name of a class template or class template partial specialization. This is a non-canonical type; the canonical type is still a template specialization type. This becomes the TypeForDecl of the pattern declaration, which cleans up some amount of code (and complicates some other parts, but whatever). Fixes PR6326 and probably a few others, primarily by re-establishing a few invariants about TypeLoc sizes. llvm-svn: 98134
* Reinstate r97674 with a fix for the assertion that was firing in <list>Douglas Gregor2010-03-031-1/+1
| | | | llvm-svn: 97686
* Revert r97674; it's causing failuresDouglas Gregor2010-03-031-1/+1
| | | | llvm-svn: 97677
* Implement disambiguation of base class members via aDouglas Gregor2010-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | nested-name-specifier. For example, this allows member access in diamond-shaped hierarchies like: struct Base { void Foo(); int Member; }; struct D1 : public Base {}; struct D2 : public Base {}; struct Derived : public D1, public D2 { } void Test(Derived d) { d.Member = 17; // error: ambiguous cast from Derived to Base d.D1::Member = 17; // error: okay, modify D1's Base's Member } Fixes PR5820 and <rdar://problem/7535045>. Also, eliminate some redundancy between Sema::PerformObjectMemberConversion() and Sema::PerformObjectArgumentInitialization() -- the latter now calls the former. llvm-svn: 97674
* During codegen assert that any copy assignment, destructor or constructor thatRafael Espindola2010-03-021-0/+12
| | | | | | | | we need to synthesize has been marked as used by Sema. Change Sema to avoid these asserts. llvm-svn: 97589
* Warn about the deprecated string literal -> char* conversion. Fixes PR6428.Douglas Gregor2010-02-281-0/+5
| | | | llvm-svn: 97404
* Implement semantic analysis for C++ [expr.new]p18-20, which describeDouglas Gregor2010-02-261-2/+133
| | | | | | | | | | how we find the operator delete that matches withe operator new we found in a C++ new-expression. This will also need CodeGen support. On a happy note, we're now a "nans" away from building tramp3d-v4. llvm-svn: 97209
* When computing the composite pointer type for relational comparisons,Douglas Gregor2010-02-251-3/+48
| | | | | | | | | | | | | | | | | | | | | | | | equality comparisons, and conditional operators, produce a composite pointer type with the appropriate additional "const" qualifiers if the pointer types would otherwise be incompatible. This is a small extension (also present in GCC and EDG in a slightly different form) that permits code like: void** i; void const** j; i == j; with the following extwarn: t.cpp:5:5: warning: comparison of distinct pointer types ('void **' and 'void const **') uses non-standard composite pointer type 'void const *const *' [-pedantic] i == j; ~ ^ ~ Fixes PR6346, and I'll be filing a core issue about this with the C++ committee. llvm-svn: 97177
* Restore the invariant that a nested-name-specifier can only containDouglas Gregor2010-02-251-1/+1
| | | | | | | | | class types, dependent types, and namespaces. I had previously weakened this invariant while working on parsing pseudo-destructor expressions, but recent work in that area has made these changes unnecessary. llvm-svn: 97112
* Use CXXPseudoDestructorExpr as the stored representation for dependentDouglas Gregor2010-02-251-170/+54
| | | | | | | | | | | | | | | | expressions that look like pseudo-destructors, e.g., p->T::~T() where p has dependent type. At template instantiate time, we determine whether we actually have a pseudo-destructor or a member access, and funnel down to the appropriate routine in Sema. Fixes PR6380. llvm-svn: 97092
* Catch more uses of uninitialized implicit conversion sequences.John McCall2010-02-251-14/+21
| | | | | | | When diagnosing bad conversions, skip the conversion for ignored object arguments. Fixes PR 6398. llvm-svn: 97090
* Keep track of the location of the '~' in a pseudo-destructor expression.Douglas Gregor2010-02-241-2/+4
| | | | llvm-svn: 97080
* Retain complete source information for the type after the '~' in aDouglas Gregor2010-02-241-10/+9
| | | | | | | | | | | CXXPseudoDestructorExpr. Update template instantiation for pseudo-destructor expressions to use this source information and to make use of Sema::BuildPseudoDestructorExpr when the base expression is dependent or refers to a scalar type. llvm-svn: 97079
* Make sure that we have type source information for the scope type of aDouglas Gregor2010-02-241-1/+6
| | | | | | pseudo-destructor expression. Attempt #1 at fixing the MSVC buildbot. llvm-svn: 97076
* Split ActOnPseudoDestructorExpr into the part that interprets theDouglas Gregor2010-02-241-86/+149
| | | | | | | | parser's data structures and the part that performs semantic analysis and AST building, in preparation for improved template instantiation of pseudo-destructor expressions. llvm-svn: 97070
* Retain source information for the "type-name ::" in aDouglas Gregor2010-02-241-3/+6
| | | | | | | | pseudo-destructor expression such as p->T::~T() llvm-svn: 97060
* ActOnPseudoDestructorExpr now performs all semantic analysis forDouglas Gregor2010-02-241-38/+211
| | | | | | | | | | | | | | | | pseudo-destructor expressions, and builds the CXXPseudoDestructorExpr node directly. Currently, this only affects pseudo-destructor expressions when they are parsed, but not after template instantiation. That's coming next... Improve parsing of pseudo-destructor-names. When parsing the nested-name-specifier and we hit the sequence of tokens X :: ~, query the actual module to determine whether X is a type-name (in which case the X :: is part of the pseudo-destructor-name but not the nested-name-specifier) or not (in which case the X :: is part of the nested-name-specifier). llvm-svn: 97058
* 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
OpenPOWER on IntegriCloud