summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Renamed CXXBaseOrMemberInitializer to CXXCtorInitializer. This is both shorter,Alexis Hunt2011-01-081-36/+37
| | | | | | | more accurate, and makes it make sense for it to hold a delegating constructor call. llvm-svn: 123084
* Implement pack expansion of base initializers, so that we canDouglas Gregor2011-01-041-5/+6
| | | | | | | initialize those lovely mixins that come from pack expansions of base specifiers. llvm-svn: 122793
* Implement pack expansions whose pattern is a base-specifier.Douglas Gregor2011-01-031-1/+2
| | | | llvm-svn: 122782
* Revert r120808, my previous implementation of caching for the linkageDouglas Gregor2010-12-061-2/+0
| | | | | | | | | and visibility of declarations, because it was extremely messy and it increased the size of NamedDecl. An improved implementation is forthcoming. llvm-svn: 121012
* More anonymous struct/union redesign. This one deals with anonymous field ↵Francois Pichet2010-12-041-4/+14
| | | | | | | | | | | | | | | | used in a constructor initializer list: struct X { X() : au_i1(123) {} union { int au_i1; float au_f1; }; }; clang will now deal with au_i1 explicitly as an IndirectFieldDecl. llvm-svn: 120900
* Implement caching for the linkage and visibility calculations ofDouglas Gregor2010-12-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | declarations. The motivation for this patch is that linkage/visibility computations are linear in the number of redeclarations of an entity, and we've run into a case where a single translation unit has > 6500 redeclarations of the same (unused!) external variable. Since each redeclaration involves a linkage check, the resulting quadratic behavior makes Clang slow to a crawl. With this change, a simple test with 512 redeclarations of a variable syntax-checks ~20x faster than before. That said, I hate this change, and will probably end up reverting it in a few hours. Reasons to hate it: - It makes NamedDecl larger, since we don't have enough free bits in Decl to squeeze in the extra information about caching. - There are way too many places where we need to invalidate this cache, because the visibility of a declaration can change due to redeclarations (!). Despite self-hosting and passing the testsuite, I have no confidence that I've found all of places where this cache needs to be invalidated. llvm-svn: 120808
* Eliminate two uses of NDEBUG in headers that cause different symbolsDouglas Gregor2010-12-021-14/+0
| | | | | | to be available in debug vs. release builds. llvm-svn: 120629
* Replace UsingDecl's SmallPtrSet of UsingShadowDecls with a linked list to ↵Argyrios Kyrtzidis2010-11-101-0/+38
| | | | | | | | avoid leaking memory. Fixes rdar://8649963. llvm-svn: 118674
* Improve our handling of C++ [class.copy]p3, which specifies that aDouglas Gregor2010-11-081-7/+1
| | | | | | | | | constructor template will not be used to copy a class object to a value of its own type. We were eliminating all constructor templates whose specializations look like a copy constructor, which eliminated important candidates. Fixes PR8182. llvm-svn: 118418
* Rename alignof -> alignOf to avoid irritating C++'0x compilers,Chris Lattner2010-10-301-1/+1
| | | | | | PR8423 llvm-svn: 117775
* Make the deserialization of C++ base class specifiers lazy, improvingDouglas Gregor2010-10-291-5/+5
| | | | | | the performance of C++ PCH and reducing stack depth in the reader. llvm-svn: 117732
OpenPOWER on IntegriCloud