summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "Make CXXNewExpr contain only a single initialier, and not hold the ↵Sebastian Redl2012-02-161-38/+31
| | | | | | | | | | used constructor itself." It leads to a compiler crash in the Bullet benchmark. This reverts commit r12014. llvm-svn: 150684
* Make CXXNewExpr contain only a single initialier, and not hold the used ↵Sebastian Redl2012-02-161-31/+38
| | | | | | | | | | constructor itself. Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities. This breaks the static analysis of new expressions. I've filed PR12014 to track this. llvm-svn: 150682
* Implement AST (de-)serialization for lambda expressions.Douglas Gregor2012-02-141-0/+17
| | | | llvm-svn: 150491
* Introduce support for template instantiation of lambdaDouglas Gregor2012-02-131-2/+5
| | | | | | | | | | | | | | | | | | expressions. This is mostly a simple refact, splitting the main "start a lambda expression" function into smaller chunks that are driven either from the parser (Sema::ActOnLambdaExpr) or during AST transformation (TreeTransform::TransformLambdaExpr). A few minor interesting points: - Added new entry points for TreeTransform, so that we can explicitly establish the link between the lambda closure type in the template and the lambda closure type in the instantiation. - Added a bit into LambdaExpr specifying whether it had an explicit result type or not. We should have had this anyway. This code is 'lightly' tested. llvm-svn: 150417
* Sink variable into assertMatt Beaumont-Gay2012-02-131-2/+2
| | | | llvm-svn: 150407
* Split the storage of lambda information between the LambdaExpr and theDouglas Gregor2012-02-131-41/+52
| | | | | | | | | | | | CXXRecordDecl in a way that actually makes some sense: - LambdaExpr contains all of the information for initializing the lambda object, including the capture initializers and associated array index variables. - CXXRecordDecl's LambdaDefinitionData contains the captures, which are needed to understand the captured variable references in the body of the lambda. llvm-svn: 150401
* Keep track of the set of array index variables we use when weDouglas Gregor2012-02-131-1/+20
| | | | | | | synthesize a by-copy captured array in a lambda. This information will be needed by IR generation. llvm-svn: 150396
* Don't allocate unused storage for captures/capture initializers in lambda ↵Douglas Gregor2012-02-131-6/+3
| | | | | | expressions llvm-svn: 150394
* Move the storage of lambda captures and capture initializers fromDouglas Gregor2012-02-131-19/+56
| | | | | | | | LambdaExpr over to the CXXRecordDecl. This allows us to eliminate the back-link from the closure type to the LambdaExpr, which will simplify and lazify AST deserialization. llvm-svn: 150393
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-111-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of having a special-purpose function. - ActOnCXXDirectInitializer, which was mostly duplication of AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days ago), is dropped completely. - MultiInitializer, which was an ugly hack I added, is dropped again. - We now have the infrastructure in place to distinguish between int x = {1}; int x({1}); int x{1}; -- VarDecl now has getInitStyle(), which indicates which of the above was used. -- CXXConstructExpr now has a flag to indicate that it represents list- initialization, although this is not yet used. - InstantiateInitializer was renamed to SubstInitializer and simplified. - ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which always produces a ParenListExpr. Placed that so far failed to convert that back to a ParenExpr containing comma operators have been fixed. I'm pretty sure I could have made a crashing test case before this. The end result is a (I hope) considerably cleaner design of initializers. More importantly, the fact that I can now distinguish between the various initialization kinds means that I can get the tricky generalized initializer test cases Johannes Schaub supplied to work. (This is not yet done.) This commit passed self-host, with the resulting compiler passing the tests. I hope it doesn't break more complicated code. It's a pretty big change, but one that I feel is necessary. llvm-svn: 150318
* Introduce basic ASTs for lambda expressions. This covers:Douglas Gregor2012-02-071-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | - Capturing variables by-reference and by-copy within a lambda - The representation of lambda captures - The creation of the non-static data members in the lambda class that store the captured variables - The initialization of the non-static data members from the captured variables - Pretty-printing lambda expressions There are a number of FIXMEs, both explicit and implied, including: - Creating a field for a capture of 'this' - Improved diagnostics for initialization failures when capturing variables by copy - Dealing with temporaries created during said initialization - Template instantiation - AST (de-)serialization - Binding and returning the lambda expression; turning it into a proper temporary - Lots and lots of semantic constraints - Parameter pack captures llvm-svn: 149977
* Fixed instantiation of DependentScopeDeclRefExpr.Abramo Bagnara2012-02-061-5/+7
| | | | llvm-svn: 149868
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-52/+77
| | | | llvm-svn: 149127
* Unweaken vtables as per ↵David Blaikie2011-12-201-1/+1
| | | | | | http://llvm.org/docs/CodingStandards.html#ll_virtual_anch llvm-svn: 146959
* In Sema::MaybeBindToTemporary, create a CXXBindTemporaryExpr for anPeter Collingbourne2011-11-271-2/+3
| | | | | | array of objects with non-trivial destructors. PR11365. llvm-svn: 145203
* There's no good reason to track temporaries in ExprWithCleanups,John McCall2011-11-101-19/+21
| | | | | | | but it is sometimes useful to track blocks. Do so. Also optimize the storage of these expressions. llvm-svn: 144263
* Added a flag to identify resolved overloaded function references.Abramo Bagnara2011-10-051-4/+12
| | | | llvm-svn: 141171
* Re-arrange and bitfieldify data members of CXXConstructExpr to save aDouglas Gregor2011-09-261-3/+3
| | | | | | little storage. llvm-svn: 140529
* Rename ExplicitTemplateArgumentList -> ASTTemplateArgumentListInfo, no ↵Argyrios Kyrtzidis2011-09-221-9/+9
| | | | | | functionality change. llvm-svn: 140330
* Teach CXXUnresolvedConstructExpr when it should be anDouglas Gregor2011-07-081-1/+4
| | | | | | | lvalue/xvalue/rvalue, rather than just (incorrectly) assuming it's an lvalue. Fixes PR10285 / <rdar://problem/9743926>. llvm-svn: 134700
* Introduce the notion of instantiation dependence into Clang's AST. ADouglas Gregor2011-07-011-8/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | type/expression/template argument/etc. is instantiation-dependent if it somehow involves a template parameter, even if it doesn't meet the requirements for the more common kinds of dependence (dependent type, type-dependent expression, value-dependent expression). When we see an instantiation-dependent type, we know we always need to perform substitution into that instantiation-dependent type. This keeps us from short-circuiting evaluation in places where we shouldn't, and lets us properly implement C++0x [temp.type]p2. In theory, this would also allow us to properly mangle instantiation-dependent-but-not-dependent decltype types per the Itanium C++ ABI, but we aren't quite there because we still mangle based on the canonical type in cases like, e.g., template<unsigned> struct A { }; template<typename T> void f(A<sizeof(sizeof(decltype(T() + T())))>) { } template void f<int>(A<sizeof(sizeof(int))>); and therefore get the wrong answer. llvm-svn: 134225
* Make yet another placeholder type, this one marking that an expression is a ↵John McCall2011-04-261-0/+27
| | | | | | | | | | | bound member function, i.e. something of the form 'x.f' where 'f' is a non-static member function. Diagnose this in the general case. Some of the new diagnostics are probably worse than the old ones, but we now get this right much more universally, and there's certainly room for improvement in the diagnostics. llvm-svn: 130239
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-1/+1
| | | | | | draft standard (N3291). llvm-svn: 129541
* Add CXXDynamicCastExpr::isAlwaysNull() which will be replacing the cast kind ↵Anders Carlsson2011-04-111-0/+30
| | | | | | I added. llvm-svn: 129263
* Apply a bug-fix patch from Marcin Kowalczyk to the source locations forChandler Carruth2011-04-021-1/+3
| | | | | | | | | | | a couple of operator overloads which form interesting expressions in the AST. I added test cases for both bugs with the c-index-test's token annotation feature. Also, thanks to John McCall for confirming that this is the correct solution. llvm-svn: 128768
* Begin reworking static analyzer support for C++ method calls. The current ↵Ted Kremenek2011-03-301-2/+13
| | | | | | | | | | | logic was divorced from how we process ordinary function calls, had a tremendous about of redundancy, and relied strictly on inlining behavior (which was incomplete) to provide semantics instead of falling back to the conservative analysis we use for C functions. This is a significant step into making C++ analyzer support more useful. llvm-svn: 128557
* Instead of storing an ASTContext* in FunctionProtoTypes with computed ↵Sebastian Redl2011-03-131-2/+2
| | | | | | noexcept specifiers, unique FunctionProtoTypes with a ContextualFoldingSet, as suggested by John McCall. llvm-svn: 127568
* Propagate the new exception information to FunctionProtoType.Sebastian Redl2011-03-121-1/+1
| | | | | | | | Change the interface to expose the new information and deal with the enormous fallout. Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications. Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support. llvm-svn: 127537
* The conditional needs to be pushed before the branch. Make the test lessJohn McCall2011-03-071-0/+4
| | | | | | trivial to check this. Adjust for style. llvm-svn: 127151
* Fix the source range for a member access expression that includes aDouglas Gregor2011-03-021-37/+2
| | | | | | | nested-name-specifier and improve the detection of implicit 'this' bases. Fixes <rdar://problem/8750392>. llvm-svn: 126880
* Push nested-name-specifier source location information intoDouglas Gregor2011-02-281-15/+60
| | | | | | | | | | | | | UnresolvedLookupExpr and UnresolvedMemberExpr. Also, improve the computation that checks whether the base of a member expression (either unresolved or dependent-scoped) is implicit. The previous check didn't cover all of the cases we use in our representation, which threw off source-location information for these expressions (which, in turn, caused some breakage in libclang's token annotation). llvm-svn: 126681
* Push nested-name-specifier source location information intoDouglas Gregor2011-02-281-17/+17
| | | | | | | | CXXDependentScopeMemberExpr, and clean up instantiation of nested-name-specifiers with dependent template specialization types in the process. llvm-svn: 126663
* Push nested-name-specifier source location information intoDouglas Gregor2011-02-251-9/+8
| | | | | | | DependentScopeDeclRefExpr. Plus, give NestedNameSpecifierLoc == and != operators, since we're going to need 'em elsewhere. llvm-svn: 126508
* Push nested-name-specifier source-location information intoDouglas Gregor2011-02-251-7/+8
| | | | | | | | pseudo-destructor expressions. Also, clean up some template-instantiation and type-checking issues with pseudo-destructors. llvm-svn: 126498
* Pseudo-revirtualize CallExpr::getSourceRange by making it follow theJohn McCall2011-02-211-7/+3
| | | | | | | | logic from CXXMemberCallExpr and by making it check for CXXOperatorCallExpr in order to defer. This is not really an awesome solution, but I don't have a better idea. llvm-svn: 126114
* Remove vtables from the Stmt hierarchy; this was pretty easy asJohn McCall2011-02-091-202/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | there were only three virtual methods of any significance. The primary way to grab child iterators now is with Stmt::child_range children(); Stmt::const_child_range children() const; where a child_range is just a std::pair of iterators suitable for being llvm::tie'd to some locals. I've left the old child_begin() and child_end() accessors in place, but it's probably a substantial penalty to grab the iterators individually now, since the switch-based dispatch is kindof inherently slower than vtable dispatch. Grabbing them together is probably a slight win over the status quo, although of course we could've achieved that with vtables, too. I also reclassified SwitchCase (correctly) as an abstract Stmt class, which (as the first such class that wasn't an Expr subclass) required some fiddling in a few places. There are somewhat gross metaprogramming hooks in place to ensure that new statements/expressions continue to implement getSourceRange() and children(). I had to work around a recent clang bug; dgregor actually fixed it already, but I didn't want to introduce a selfhosting dependency on ToT. llvm-svn: 125183
* Implement proper (de-)serialization for explicit template argumentDouglas Gregor2011-02-041-10/+17
| | | | | | | lists with zero template arguments. Fixes some seriously scary crashers in C++ PCH. llvm-svn: 124862
* Do a proper recursive lookup when deciding whether a class's usualJohn McCall2011-01-271-3/+5
| | | | | | | | | deallocation function has a two-argument form. Store the result of this check in new[] and delete[] nodes. Fixes rdar://problem/8913519 llvm-svn: 124373
* Change QualType::getTypePtr() to return a const pointer, then change aJohn McCall2011-01-191-1/+1
| | | | | | thousand other things which were (generally inadvertantly) relying on that. llvm-svn: 123814
* Introduce a new expression kind, SubstNonTypeTemplateParmPackExpr,Douglas Gregor2011-01-151-0/+28
| | | | | | | | | that captures the substitution of a non-type template argument pack for a non-type template parameter pack within a pack expansion that cannot be fully expanded. This follows the approach taken by SubstTemplateTypeParmPackType. llvm-svn: 123506
* Add the location of the right parenthesis of a C++ named castDouglas Gregor2011-01-121-8/+15
| | | | | | | (static_cast, dynamic_cast, reinterpret_cast, or const_cast) to improve source-location information. Fixes PR8960. llvm-svn: 123336
* Implement the sizeof...(pack) expression to compute the length of aDouglas Gregor2011-01-041-0/+12
| | | | | | | | | parameter pack. Note that we're missing proper libclang support for the new SizeOfPackExpr expression node. llvm-svn: 122813
* Implement support for pack expansions whose pattern is a non-typeDouglas Gregor2011-01-031-0/+12
| | | | | | | | | | | | | | | | | template argument (described by an expression, of course). For example: template<int...> struct int_tuple { }; template<int ...Values> struct square { typedef int_tuple<(Values*Values)...> type; }; It also lays the foundation for pack expansions in an initializer-list. llvm-svn: 122751
* Variadic templates: extend the Expr class with a bit that specifiesDouglas Gregor2010-12-151-85/+182
| | | | | | | | | | | | | | | | | | whether the expression contains an unexpanded parameter pack, in the same vein as the changes to the Type hierarchy. Compute this bit within all of the Expr subclasses. This change required a bunch of reshuffling of dependency calculations, mainly to consolidate them inside the constructors and to fuse multiple loops that iterate over arguments to determine type dependence, value dependence, and (now) containment of unexpanded parameter packs. Again, testing is painfully sparse, because all of the diagnostics will change and it is more important to test the to-be-written visitor that collects unexpanded parameter packs. llvm-svn: 121831
* Restore r121752 without modification.John McCall2010-12-141-0/+19
| | | | llvm-svn: 121763
* Pull out r121752 in case it's causing the selfhost breakage.John McCall2010-12-141-19/+0
| | | | llvm-svn: 121759
* Factor out most of the extra state in a FunctionProtoType into a separateJohn McCall2010-12-141-0/+19
| | | | | | | class to be passed around. The line between argument and return types and everything else is kindof vague, but I think it's justifiable. llvm-svn: 121752
* Type traits intrinsic implementation: __is_base_of(T, U)Francois Pichet2010-12-071-0/+8
| | | | | | New AST node introduced: BinaryTypeTraitExpr; to be reused for more intrinsics. llvm-svn: 121074
* Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall2010-12-061-14/+14
| | | | | | reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
* Add an assertion, fix a whole bunch of bugs, comment the assertionJohn McCall2010-11-181-1/+1
| | | | | | out because there are still bugs left. llvm-svn: 119722
OpenPOWER on IntegriCloud