summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* AST: __uuidof should leak through templated typesDavid Majnemer2013-09-071-6/+47
| | | | | | | | | | | | | | | Summary: __uuidof on templated types should exmaine if any of its template parameters have a uuid declspec. If exactly one does, then take it. Otherwise, issue an appropriate error. Reviewers: rsmith, thakis, rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1419 llvm-svn: 190240
* Fix missing source location in CXXTemporaryObjectExpr nodes.Enea Zaffanella2013-09-071-9/+10
| | | | | | | | For clarity, renamed (get/set)ParenRange as (get/set)ParenOrBraceRange in CXXConstructExpr nodes. Added testcase. llvm-svn: 190239
* Delete CC_Default and use the target default CC everywhereReid Kleckner2013-08-271-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Makes functions with implicit calling convention compatible with function types with a matching explicit calling convention. This fixes things like calls to qsort(), which has an explicit __cdecl attribute on the comparator in Windows headers. Clang will now infer the calling convention from the declarator. There are two cases when the CC must be adjusted during redeclaration: 1. When defining a non-inline static method. 2. When redeclaring a function with an implicit or mismatched convention. Fixes PR13457, and allows clang to compile CommandLine.cpp for the Microsoft C++ ABI. Excellent test cases provided by Alexander Zinenko! Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1231 llvm-svn: 189412
* Revert "Implement a rudimentary form of generic lambdas."Manuel Klimek2013-08-221-7/+7
| | | | | | This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7. llvm-svn: 189004
* Constify more uses of ASTContext&. No functional change.Craig Topper2013-08-221-49/+52
| | | | llvm-svn: 188991
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-08-221-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - nested lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware As an example of what compiles: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Augment AutoType's constructor (similar to how variadic template-type-parameters ala TemplateTypeParmDecl are implemented) to accept an IsParameterPack to encode a generic lambda parameter pack. - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that Sema::ActOnLambdaAutoParameter may use it to create the appropriate list of corresponding TemplateTypeParmDecl for each auto parameter identified within the generic lambda (also stored within the current LambdaScopeInfo). Additionally, a TemplateParameterList data-member was added to hold the invented TemplateParameterList AST node which will be much more useful once we teach TreeTransform how to transform generic lambdas. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - Teach Sema::ActOnStartOfLambdaDefinition to set the return type of a lambda without a trailing return type to 'auto' in C++1y mode, and teach the return type deduction machinery in SemaStmt.cpp to process either C++11 and C++14 lambda's correctly depending on the flag. - various tests were added - but much more will be needed. A greatful thanks to all reviewers including Eli Friedman, James Dennett and the ever illuminating Richard Smith. And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 188977
* Properly track l-paren of a CXXFucntionalCastExpr.Eli Friedman2013-08-151-4/+12
| | | | | | | | | | In addition to storing more useful information in the AST, this fixes a semantic check in template instantiation which checks whether the l-paren location is valid. Fixes PR16903. llvm-svn: 188495
* [-cxx-abi microsoft] Mangle __uuidof correctly into template parametersDavid Majnemer2013-08-131-0/+15
| | | | | | | | | | | | | | | | | | | | | | | Summary: It seems that __uuidof introduces a global extern "C" declaration of type __s_GUID. However, our implementation of __uuidof does not provide such a declaration and thus must open-code the mangling for __uuidof in template parameters. This allows us to codegen scoped COM pointers and other such things. This fixes PR16836. Depends on D1356. Reviewers: rnk, cdavis5x, rsmith Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1357 llvm-svn: 188252
* Expose LambdaIntroducer::DefaultLoc in the AST's LambdaExpr.James Dennett2013-08-091-6/+10
| | | | | | | | | | | | | | | | | | | | | Summary: Source-centric tools need access to the location of a C++11 lambda expression's capture-default ('&' or '=') when it's present. It's possible for them to find it by re-lexing and re-implementing rules that Clang's parser has already applied, but the cost of storing the SourceLocation and making it available to them is 32 bits per LambdaExpr (a small delta, proportionally), and the simplification in client code is significant. Reviewers: rsmith Reviewed By: rsmith CC: cfe-commits, klimek, revane Differential Revision: http://llvm-reviews.chandlerc.com/D1192 llvm-svn: 188121
* Fix source range of CXXNewExpr with parentheses around the type. PR15569.Eli Friedman2013-06-171-1/+4
| | | | llvm-svn: 184139
* First pass of semantic analysis for init-captures: check the initializer, buildRichard Smith2013-05-161-4/+16
| | | | | | | | | | | | | a FieldDecl from it, and propagate both into the closure type and the LambdaExpr. You can't do much useful with them yet -- you can't use them within the body of the lambda, because we don't have a representation for "the this of the lambda, not the this of the enclosing context". We also don't have support or a representation for a nested capture of an init-capture yet, which was intended to work despite not being allowed by the current standard wording. llvm-svn: 181985
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-2/+1
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-201-0/+11
| | | | | | | | | | | Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in CXXCtorInitializers and in InitListExprs to represent a default initializer. There's an additional complication here: because the default initializer can refer to the initialized object via its 'this' pointer, we need to make sure that 'this' points to the right thing within the evaluation. llvm-svn: 179958
* ArrayRef-ize ASTContext::getFunctionType and Sema::BuildFunctionType.Jordan Rose2013-03-081-1/+2
| | | | | | No (intended) functionality change. llvm-svn: 176726
* objective-C arg: provide fixit support whenFariborz Jahanian2013-02-221-8/+12
| | | | | | | c++'s named cast need be replaced for bridge casting. // rdar://12788838 llvm-svn: 175923
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-1/+1
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* Fix for PR12222.Erik Verbruggen2012-12-251-16/+22
| | | | | | | | Changed getLocStart() and getLocEnd() to be required for Stmts, and make getSourceRange() optional. The default implementation for getSourceRange() is build the range by calling getLocStart() and getLocEnd(). llvm-svn: 171067
* PR13470: Ensure that copy-list-initialization isntantiates asRichard Smith2012-12-191-1/+3
| | | | | | | | | | | | copy-list-initialization (and doesn't add an additional copy step): Fill in the ListInitialization bit when creating a CXXConstructExpr. Use it when instantiating initializers in order to correctly handle instantiation of copy-list-initialization. Teach TreeTransform that function arguments are initializations, and so need this special treatment too. Finally, remove some hacks which were working around SubstInitializer's shortcomings. llvm-svn: 170489
* Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as ↵David Blaikie2012-12-191-3/+3
| | | | | | | | | | | | | | | per review discussion in r170365 This does limit these typedefs to being sequences, but no current usage requires them to be contiguous (we could expand this to a more general iterator pair range concept at some point). Also, it'd be nice if SmallVector were constructible directly from an ArrayRef but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the inverse conversion. (& generalizing over all range-like things, while nice, would require some nontrivial SFINAE I haven't thought about yet) llvm-svn: 170482
* Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't ↵Benjamin Kramer2012-12-011-1/+2
| | | | | | | | | pull in all the generated Attr code. Required to pull some functions out of line, but this shouldn't have a perf impact. No functionality change. llvm-svn: 169092
* Fix a source range regression in C++ new expressions with call initializers.David Blaikie2012-11-081-0/+8
| | | | | | Introduced in r167507, discovered in review by Abramo Bagnara. llvm-svn: 167597
* PR13552: Fix the end location of a CXXNewExpr.David Blaikie2012-11-071-14/+2
| | | | | | | | | Spent longer than reasonable looking for a nice way to test this & decided to give up for now. Open to suggestions/requests. Richard Smith suggested adding something to ASTMatchers but it wasn't readily apparent how to test this with that. llvm-svn: 167507
* DR1442: In a range-based for statement, namespace 'std' is not an associatedRichard Smith2012-10-181-1/+1
| | | | | | namespace. llvm-svn: 166194
* Add codegen support for __uuidof().Nico Weber2012-10-111-0/+20
| | | | llvm-svn: 165710
* PR13811: Add a FunctionParmPackExpr node to handle references to functionRichard Smith2012-09-121-0/+28
| | | | | | | parameter packs where the reference is not being expanded but the pack has been. Previously, Clang would segfault in such cases. llvm-svn: 163672
* Push ArrayRef through the Expr hierarchy.Benjamin Kramer2012-08-241-21/+17
| | | | | | No functionality change. llvm-svn: 162552
* Switch some realignment calculations over to llvm::RoundUpToAlignment.Richard Smith2012-08-211-2/+1
| | | | llvm-svn: 162297
* Fix alignment of array of VarDecl* following array of unsigned in LambdaExpr.Richard Smith2012-08-211-3/+7
| | | | llvm-svn: 162255
* PR13570: When an unresolved overloaded call appeared in a dependent context, weRichard Smith2012-08-131-0/+1
| | | | | | | forgot to set it as being instantiation-dependent as well as being type- and value-dependent. llvm-svn: 161791
* Factor out computation of whether a typeid's expression is potentiallyRichard Smith2012-08-131-0/+15
| | | | | | evaluated into a CXXTypeid member function. No functionality change. llvm-svn: 161779
* Provide isConst/Volatile on CXXMethodDecl.David Blaikie2012-08-101-1/+1
| | | | | | | | | This also provides isConst/Volatile/Restrict on FunctionTypes to coalesce the implementation with other callers (& update those other callers). Patch contributed by Sam Panzer (panzer@google.com). llvm-svn: 161647
* Enhance getImplicitObjectArgument to look through ->*.Jordan Rose2012-08-031-2/+5
| | | | | | | This only applies in the case where ->* is not overloaded, since it specifically looks for BinaryOperator and not CXXOperatorCallExpr. llvm-svn: 161275
* PR12057: Allow variadic template pack expansions to cross lambda boundaries.Richard Smith2012-07-251-4/+6
| | | | | | | | | | Rather than adding a ContainsUnexpandedParameterPack bit to essentially every AST node, we tunnel the bit directly up to the surrounding lambda expression when we reach a context where an unexpanded pack can not normally appear. Thus any statement or declaration within a lambda can now potentially contain an unexpanded parameter pack. llvm-svn: 160705
* The delete argument should not be converted to void*.Abramo Bagnara2012-07-091-7/+0
| | | | llvm-svn: 159961
* Drop the ASTContext.h include from DeclFriend.h and DeclTemplate.h.Benjamin Kramer2012-07-041-0/+1
| | | | llvm-svn: 159723
* Do not crash when we dynamic cast a final type to void*.Alexis Hunt2012-06-191-0/+3
| | | | llvm-svn: 158763
* Revert r158700 and dependent patches r158716, r158717, and r158731.Jakob Stoklund Olesen2012-06-191-0/+3
| | | | | | | | The original r158700 caused crashes in the gcc test suite, g++.abi/vtable3a.C among others. It also caused failures in the libc++ test suite. llvm-svn: 158749
* Improve the specification of spellings in Attr.td.Alexis Hunt2012-06-191-3/+0
| | | | | | | | | | | | | | | | | Note that this is mostly a structural patch that handles the change from the old spelling style to the new one. One consequence of this is that all AT_foo_bar enum values have changed to not be based off of the first spelling, but rather off of the class name, so they are now AT_FooBar and the like (a straw poll on IRC showed support for this). Apologies for code churn. Most attributes have GNU spellings as a temporary solution until everything else is sorted out (such as a Keyword spelling, which I intend to add if someone else doesn't beat me to it). This is definitely a WIP. I've also killed BaseCheckAttr since it was unused, and I had to go through every attribute anyway. llvm-svn: 158700
* Correctly constify clang::CXXMemberCallExpr::getRecordDecl()David Blaikie2012-05-031-1/+1
| | | | llvm-svn: 156074
* Utilize getLocStart()/getLocEnd() on my recent change.Argyrios Kyrtzidis2012-05-011-9/+6
| | | | llvm-svn: 155952
* Store the source range of a CXXOperatorCallExpr in the Expr object instead ofArgyrios Kyrtzidis2012-04-301-2/+2
| | | | | | | | | | | | | | | calculating it recursively. boost::assign::tuple_list_of uses the trick of chaining call operator expressions in order to declare a "list of tuples", e.g: std::vector<tuple> v = boost::assign::tuple_list_of(1, "foo")(2, "bar")(3, "qqq"); Due to CXXOperatorCallExpr calculating its source range recursively we would get significant slowdowns with a large number of chained call operator expressions and the potential for stack overflow. rdar://11350116 llvm-svn: 155848
* Move the computation of the lambda mangling information (manglingDouglas Gregor2012-04-041-12/+3
| | | | | | | | | | number + context) to the point where we initially start defining the lambda, so that the linkage won't change when that information is made available. Fixes the assertion in <rdar://problem/11182962>. Plus, actually mangle the context of lambdas properly. llvm-svn: 154029
* AST representation for user-defined literals, plus just enough of semanticRichard Smith2012-03-071-0/+33
| | | | | | | | | | | | | | | | | | | | | analysis to make the AST representation testable. They are represented by a new UserDefinedLiteral AST node, which is a sugared CallExpr. All semantic properties, including full CodeGen support, are achieved for free by this representation. UserDefinedLiterals can never be dependent, so no custom instantiation behavior is required. They are mangled as if they were direct calls to the underlying literal operator. This matches g++'s apparent behavior (but not its actual mangling, which is broken for literal-operator-ids). User-defined *string* literals are now fully-operational, but the semantic analysis is quite hacky and needs more work. No other forms of user-defined literal are created yet, but the AST support for them is present. This patch committed after midnight because we had already hit the quota for new kinds of literal yesterday. llvm-svn: 152211
* Reorder members to save padding.Benjamin Kramer2012-02-261-4/+4
| | | | | | | | There's more potential here, but these Exprs aren't used that often so I don't feel like doing heroic bit packing right now. -8 bytes on every class changed (x86_64). llvm-svn: 151501
* Implement a new type trait __is_trivially_constructible(T, Args...)Douglas Gregor2012-02-241-1/+47
| | | | | | | | | | | | | | | | that provides the behavior of the C++11 library trait std::is_trivially_constructible<T, Args...>, which can't be implemented purely as a library. Since __is_trivially_constructible can have zero or more arguments, I needed to add Yet Another Type Trait Expression Class, this one handling arbitrary arguments. The next step will be to migrate UnaryTypeTrait and BinaryTypeTrait over to this new, more general TypeTrait class. Fixes the Clang side of <rdar://problem/10895483> / PR12038. llvm-svn: 151352
* Implement non-internal linkage for lambda closure types that need aDouglas Gregor2012-02-211-1/+4
| | | | | | | | | stable mangling, since these lambdas can end up in multiple translation units. Sema is responsible for deciding when this is the case, because it's already responsible for choosing the mangling number. llvm-svn: 151029
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-3/+6
| | | | | | | | | | | | | | | | default arguments of function parameters. This simple-sounding task is complicated greatly by two issues: (1) Default arguments aren't actually a real context, so we need to maintain extra state within lambda expressions to track when a lambda was actually in a default argument. (2) At the time that we parse a default argument, the FunctionDecl doesn't exist yet, so lambda closure types end up in the enclosing context. It's not clear that we ever want to change that, so instead we introduce the notion of the "effective" context of a declaration for the purposes of name mangling. llvm-svn: 151011
* Basic support for name mangling of C++11 lambda expressions. BecauseDouglas Gregor2012-02-201-3/+6
| | | | | | | | | | | | | | | name mangling in the Itanium C++ ABI for lambda expressions is so dependent on context, we encode the number used to encode each lambda as part of the lambda closure type, and maintain this value within Sema. Note that there are a several pieces still missing: - We still get the linkage of lambda expressions wrong - We aren't properly numbering or mangling lambda expressions that occur in default function arguments or in data member initializers. - We aren't (de-)serializing the lambda numbering tables llvm-svn: 150982
* Pacify gcc's -Wreturn-typeMatt Beaumont-Gay2012-02-161-0/+1
| | | | llvm-svn: 150731
* Revert "Revert "Make CXXNewExpr contain only a single initialier, and not ↵Sebastian Redl2012-02-161-31/+38
| | | | | | | | hold the used constructor itself."" This reintroduces commit r150682 with a fix for the Bullet benchmark crash. llvm-svn: 150685
OpenPOWER on IntegriCloud