summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Keep track of when DependentNameTypes have no associated keywordDouglas Gregor2010-04-241-1/+1
| | | | | | | (e.g., no typename, enum, class, etc.), e.g., because the context is one that is known to refer to a type. Patch from Enea Zaffanella! llvm-svn: 102243
* Add an InheritancePath parameter to the ImplicitCastExpr constructor.Anders Carlsson2010-04-231-3/+5
| | | | llvm-svn: 102218
* Require a complete type for the lhs of member pointer dereference operations ↵Sebastian Redl2010-04-231-0/+5
| | | | | | if the type isn't exactly the same as the container class. Fixes PR6783. llvm-svn: 102186
* 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
* 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
* Keep track of the actual storage specifier written on a variable orDouglas Gregor2010-04-191-1/+3
| | | | | | | | 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
* Switch Sema::FindCompositePointerType() over to InitializationSequence. Douglas Gregor2010-04-161-39/+69
| | | | | | | This is the last of the uses of TryImplicitConversion outside of overload resolution and InitializationSequence itself. llvm-svn: 101569
* Move Sema::PerformImplicitConversion over to where ↵Douglas Gregor2010-04-161-24/+0
| | | | | | Sema::TryImplicitConversion is, for my own sanity. No functionality change llvm-svn: 101554
* Make Sema::BuildCXXCastArgument static, since it now only has one caller. No ↵Douglas Gregor2010-04-161-38/+40
| | | | | | functionality change llvm-svn: 101550
* Collapse the three separate initialization paths inDouglas Gregor2010-04-161-12/+1
| | | | | | | | | | | | | | | | | | TryStaticImplicitCast (for references, class types, and everything else, respectively) into a single invocation of InitializationSequence. One of the paths (for class types) was the only client of Sema::TryInitializationByConstructor, which I have eliminated. This also simplified the interface for much of the cast-checking logic, eliminating yet more code. I've kept the representation of C++ functional casts with <> 1 arguments the same, despite the fact that I hate it. That fix will come soon. To satisfy my paranoia, I've bootstrapped + tested Clang with these changes. llvm-svn: 101549
* Kill ForceRValue once and for allDouglas Gregor2010-04-161-5/+0
| | | | llvm-svn: 101502
* Eliminate the Elidable parameter to PerformImplicitConversion; weDouglas Gregor2010-04-161-23/+8
| | | | | | don't need it. llvm-svn: 101481
* Diagnose attempts to throw an abstract class type.Douglas Gregor2010-04-151-0/+5
| | | | llvm-svn: 101381
* When a member pointer is dereferenced, the class it points into must be ↵Sebastian Redl2010-04-101-0/+3
| | | | | | complete. Enforce this. llvm-svn: 100925
* Make CXXScopeSpec invalid when incomplete, and propagate that into anyJeffrey Yasskin2010-04-081-2/+2
| | | | | | | Declarator that depends on it. This fixes several redundant errors and bad recoveries. llvm-svn: 100779
* Check access for the implicit calls to destructors that occur when weJohn McCall2010-04-071-1/+5
| | | | | | | | have a temporary object in C++. Also fix a tag mismatch that Doug noticed. llvm-svn: 100593
* Minor cleanup with the ternary operatorDouglas Gregor2010-04-011-2/+2
| | | | llvm-svn: 100144
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-4/+4
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-4/+4
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-4/+4
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Regularize support for naming conversion functions in using decls.John McCall2010-03-311-11/+14
| | | | llvm-svn: 99979
* Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall2010-03-301-4/+9
| | | | | | | | | | | | | the underlying/instantiated decl) through a lot of API, including "intermediate" MemberExprs required for (e.g.) template instantiation. This is necessary because of the access semantics of member accesses to using declarations: only the base class *containing the using decl* need be accessible from the naming class. This allows us to complete an access-controlled selfhost, if there are no recent regressions. llvm-svn: 99936
* the big refactoring bits of PR3782.Rafael Espindola2010-03-301-2/+4
| | | | | | | | This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. llvm-svn: 99920
* Remove unused static functionDouglas Gregor2010-03-261-17/+0
| | | | llvm-svn: 99666
* When trying to determine whether one operand of a conditionalDouglas Gregor2010-03-261-7/+9
| | | | | | | | | expression can be converted to the type of another, only apply the lvalue-to-rvalue conversion to the type of the expression we're converting, *not* the array-to-pointer or function-to-pointer conversions. Fixes PR6595. llvm-svn: 99652
* Eliminate the non-InitializedEntity PerformCopyInitialization() andDouglas Gregor2010-03-261-3/+8
| | | | | | | | re-route its only caller to the newer PerformCopyInitialization(). We're down to one remaining caller of Sema::CheckReferenceInit. llvm-svn: 99650
* Switch semantic analysis of the conditional operator from usingDouglas Gregor2010-03-261-88/+71
| | | | | | CheckReferenceInit to using the new initialization sequence code. llvm-svn: 99647
OpenPOWER on IntegriCloud