summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* constexpr: don't consider class types with mutable members to be literal types.Richard Smith2011-10-121-1/+5
| | | | | | | The standard doesn't allow this, but mutable constexpr variables break the semantics so badly that we can't reasonably accept them. llvm-svn: 141768
* Constant expression evaluation refactoring:Richard Smith2011-10-101-8/+4
| | | | | | | | | | | - Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. llvm-svn: 141561
* Per C++ [class.bit]p2, unnamed bit-fields are not members. Fixes PR10289.Douglas Gregor2011-10-101-0/+7
| | | | llvm-svn: 141549
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-1/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-3/+3
| | | | llvm-svn: 140367
* Fix a broken assert in AST/DeclCXX.cpp.Richard Trieu2011-09-101-1/+1
| | | | llvm-svn: 139461
* Implement the suggested resolution of WG21 N3307 issue 19: When determining ↵Richard Smith2011-09-051-11/+7
| | | | | | whether a class is an aggregate in C++0x, treat all functions which are neither deleted nor defaulted as user-provided, not just special member functions. The wording of the standard only defines the term "user-provided" for special member functions, but the intent seems to be that any function can be user-provided. llvm-svn: 139111
* Declare and define implicit move constructor and assignment operator.Sebastian Redl2011-08-301-2/+3
| | | | | | | | | This makes the code duplication of implicit special member handling even worse, but the cleanup will have to come later. For now, this works. Follow-up with tests for explicit defaulting and enabling the __has_feature flag to come. llvm-svn: 138821
* Track in the AST whether a function is constexpr.Richard Smith2011-08-151-12/+13
| | | | llvm-svn: 137653
* Renamings to consistently use 'Constexpr' not 'ConstExpr' when referring to ↵Richard Smith2011-08-101-5/+4
| | | | | | the C++0x 'constexpr' keyword. llvm-svn: 137230
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-4/+4
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Correctly set up the list of virtual base classes for a CXXRecordDecl. ↵Richard Smith2011-07-121-16/+2
| | | | | | Previously we got the source range wrong for everything in the virtual bases list. llvm-svn: 135011
* Automatic Reference Counting.John McCall2011-06-151-1/+35
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-111-0/+26
| | | | llvm-svn: 132878
* Implement a little bit of cleanup and a lot more of the base workAlexis Hunt2011-05-251-71/+91
| | | | | | | | behind implicit moves. We now correctly identify move constructors and assignment operators and update bits on the record correctly. Generation of implicit moves (declarations or definitions) is not yet supported. llvm-svn: 132080
* Implement the new C++0x rules for non-trivial things in unions so thatAlexis Hunt2011-05-161-14/+11
| | | | | | my defaulted constructor tests stop yelling at me about them. llvm-svn: 131432
* When determining whether we can make a declaration into a globalDouglas Gregor2011-05-131-1/+13
| | | | | | | constant, also consider whether it's a class type that has any mutable fields. If so, it can't be a global constant. llvm-svn: 131276
* Implement implicit deletion of default constructors.Alexis Hunt2011-05-111-5/+2
| | | | | | | | Yes, I'm aware that the diagnostics are awful. Tests to follow. llvm-svn: 131203
* Clean up trivial default constructors now.Alexis Hunt2011-05-091-18/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | hasTrivialDefaultConstructor() really really means it now. Also implement a fun standards bug regarding aggregates. Doug, if you'd like, I can un-implement that bug if you think it is truly a defect. The bug is that non-special-member constructors are never considered user-provided, so the following is an aggregate: struct foo { foo(int); }; It's kind of bad, but the solution isn't obvious - should struct foo { foo (int) = delete; }; be an aggregate or not? Lastly, add a missing initialization to FunctionDecl. llvm-svn: 131101
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-091-29/+37
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* Revert r130912 in order to approach defaulted functions from the otherAlexis Hunt2011-05-061-5/+3
| | | | | | | direction and not introduce things in the wrong place three different times. llvm-svn: 130968
* Implement some framework for defaulted constructors.Alexis Hunt2011-05-051-3/+5
| | | | | | There's some unused stuff for now. llvm-svn: 130912
* Rename the last '[hH]asStandardLayout' entites to '[iI]sStandardLayout'Chandler Carruth2011-04-301-14/+14
| | | | | | | based on Doug's preferences when we discussed this in IRC. This brings the wording more in line with the standard. llvm-svn: 130603
* Completely re-implement the core logic behind the __is_standard_layoutChandler Carruth2011-04-301-10/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type trait. The previous implementation suffered from several problems: 1) It implemented all of the logic in RecordType by walking over every base and field in a CXXRecordDecl and validating the constraints of the standard. This made for very straightforward code, but is extremely inefficient. It also is conceptually wrong, the logic tied to the C++ definition of standard-layout classes should be in CXXRecordDecl, not RecordType. 2) To address the performance problems with #1, a cache bit was added to CXXRecordDecl, and at the completion of every C++ class, the RecordType was queried to determine if it was a standard layout class, and that state was cached. Two things went very very wrong with this. First, the caching version of the query *was never called*. Even within the recursive steps of the walk over all fields and bases the caching variant was not called, making each query a full *recursive* walk. Second, despite the cache not being used, it was computed for every class declared, even when the trait was never used in the program. This probably significantly regressed compile time performance for edge-case files. 3) An ASTContext was required merely to query the type trait because querying it performed the actual computations. 4) The caching bit wasn't managed correctly (uninitialized). The new implementation follows the system for all the other traits on C++ classes by encoding all the state needed in the definition data and building up the trait incrementally as each base and member are added to the definition of the class. The idiosyncracies of the specification of standard-layout classes requires more state than I would like; currently 5 bits. I could eliminate one of the bits easily at the expense of both clarity and resilience of the code. I might be able to eliminate one of the other bits by computing its state in terms of other state bits in the definition. I've already done that in one place where there was a fairly simple way to achieve it. It's possible some of the bits could be moved out of the definition data and into some other structure which isn't serialized if the serialized bloat is a problem. That would preclude serialization of a partial class declaration, but that's likely already precluded. Comments on any of these issues welcome. llvm-svn: 130601
* Initialize HasStandardLayout.Benjamin Kramer2011-04-301-1/+1
| | | | llvm-svn: 130600
* More cleanup of template argument deduction and its handling ofDouglas Gregor2011-04-281-2/+2
| | | | | | | non-CVR qualifiers. We can now properly match address-space--qualified references during template argument deduction. llvm-svn: 130365
* t/clang/type-traitsJohn Wiegley2011-04-271-0/+4
| | | | | | | | | | Patch authored by John Wiegley. These type traits are used for parsing code that employs certain features of the Embarcadero C++ compiler. Several of these constructs are also desired by libc++, according to its project pages (such as __is_standard_layout). llvm-svn: 130342
* Implement most of the remaining logic in __is_literal type trait. ThisChandler Carruth2011-04-241-2/+18
| | | | | | | should now support all of the C++98 types, and all of the C++0x types Clang supports. llvm-svn: 130079
* Begin tracking trivialness of move constructors and move assignmentChandler Carruth2011-04-231-52/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | operators in C++ record declarations. This patch starts off by updating a bunch of the standard citations to refer to the draft 0x standard so that the semantics intended for move varianst is clear. Where necessary these are duplicated so they'll be available in doxygen. It adds bit fields to keep track of the state for the move constructs, and updates all the code necessary to track this state (I think) as members are declared for a class. It also wires the state into the various trait-like accessors in the AST's API, and tests that the type trait expressions now behave correctly in the presence of move constructors and move assignment operators. This isn't complete yet due to these glaring FIXMEs: 1) No synthesis of implicit move constructors or assignment operators. 2) I don't think we correctly enforce the new logic for both copy and move trivial checks: that the *selected* copy/move constructor/operator is trivial. Currently this requires *all* of them to be trivial. 3) Some of the trait logic needs to be folded into the fine-grained trivial bits to more closely match the wording of the standard. For example, many of the places we currently set a bit to track POD-ness could be removed by querying other more fine grained traits on demand. llvm-svn: 130076
* Implement basic __is_trivial type-trait support, enough to close PR9472.Chandler Carruth2011-04-231-0/+17
| | | | | | | | | | | | | | | | | | This introduces a few APIs on the AST to bundle up the standard-based logic so that programmatic clients have access to exactly the same behavior. There is only one serious FIXME here: checking for non-trivial move constructors and move assignment operators. Those bits need to be added to the declaration and accessors provided. This implementation should be enough for the uses of __is_trivial in libstdc++ 4.6's C++98 library implementation. Ideas for more thorough test cases or any edge cases missing would be appreciated. =D llvm-svn: 130057
* Eliminate an uninteresting assertion; invalid code involvingDouglas Gregor2011-04-201-2/+0
| | | | | | | | out-of-line destructors can result in the addition of redundant destructors to a class. It's not harmful to the AST. Fixes <rdar://problem/9158632>. llvm-svn: 129860
* Fixed InnerLocStart.Abramo Bagnara2011-03-091-10/+9
| | | | llvm-svn: 127330
* Teach libclang's token-annotation logic about context-sensitiveDouglas Gregor2011-03-081-5/+8
| | | | | | keywords for Objective-C+ and C++0x. llvm-svn: 127253
* Fixed source range for StaticAssertDecl and LinkageSpecDecl. Fixed source ↵Abramo Bagnara2011-03-081-5/+9
| | | | | | range for declarations using postfix types. llvm-svn: 127251
* Fixed source range for all DeclaratorDecl's.Abramo Bagnara2011-03-081-8/+12
| | | | llvm-svn: 127225
* Removed left brace location from LinkageSpecDecl.Abramo Bagnara2011-03-031-2/+1
| | | | llvm-svn: 126945
* Fixed end source location for LinkageSpecDecl.Abramo Bagnara2011-03-031-2/+4
| | | | llvm-svn: 126943
* Implement delegating constructors partially.Alexis Hunt2011-02-261-1/+11
| | | | | | | | | | | This successfully performs constructor lookup and verifies that a delegating initializer is the only initializer present. This does not perform loop detection in the initialization, but it also doesn't codegen delegating constructors at all, so this won't cause runtime infinite loops yet. llvm-svn: 126552
* Push nested-name-specifier source location information into namespaceDouglas Gregor2011-02-251-4/+3
| | | | | | aliases. llvm-svn: 126496
* Push nested-name-specifier source location information into using directives.Douglas Gregor2011-02-251-4/+3
| | | | llvm-svn: 126489
* Update UsingDecl, UnresolvedUsingTypenameDecl, andDouglas Gregor2011-02-251-11/+7
| | | | | | | | | | | | | | UnresolvedUsingValueDecl to use NestedNameSpecifierLoc rather than the extremely-lossy NestedNameSpecifier/SourceRange pair it used to use, improving source-location information. Various infrastructure updates to support NestedNameSpecifierLoc: - AST/PCH (de-)serialization - Recursive AST visitor - libclang traversal (including the first tests of this functionality) llvm-svn: 126459
* Revert all of my commits that devirtualized the Decl hierarchy, whichDouglas Gregor2011-02-191-8/+7
| | | | | | | | lead to a serious slowdown (4%) on parsing of Cocoa.h. This memory optimization should be revisited later, when we have time to look at the generated code. llvm-svn: 126033
* Devirtualize TagDecl::completeDefinition().Douglas Gregor2011-02-171-7/+8
| | | | llvm-svn: 125755
* Basic implementation of inherited constructors. Only generates declarations, ↵Sebastian Redl2011-02-051-0/+16
| | | | | | and probably only works for very basic use cases. llvm-svn: 124970
* Use attributes for all the override control specifiers.Anders Carlsson2011-01-241-3/+2
| | | | llvm-svn: 124122
* Add final/explicit getters and setters to CXXRecordDecl.Anders Carlsson2011-01-221-0/+1
| | | | llvm-svn: 124037
* Implement the preference for move-construction over copy-constructionDouglas Gregor2011-01-211-10/+25
| | | | | | | | | | | | when returning an NRVO candidate expression. For example, this properly picks the move constructor when dealing with code such as MoveOnlyType f() { MoveOnlyType mot; return mot; } The previously-XFAIL'd rvalue-references test case now works, and has been moved into the appropriate paragraph-specific test case. llvm-svn: 123992
* Change QualType::getTypePtr() to return a const pointer, then change aJohn McCall2011-01-191-7/+0
| | | | | | thousand other things which were (generally inadvertantly) relying on that. llvm-svn: 123814
* PR3558: mark "logically const" accessor methods in ASTContext as const,Jay Foad2011-01-121-6/+6
| | | | | | | and mark the fields they use as mutable. This allows us to remove a few const_casts. llvm-svn: 123314
* Rename CXXCtorInitializer::BaseOrMember to Initializee, since it will also beAlexis Hunt2011-01-081-9/+9
| | | | | | used to store the CXXConstructorDecl in a delegating constructor. llvm-svn: 123095
OpenPOWER on IntegriCloud