summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Whenever we're creating an expression that is typically an rvalueDouglas Gregor2010-07-131-2/+3
| | | | | | | | | | | | | | | | (e.g., a call, cast, etc.), immediately adjust the expression's type to strip cv-qualifiers off of all non-class types (in C++) or all types (in C). This effectively extends my previous fix for PR7463, which was restricted to calls, to other kinds of expressions within similar characteristics. I've audited every use of getNonReferenceType() in the code base, switching to the newly-renamed getNonLValueExprType() where necessary. Big thanks to Eli for pointing out just how incomplete my original fix for PR7463 actually was. We've been handling cv-qualifiers on rvalues wrong for a very, very long time. Fixes PR7463. llvm-svn: 108253
* Downgrade the "when type is in parentheses, array cannot have dynamicDouglas Gregor2010-07-131-15/+12
| | | | | | | | | | | | size" error for code like new (int [size]) to a warning, add a Fix-It to remove the parentheses, and make this diagnostic work properly when it occurs in a template instantiation. <rdar://problem/8018245>. llvm-svn: 108242
* When forming a function call or message send expression, be sure toDouglas Gregor2010-07-131-1/+1
| | | | | | | | | | | | | | | | | strip cv-qualifiers from the expression's type when the language calls for it: in C, that's all the time, while C++ only does it for non-class types. Centralized the computation of the call expression type in QualType::getCallResultType() and some helper functions in other nodes (FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant callers of getResultType() to getCallResultType(). Fixes PR7598 and PR7463, along with a bunch of getResultType() call sites that weren't stripping references off the result type (nothing stripped cv-qualifiers properly before this change). llvm-svn: 108234
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-24/+16
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-16/+24
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Rip out the C++0x-specific handling of destructor names. The specification ↵Sebastian Redl2010-07-071-45/+25
| | | | | | is still in flux and unclear, and our interim workaround was broken. Fixes PR7467. llvm-svn: 107835
* Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect itsDouglas Gregor2010-07-071-2/+2
| | | | | | newly-narrowed scope. No functionality change. llvm-svn: 107828
* Do not use CXXZeroValueInitExpr for class types. Instead, useDouglas Gregor2010-07-071-22/+14
| | | | | | | | | CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as appropriate. Fixes PR7556, and provides a slide codegen improvement when copy-initializing a POD class type from a value-initialized temporary. Previously, we weren't eliding the copy. llvm-svn: 107827
* Add a new routine Sema::LookupDestructor and make all destructor-lookup ↵Douglas Gregor2010-07-011-5/+4
| | | | | | calls use that routine llvm-svn: 107444
* Remove unnecessary ASTContext parameter fromDouglas Gregor2010-07-011-6/+5
| | | | | | CXXRecordDecl::getDestructor(); no functionality change. llvm-svn: 107394
* Implement C++ DR299, which allows an implicit conversion from a classDouglas Gregor2010-06-301-3/+20
| | | | | | | | | | | type to an integral or enumeration type in the size of an array new expression, e.g., new int[ConvertibleToInt(10)]; This is a GNU and C++0x extension. llvm-svn: 107229
* Factor the conversion from a switch condition to an integral orDouglas Gregor2010-06-291-0/+1
| | | | | | | | enumeration type out into a separate, reusable routine. The only functionality change here is that we recover a little more aggressively from ill-formed switch conditions. llvm-svn: 107222
* Allow a using directive to refer to the implicitly-defined namespaceDouglas Gregor2010-06-291-10/+1
| | | | | | | | "std", with a warning, to improve GCC compatibility. Fixes PR7517. As a drive-by, add typo correction for using directives. llvm-svn: 107172
* Suppress diagnosing access violations while looking up deallocation functionsChandler Carruth2010-06-281-0/+4
| | | | | | | | | much as we already do for allocation function lookup. Explicitly check access for the function we actually select in one case that was previously missing, but being caught behind the blanket diagnostics for all overload candidates. This fixs PR7436. llvm-svn: 106986
* Use TypeSourceInfo to help determine the SourceRange of a CXXNewExpr. This ↵Ted Kremenek2010-06-251-3/+6
| | | | | | | | | fixes several cases where we generated an invalid SourceRange for this expression. Thanks to John McCall for helping me figure this out. llvm-svn: 106903
* String literals enclosed in parentheses are still stringDouglas Gregor2010-06-221-1/+1
| | | | | | literals. Fixes PR7488. llvm-svn: 106607
* Type Type::isRealFloatingType() that vectors are not floating-pointDouglas Gregor2010-06-221-1/+1
| | | | | | | | | types, updating callers of both isFloatingType() and isRealFloatingType() accordingly. Caught at least one issue where we allowed one to declare a vector of vectors (!), along with cleaning up the standard-conversion logic for C++. llvm-svn: 106595
* fix some more gcc3.4 constness warningsGabor Greif2010-06-171-1/+2
| | | | llvm-svn: 106216
* Make sure result type of objc++ message expression isFariborz Jahanian2010-06-161-0/+11
| | | | | | | complete before attempting to bind it to a temporary. Fixes PR7386. llvm-svn: 106130
* Introduce Type::isIntegralOrEnumerationType(), to cover those placesDouglas Gregor2010-06-161-1/+1
| | | | | | | | | | in C++ that involve both integral and enumeration types. Convert all of the callers to Type::isIntegralType() that are meant to work with both integral and enumeration types over to Type::isIntegralOrEnumerationType(), to prepare to eliminate enumeration types as integral types. llvm-svn: 106071
* Allow pseudo-destructors to be called on qualified pointers. Patch byJohn McCall2010-06-111-1/+1
| | | | | | Troy Straszheim! llvm-svn: 105823
* Alter the interface of GetTypeForDeclarator to return a TypeSourceInfo*.John McCall2010-06-041-2/+2
| | | | | | This is never null, but the associated type might be. llvm-svn: 105503
* Make sure to check the accessibility of and mark the destructor for theEli Friedman2010-06-031-3/+20
| | | | | | operand of a throw expression. Fixes PR7281. llvm-svn: 105408
* typeid() produces type information for the cv-unqualified version ofDouglas Gregor2010-06-021-4/+9
| | | | | | the type. Thanks to Anders for the bug report! llvm-svn: 105314
* Downgrade deletion of a void* from an error (which is should be) to anDouglas Gregor2010-05-241-1/+7
| | | | | | | extension warning (which other compilers seem to use). Works around a known bug in Xalan. llvm-svn: 104509
* Renamed misleading getSourceRange -> getLocalSourceRange and ↵Abramo Bagnara2010-05-201-4/+4
| | | | | | getFullSourceRange -> getSourceRange for TypeLoc. llvm-svn: 104220
* Support implicitly closing on 'this' in a block. Fixed PR7165.John McCall2010-05-201-4/+2
| | | | | | (the codegen works here, too, but that's annoying to test without execution) llvm-svn: 104202
* When a conditional operator is an rvalue of class type, we need toDouglas Gregor2010-05-191-2/+25
| | | | | | | | | | create a temporary copy of both the "true" and "false" results. Fixes the Boost.Interprocess failures. Daniel did all the hard work of tracking down the issue, I get to type up the trivial fix for this horrible miscompile. llvm-svn: 104184
* Added basic source locations to Elaborated and DependentName types.Abramo Bagnara2010-05-191-1/+2
| | | | llvm-svn: 104169
* Implement C++ support for vector and extended vector types. ThisDouglas Gregor2010-05-181-6/+22
| | | | | | | | | | involves extending implicit conversion sequences to model vector conversions and vector splats, along with teaching the C++ conditional operator-checking code about vector types. Fixes <rdar://problem/7983501>. llvm-svn: 104081
* Correctly diagnose array 'new' with initialization arguments when the new ↵Anders Carlsson2010-05-161-1/+1
| | | | | | type is a typedef to an array type. llvm-svn: 103909
* When the type-id or new-type-id of a C++ "new" expression is a typedefDouglas Gregor2010-05-161-3/+12
| | | | | | | of an array type, use the outermost array bound as the number of elements to allocate. Fixes PR7147. llvm-svn: 103908
* Recognize when the named return value optimization applies in aDouglas Gregor2010-05-151-1/+3
| | | | | | | | | | "return" statement and mark the corresponding CXXConstructExpr as elidable. Teach CodeGen that eliding a temporary is different from eliding an object construction. This is just a baby step toward NRVO. llvm-svn: 103849
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-5/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "used" (e.g., we will refer to the vtable in the generated code) and when they are defined (i.e., because we've seen the key function definition). Previously, we were effectively tracking "potential definitions" rather than uses, so we were a bit too eager about emitting vtables for classes without key functions. The new scheme: - For every use of a vtable, Sema calls MarkVTableUsed() to indicate the use. For example, this occurs when calling a virtual member function of the class, defining a constructor of that class type, dynamic_cast'ing from that type to a derived class, casting to/through a virtual base class, etc. - For every definition of a vtable, Sema calls MarkVTableUsed() to indicate the definition. This happens at the end of the translation unit for classes whose key function has been defined (so we can delay computation of the key function; see PR6564), and will also occur with explicit template instantiation definitions. - For every vtable defined/used, we mark all of the virtual member functions of that vtable as defined/used, unless we know that the key function is in another translation unit. This instantiates virtual member functions when needed. - At the end of the translation unit, Sema tells CodeGen (via the ASTConsumer) which vtables must be defined (CodeGen will define them) and which may be used (for which CodeGen will define the vtables lazily). From a language perspective, both the old and the new schemes are permissible: we're allowed to instantiate virtual member functions whenever we want per the standard. However, all other C++ compilers were more lazy than we were, and our eagerness was both a performance issue (we instantiated too much) and a portability problem (we broke Boost test cases, which now pass). Notes: (1) There's a ton of churn in the tests, because the order in which vtables get emitted to IR has changed. I've tried to isolate some of the larger tests from these issues. (2) Some diagnostics related to implicitly-instantiated/implicitly-defined virtual member functions have moved to the point of first use/definition. It's better this way. (3) I could use a review of the places where we MarkVTableUsed, to see if I missed any place where the language effectively requires a vtable. Fixes PR7114 and PR6564. llvm-svn: 103718
* Merged Elaborated and QualifiedName types.Abramo Bagnara2010-05-111-1/+1
| | | | llvm-svn: 103517
* Speculatively revert r103497, "Do not mark the virtual members of anDaniel Dunbar2010-05-111-12/+2
| | | | | | implicitly-instantiated class as ...", which seems to have broken bootstrap. llvm-svn: 103515
* Do not mark the virtual members of an implicitly-instantiated class asDouglas Gregor2010-05-111-2/+12
| | | | | | | | referenced unless we see one of them defined (or the key function defined, if it as one) or if we need the vtable for something. Fixes PR7114. llvm-svn: 103497
* Fixed DISABLE_SMART_POINTERS breakageDouglas Gregor2010-05-061-4/+3
| | | | llvm-svn: 103198
* Rework our handling of temporary objects within the conditions ofDouglas Gregor2010-05-061-4/+15
| | | | | | | | | | | | | | | | | | | if/switch/while/do/for statements. Previously, we would end up either: (1) Forgetting to destroy temporaries created in the condition (!), (2) Destroying the temporaries created in the condition *before* converting the condition to a boolean value (or, in the case of a switch statement, to an integral or enumeral value), or (3) In a for statement, destroying the condition's temporaries at the end of the increment expression (!). We now destroy temporaries in conditions at the right times. This required some tweaking of the Parse/Sema interaction, since the parser was building full expressions too early in many places. Fixes PR7067. llvm-svn: 103187
* Rearchitect -Wconversion and -Wsign-compare. Instead of computing themJohn McCall2010-05-061-2/+3
| | | | | | | | | | | | | | "bottom-up" when implicit casts and comparisons are inserted, compute them "top-down" when the full expression is finished. Makes it easier to coordinate warnings and thus implement -Wconversion for signedness conversions without double-warning with -Wsign-compare. Also makes it possible to realize that a signedness conversion is okay because the context is performing the inverse conversion. Also simplifies some logic that was trying to calculate the ultimate comparison/result type and getting it wrong. Also fixes a problem with the C++ explicit casts which are often "implemented" in the AST with a series of implicit cast expressions. llvm-svn: 103174
* The array form of 'new' can never have initializers.Anders Carlsson2010-05-031-0/+9
| | | | llvm-svn: 102917
* Simplify.Anders Carlsson2010-05-031-4/+4
| | | | llvm-svn: 102896
* When determining a standard conversion sequence involves resolving theDouglas Gregor2010-04-291-19/+15
| | | | | | | | | | | | | | | | | | | | | address of an overloaded function (or function template), perform that resolution prior to determining the implicit conversion sequence. This resolution is not part of the implicit conversion sequence itself. Previously, we would always consider this resolution to be a function pointer decay, which was a lie: there might be an explicit & in the expression, in which case decay should not occur. This caused the CodeGen assertion in PR6973 (where we created a pointer to a pointer to a function when we should have had a pointer to a function), but it's likely that there are corner cases of overload resolution where this would have failed. Cleaned up the code involved in determining the type that will produced afer resolving the overloaded function reference, and added an assertion to make sure the result is correct. Fixes PR6973. llvm-svn: 102650
* Improve source-location information in a C++ typeid (type) expressionDouglas Gregor2010-04-261-67/+85
| | | | | | | | | | | | | | | | | by using TypeSourceInfo, cleaning up the representation somewhat. Teach getTypeOperand() to strip references and cv-qualifiers, providing the semantic view of the type without requiring any extra storage (the unmodified type remains within the TypeSourceInfo). This fixes a bug found by Boost's call_traits test. Finally, clean up semantic analysis, by splitting the ActOnCXXTypeid routine into ActOnCXXTypeId (the parser action) and two BuildCXXTypeId functions, which perform the semantic analysis for typeid(type) and typeid(expression), respectively. We now perform less work at template instantiation time (we don't look for std::type_info again) and can give better diagnostics. llvm-svn: 102393
* Improve the diagnostic when we find something we did not expect in aDouglas Gregor2010-04-251-2/+1
| | | | | | | member expression (p-> or x.), by showing the type we looked into and what we did actually find. llvm-svn: 102315
* Add base paths for CK_BaseToDerived and CK_BaseToDerivedMemberPointer.Anders Carlsson2010-04-241-2/+4
| | | | llvm-svn: 102261
* Actually produce base paths for CastExprs of kind CK_DerivedToBase.Anders Carlsson2010-04-241-6/+11
| | | | llvm-svn: 102259
* Add BasePath arguments to all cast expr constructors.Anders Carlsson2010-04-241-1/+4
| | | | llvm-svn: 102258
* Pass the base specifiers through to CheckDerivedToBaseConversion. No ↵Anders Carlsson2010-04-241-1/+1
| | | | | | functionality change yet. llvm-svn: 102250
* CastExpr should not hold a pointer to the base path. More cleanup.Anders Carlsson2010-04-241-6/+3
| | | | llvm-svn: 102249
OpenPOWER on IntegriCloud