summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
* 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-165-52/+60
| | | | | | | | hold the used constructor itself."" This reintroduces commit r150682 with a fix for the Bullet benchmark crash. llvm-svn: 150685
* Revert "Make CXXNewExpr contain only a single initialier, and not hold the ↵Sebastian Redl2012-02-165-60/+52
| | | | | | | | | | 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-165-52/+60
| | | | | | | | | | 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
* constexpr tidyups:Richard Smith2012-02-161-33/+80
| | | | | | | | * Fix bug when determining whether && / || are potential constant expressions * Try harder when determining whether ?: is a potential constant expression * Produce a diagnostic on sizeof(VLA) to provide a better source location llvm-svn: 150657
* Implicitly define a lambda's conversion functions (to functionDouglas Gregor2012-02-161-0/+15
| | | | | | | | | | | | | pointers and block pointers). We use dummy definitions to keep the invariant that an implicit, used definition has a body; IR generation will substitute the actual contents, since they can't be represented as C++. For the block pointer case, compute the copy-initialization needed to capture the lambda object in the block, which IR generation will need later. llvm-svn: 150645
* When overload resolution picks an implicitly-deleted special memberDouglas Gregor2012-02-151-2/+8
| | | | | | | | | function, provide a specialized diagnostic that indicates the kind of special member function (default constructor, copy assignment operator, etc.) and that it was implicitly deleted. Add a hook where we can provide more detailed information later. llvm-svn: 150611
* Implement DR1454. This allows all intermediate results in constant expressionsRichard Smith2012-02-152-166/+267
| | | | | | | | | | | | to be core constant expressions (including pointers and references to temporaries), and makes constexpr calculations Turing-complete. A Turing machine simulator is included as a testcase. This opens up the possibilty of removing CCValue entirely, and removing some copies from the constant evaluator in the process, but that cleanup is not part of this change. llvm-svn: 150557
* Split reinterpret_casts of member pointers out from CK_BitCast; thisJohn McCall2012-02-152-0/+9
| | | | | | | | | | | | | | | | | | | | | is general goodness because representations of member pointers are not always equivalent across member pointer types on all ABIs (even though this isn't really standard-endorsed). Take advantage of the new information to teach IR-generation how to do these reinterprets in constant initializers. Make sure this works when intermingled with hierarchy conversions (although this is not part of our motivating use case). Doing this in the constant-evaluator would probably have been better, but that would require a *lot* of extra structure in the representation of constant member pointers: you'd really have to track an arbitrary chain of hierarchy conversions and reinterpretations in order to get this right. Ultimately, this seems less complex. I also wasn't quite sure how to extend the constant evaluator to handle foldings that we don't actually want to treat as extended constant expressions. llvm-svn: 150551
* constexpr: evaluation support for nullptr comparisons.Richard Smith2012-02-141-0/+10
| | | | llvm-svn: 150521
* Pending clear answer from WG21 on whether core issue 903 is intended to apply toRichard Smith2012-02-142-4/+16
| | | | | | | C++11 or just C++17, restrict the set of null pointer constants in C++11 mode back to those which were considered null in C++98. llvm-svn: 150510
* Implement AST (de-)serialization for lambda expressions.Douglas Gregor2012-02-141-0/+17
| | | | llvm-svn: 150491
* Deal with a horrible C++11 special case. If a non-literal type has a constexprRichard Smith2012-02-131-8/+9
| | | | | | | | | | | constructor, and that constructor is used to initialize an object of static storage duration such that all members and bases are initialized by constant expressions, constant initialization is performed. In this case, the object can still have a non-trivial destructor, and if it does, we must emit a dynamic initializer which performs no initialization and instead simply registers that destructor. llvm-svn: 150419
* Introduce support for template instantiation of lambdaDouglas Gregor2012-02-132-5/+8
| | | | | | | | | | | | | | | | | | 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-132-92/+53
| | | | | | | | | | | | 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-132-2/+40
| | | | | | | 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-132-30/+98
| | | | | | | | 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
* Update constexpr implementation to match CWG's chosen approach for core issuesRichard Smith2012-02-132-4/+17
| | | | | | | | | | | | | | | | | | | | 1358, 1360, 1452 and 1453. - Instantiations of constexpr functions are always constexpr. This removes the need for separate declaration/definition checking, which is now gone. - This makes it possible for a constexpr function to be virtual, if they are only dependently virtual. Virtual calls to such functions are not constant expressions. - Likewise, it's now possible for a literal type to have virtual base classes. A constexpr constructor for such a type cannot actually produce a constant expression, though, so add a special-case diagnostic for a constructor call to such a type rather than trying to evaluate it. - Classes with trivial default constructors (for which value initialization can produce a fully-initialized value) are considered literal types. - Classes with volatile members are not literal types. - constexpr constructors can be members of non-literal types. We do not yet use static initialization for global objects constructed in this way. llvm-svn: 150359
* Within the body of a lambda expression, decltype((x)) for anDouglas Gregor2012-02-122-35/+8
| | | | | | | | | | | | | | | | id-expression 'x' will compute the type based on the assumption that 'x' will be captured, even if it isn't captured, per C++11 [expr.prim.lambda]p18. There are two related refactors that go into implementing this: 1) Split out the check that determines whether we should capture a particular variable reference, along with the computation of the type of the field, from the actual act of capturing the variable. 2) Always compute the result of decltype() within Sema, rather than AST, because the decltype() computation is now context-sensitive. llvm-svn: 150347
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-114-16/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* const-qualify CXXRecordDecl::getCaptureFields.Eli Friedman2012-02-111-1/+1
| | | | llvm-svn: 150284
* Track whether a function type has a trailing return type as type sugar. Use thisRichard Smith2012-02-103-7/+17
| | | | | | | | | | | to pretty-print such function types better, and to fix a case where we were not instantiating templates in lexical order. In passing, move the Variadic bit from Type's bitfields to FunctionProtoType to get the Type bitfields down to 32 bits. Also ensure that we always substitute the return type of a function when substituting explicitly-specified arguments, since that can cause us to bail out with a SFINAE error before we hit a hard error in parameter substitution. llvm-svn: 150241
* Extend CXXRecordDecl with a function that determines the mapping fromDouglas Gregor2012-02-101-0/+29
| | | | | | | the variables captured by a lambda to the fields that store the captured values. To be used in IRgen. llvm-svn: 150235
* Update to new resolution for DR1458. When taking the address of an object ofRichard Smith2012-02-101-12/+0
| | | | | | | incomplete class type which has an overloaded operator&, it's now just unspecified whether the overloaded operator or the builtin is used. llvm-svn: 150234
* objc: If a method is not implemented in the category implementation butFariborz Jahanian2012-02-091-15/+17
| | | | | | | | has been declared in its primary class, superclass, or in one of their protocols, no need to issue unimplemented method. // rdar://10823023 llvm-svn: 150206
* CWG issue 1405: mutable members are allowed in literal types, but can't undergoRichard Smith2012-02-092-5/+8
| | | | | | lvalue-to-rvalue conversions in constant expressions. llvm-svn: 150145
* [PCH] Avoid using Decl::setAttrs() and Decl::setLexicalDeclContext() from ↵Argyrios Kyrtzidis2012-02-091-6/+15
| | | | | | | | | the ASTReaderDecl directly; they internally call Decl::getASTContext() which may crash if a declaration context parent is still deserializing. llvm-svn: 150137
* Implement DR1458: Taking the address of an object of incomplete class type isRichard Smith2012-02-081-0/+12
| | | | | | | not a constant expression, because we can't tell whether the complete class type will have an overloaded operator&. llvm-svn: 150066
* Implement the agreed resolution to DR1457: a signed left shift of a 1 bit intoRichard Smith2012-02-081-4/+3
| | | | | | | | | | the sign bit doesn't have undefined behavior, but a signed left shift of a 1 bit out of the sign bit still does. As promised to Howard :) The suppression of the potential constant expression checking in system headers is also removed, since the problem it was working around is gone. llvm-svn: 150059
* Revise the SplitQualType interface to make it its own thing instead ofJohn McCall2012-02-084-47/+48
| | | | | | | | | | | | | | a typedef of std::pair. This slightly improves type-safety, but mostly makes code using it clearer to read as well as making it possible to add methods to the type. Add such a method for efficiently single-step desugaring a split type. Add a method to single-step desugaring a locally-unqualified type. Implement both the SplitQualType and QualType methods in terms of that. Also, fix a typo ("ObjCGLifetime"). llvm-svn: 150028
* If a struct needs to be laid out, and it has notSean Callanan2012-02-081-0/+4
| | | | | | | | been completed yet, then complete it if possible. This fixes some assertion failures encountered by LLDB. llvm-svn: 150020
* Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer2012-02-078-68/+0
| | | | | | | | | | | | | | | | | | operator overloads out of line. This seems to negatively affect compile time onsome ObjC tests (which use a lot of partial diagnostics I assume). I have to come up with a way to keep them inline without including Diagnostic.h everywhere. Now adding a new diagnostic requires a full rebuild of e.g. the static analyzer which doesn't even use those diagnostics. This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99. This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789. This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7. This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f. This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5. llvm-svn: 150006
* Print NamedDecls directly to a raw_ostream where possible.Benjamin Kramer2012-02-075-9/+8
| | | | llvm-svn: 149982
* Switch the ObjC*Decl raw_stream overloads to take a reference, for ↵Benjamin Kramer2012-02-073-6/+6
| | | | | | consistency with NamedDecls. llvm-svn: 149981
* Introduce basic ASTs for lambda expressions. This covers:Douglas Gregor2012-02-078-27/+260
| | | | | | | | | | | | | | | | | | | | | | | | - 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
* Make FunctionDecl::doesDeclarationForceExternallyVisibleDefinition use the ↵Eli Friedman2012-02-071-26/+68
| | | | | | same logic as FunctionDecl::isInlineDefinitionExternallyVisible to figure out whether to emit a definition. Based on work by Anton Yartsev. llvm-svn: 149963
* Added source location for the template keyword in ↵Abramo Bagnara2012-02-061-3/+3
| | | | | | | | | | DependentTemplateSpecializationTypeLoc nodes (DTSTLoc). The new info is propagated to TSTLoc on template instantiation, getting rid of 3 FIXMEs in TreeTransform.h and another one Parser.cpp. Simplified code in TypeSpecLocFiller visitor methods for DTSTLoc and DependentNameTypeLoc by removing what now seems to be dead code (adding corresponding assertions). llvm-svn: 149923
* Fix the result of VarDecl::checkInitIsICE so it is consistently accurate in ↵Eli Friedman2012-02-061-1/+1
| | | | | | C++11 mode. PR11928. llvm-svn: 149908
* Removed redundant location info from ElaboratedTypeLoc / DependentNameLoc / ↵Abramo Bagnara2012-02-061-2/+2
| | | | | | DependentTSTLoc. Uniformed names referencing elaborated keyword. No intended functionality changes. llvm-svn: 149889
* objc: fixes a problem in block type comparison involvingFariborz Jahanian2012-02-061-2/+4
| | | | | | | | enums with underlying type explicitly specified (feature which is on by default in objective-c). // rdar://10798770 llvm-svn: 149888
* Added location for template keyword in TemplateSpecializationTypeLoc. In the ↵Abramo Bagnara2012-02-062-2/+3
| | | | | | process removed some naming ambiguities. llvm-svn: 149870
* Fixed instantiation of DependentScopeDeclRefExpr.Abramo Bagnara2012-02-061-5/+7
| | | | llvm-svn: 149868
* Implement name mangling for scalar value initialization. Reported on IRC by Xeo.Richard Smith2012-02-061-1/+6
| | | | llvm-svn: 149854
* Move operator overload out of line. Calling operator<< on a forward declared ↵Benjamin Kramer2012-02-051-0/+6
| | | | | | type doesn't seem to work on MSVC. llvm-svn: 149819
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-057-15/+15
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Basic: import OwningPtr<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | llvm-svn: 149798
* constexpr: Fix implementation of DR1311: check for volatile qualifiers inRichard Smith2012-02-051-2/+5
| | | | | | | lvalue-to-rvalue conversions on the source type of the conversion, not the target type (which has them removed for non-class types). llvm-svn: 149796
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-043-7/+7
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
OpenPOWER on IntegriCloud