summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Introduce Decl::hasBody() and FunctionDecl::hasBody() and use them instead ↵Argyrios Kyrtzidis2010-07-071-1/+1
| | | | | | | | of getBody() when we are just checking the existence of a body, to avoid de-serialization of the body from PCH. Makes de-serialization of the function body even more "lazier". llvm-svn: 107768
* Read/write more information of ASTContext for PCH. Overriden methods and ↵Argyrios Kyrtzidis2010-07-041-0/+4
| | | | | | instantiated-from information. llvm-svn: 107597
* Lazily declare default constructors. We now delay the construction ofDouglas Gregor2010-07-031-1/+4
| | | | | | | | | | | | | | | | | | declarations for implicit default constructors, copy constructors, copy assignment operators, and destructors. On a "simple" translation unit that includes a bunch of C++ standard library headers, we generate relatively few of these implicit declarations now: 4/159 implicit default constructors created 18/236 implicit copy constructors created 70/241 implicit copy assignment operators created 0/173 implicit destructors created And, on this translation unit, this optimization doesn't really provide any benefit. I'll do some more performance measurements soon, but this completes the implementation work for <rdar://problem/8151045>. llvm-svn: 107551
* Lazily declare implicit copy constructors.Douglas Gregor2010-07-021-1/+4
| | | | llvm-svn: 107543
* Lazily declare copy-assignment operators.Douglas Gregor2010-07-021-49/+3
| | | | llvm-svn: 107521
* Lazily declare the implicitly-declared destructor in a C++ class.Douglas Gregor2010-07-021-0/+1
| | | | llvm-svn: 107510
* Add some side-effect free Create methods for TypeDecl subclasses and use ↵Argyrios Kyrtzidis2010-07-021-0/+5
| | | | | | them for PCH reading. llvm-svn: 107468
* Provide exception specifications for implicitly-declared default constructors.Douglas Gregor2010-07-011-1/+2
| | | | llvm-svn: 107437
* Provide exception specifications for implicitly-declared copy constructors.Douglas Gregor2010-07-011-27/+32
| | | | llvm-svn: 107429
* Provide an exception-specification for an implicitly-declaredDouglas Gregor2010-07-011-0/+73
| | | | | | copy-assignment operator. llvm-svn: 107406
* Remove unnecessary ASTContext parameter fromDouglas Gregor2010-07-011-1/+2
| | | | | | CXXRecordDecl::getDestructor(); no functionality change. llvm-svn: 107394
* Added source order to CXXBaseOrMemberInitializer.Abramo Bagnara2010-05-261-7/+8
| | | | llvm-svn: 104712
* Renamed misleading getSourceRange -> getLocalSourceRange and ↵Abramo Bagnara2010-05-201-1/+1
| | | | | | getFullSourceRange -> getSourceRange for TypeLoc. llvm-svn: 104220
* Merged Elaborated and QualifiedName types.Abramo Bagnara2010-05-111-1/+1
| | | | llvm-svn: 103517
* add PCH support for a bunch of C++ Decls, patch byChris Lattner2010-05-071-0/+24
| | | | | | Andrew Sutton! llvm-svn: 103301
* Reimplement code generation for copying fields in theDouglas Gregor2010-05-051-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implicitly-generated copy constructor. Previously, Sema would perform some checking and instantiation to determine which copy constructors, etc., would be called, then CodeGen would attempt to figure out which copy constructor to call... but would get it wrong, or poke at an uninstantiated default argument, or fail in other ways. The new scheme is similar to what we now do for the implicit copy-assignment operator, where Sema performs all of the semantic analysis and builds specific ASTs that look similar to the ASTs we'd get from explicitly writing the copy constructor, so that CodeGen need only do a direct translation. However, it's not quite that simple because one cannot explicit write elementwise copy-construction of an array. So, I've extended CXXBaseOrMemberInitializer to contain a list of indexing variables used to copy-construct the elements. For example, if we have: struct A { A(const A&); }; struct B { A array[2][3]; }; then we generate an implicit copy assignment operator for B that looks something like this: B::B(const B &other) : array[i0][i1](other.array[i0][i1]) { } CodeGen will loop over the invented variables i0 and i1 to visit all elements in the array, so that each element in the destination array will be copy-constructed from the corresponding element in the source array. Of course, if we're dealing with arrays of scalars or class types with trivial copy-assignment operators, we just generate a memcpy rather than a loop. Fixes PR6928, PR5989, and PR6887. Boost.Regex now compiles and passes all of its regression tests. Conspicuously missing from this patch is handling for the exceptional case, where we need to destruct those objects that we have constructed. I'll address that case separately. llvm-svn: 103079
* Complete reimplementation of the synthesis for implicitly-defined copyDouglas Gregor2010-05-011-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | assignment operators. Previously, Sema provided type-checking and template instantiation for copy assignment operators, then CodeGen would synthesize the actual body of the copy constructor. Unfortunately, the two were not in sync, and CodeGen might pick a copy-assignment operator that is different from what Sema chose, leading to strange failures, e.g., link-time failures when CodeGen called a copy-assignment operator that was not instantiation, run-time failures when copy-assignment operators were overloaded for const/non-const references and the wrong one was picked, and run-time failures when by-value copy-assignment operators did not have their arguments properly copy-initialized. This implementation synthesizes the implicitly-defined copy assignment operator bodies in Sema, so that the resulting ASTs encode exactly what CodeGen needs to do; there is no longer any special code in CodeGen to synthesize copy-assignment operators. The synthesis of the body is relatively simple, and we generate one of three different kinds of copy statements for each base or member: - For a class subobject, call the appropriate copy-assignment operator, after overload resolution has determined what that is. - For an array of scalar types or an array of class types that have trivial copy assignment operators, construct a call to __builtin_memcpy. - For an array of class types with non-trivial copy assignment operators, synthesize a (possibly nested!) for loop whose inner statement calls the copy constructor. - For a scalar type, use built-in assignment. This patch fixes at least a few tests cases in Boost.Spirit that were failing because CodeGen picked the wrong copy-assignment operator (leading to link-time failures), and I suspect a number of undiagnosed problems will also go away with this change. Some of the diagnostics we had previously have gotten worse with this change, since we're going through generic code for our type-checking. I will improve this in a subsequent patch. llvm-svn: 102853
* Make the InjectedClassNameType the canonical type of the current instantiationJohn McCall2010-04-271-9/+0
| | | | | | | | | | | | | | | | of a class template or class template partial specialization. That is to say, in template <class T> class A { ... }; or template <class T> class B<const T*> { ... }; make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType when written inside the appropriate context. This allows us to track the current instantiation appropriately even inside AST routines. It also allows us to compute a DeclContext for a type much more efficiently, at some extra cost every time we write a template specialization (which can be optimized, but I've left it simple in this patch). llvm-svn: 102407
* Keep track of the actual storage specifier written on a variable orDouglas Gregor2010-04-191-7/+7
| | | | | | | | function declaration, since it may end up being changed (e.g., "extern" can become "static" if a prior declaration was static). Patch by Enea Zaffanella and Paolo Bolzoni. llvm-svn: 101826
* Have the CXXBaseOrMemberInitializer keep track of whether an initializer ↵Anders Carlsson2010-04-121-2/+2
| | | | | | initializes a virtual base or not. llvm-svn: 101004
* Regularize support for naming conversion functions in using decls.John McCall2010-03-311-13/+34
| | | | llvm-svn: 99979
* When collecting virtual bases it's very important to use the canonical type ↵Anders Carlsson2010-03-291-3/+3
| | | | | | of the base class. Otherwise, we might add the same virtual base class twice if the virtual base is an instantiated template. Fixes PR6251. llvm-svn: 99829
* Fix a nasty bug in the virtual base computation which would lead to us ↵Anders Carlsson2010-03-291-49/+37
| | | | | | initializing virtual bases in the wrong order. llvm-svn: 99806
* Remember declaration scope qualifiers in the AST. Imposes no memory overheadJohn McCall2010-03-151-2/+1
| | | | | | | | | | | on unqualified declarations. Patch by Enea Zaffanella! Minimal adjustments: allocate the ExtInfo nodes with the ASTContext and delete them during Destroy(). I audited a bunch of Destroy methods at the same time, to ensure that the correct teardown was being done. llvm-svn: 98540
* Remember access paths for visible conversion decls.John McCall2010-03-151-108/+121
| | | | llvm-svn: 98539
* Implement basic support for friend types and functions in non-dependentJohn McCall2010-03-121-1/+1
| | | | | | contexts. llvm-svn: 98321
* Split C++ friend declarations into their own header/implementation file.John McCall2010-03-111-22/+0
| | | | | | | | | I'm expecting this portion of the AST to grow and change, and I'd like to be able to do that with minimal recompilation. If this proves unnecessary when access control is fully-implemented, I'll fold the classes back into DeclCXX.h. llvm-svn: 98249
* Create a new InjectedClassNameType to represent bare-word references to the John McCall2010-03-101-5/+10
| | | | | | | | | | | | | injected class name of a class template or class template partial specialization. This is a non-canonical type; the canonical type is still a template specialization type. This becomes the TypeForDecl of the pattern declaration, which cleans up some amount of code (and complicates some other parts, but whatever). Fixes PR6326 and probably a few others, primarily by re-establishing a few invariants about TypeLoc sizes. llvm-svn: 98134
* Eliminate the static map of overridden C++ methods, which was going toDouglas Gregor2010-03-021-34/+3
| | | | | | come back to bite us at some point. llvm-svn: 97607
* Skip dependent virtual base classes; fixes PR6413.Douglas Gregor2010-02-271-3/+4
| | | | llvm-svn: 97291
* Implement semantic analysis for C++ [expr.new]p18-20, which describeDouglas Gregor2010-02-261-1/+7
| | | | | | | | | | how we find the operator delete that matches withe operator new we found in a C++ new-expression. This will also need CodeGen support. On a happy note, we're now a "nans" away from building tramp3d-v4. llvm-svn: 97209
* Perform two more constructor/destructor code-size optimizations:John McCall2010-02-231-2/+2
| | | | | | | | | | | | | | | | 1) emit base destructors as aliases to their unique base class destructors under some careful conditions. This is enabled for the same targets that can support complete-to-base aliases, i.e. not darwin. 2) Emit non-variadic complete constructors for classes with no virtual bases as calls to the base constructor. This is enabled on all targets and in theory can trigger in situations that the alias optimization can't (mostly involving virtual bases, mostly not yet supported). These are bundled together because I didn't think it worthwhile to split them, not because they really need to be. llvm-svn: 96842
* Remove another redundant ASTContext parameterDouglas Gregor2010-02-111-2/+3
| | | | llvm-svn: 95843
* Ensure that a operator delete overload is rocognized regardless of cv-quals.Chandler Carruth2010-02-081-1/+2
| | | | llvm-svn: 95553
* Extract a common structure for holding information about the definitionJohn McCall2010-02-041-35/+43
| | | | | | | | of a C++ record. Exposed a lot of problems where various routines were silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order) when presented with a non-definition. Also cuts down on memory usage. llvm-svn: 95330
* Rework base and member initialization in constructors, with severalDouglas Gregor2010-01-311-25/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (necessarily simultaneous) changes: - CXXBaseOrMemberInitializer now contains only a single initializer rather than a set of initialiation arguments + a constructor. The single initializer covers all aspects of initialization, including constructor calls as necessary but also cleanup of temporaries created by the initializer (which we never handled before!). - Rework + simplify code generation for CXXBaseOrMemberInitializers, since we can now just emit the initializer as an initializer. - Switched base and member initialization over to the new initialization code (InitializationSequence), so that it - Improved diagnostics for the new initialization code when initializing bases and members, to match the diagnostics produced by the previous (special-purpose) code. - Simplify the representation of type-checked constructor initializers in templates; instead of keeping the fully-type-checked AST, which is rather hard to undo at template instantiation time, throw away the type-checked AST and store the raw expressions in the AST. This simplifies instantiation, but loses a little but of information in the AST. - When type-checking implicit base or member initializers within a dependent context, don't add the generated initializers into the AST, because they'll look like they were explicit. - Record in CXXConstructExpr when the constructor call is to initialize a base class, so that CodeGen does not have to infer it from context. This ensures that we call the right kind of constructor. There are also a few "opportunity" fixes here that were needed to not regress, for example: - Diagnose default-initialization of a const-qualified class that does not have a user-declared default constructor. We had this diagnostic specifically for bases and members, but missed it for variables. That's fixed now. - When defining the implicit constructors, destructor, and copy-assignment operator, set the CurContext to that constructor when we're defining the body. llvm-svn: 94952
* Add an assert to make sure that we don't try to mess with overridden methods ↵Anders Carlsson2010-01-301-1/+3
| | | | | | for class templates. llvm-svn: 94907
* Give UnresolvedSet the ability to store access specifiers for each declaration.John McCall2010-01-201-5/+7
| | | | | | | Change LookupResult to use UnresolvedSet. Also extract UnresolvedSet into its own header and make it templated over an inline capacity. llvm-svn: 93959
* When qualified lookup into the current instantiation fails (because itDouglas Gregor2010-01-141-0/+13
| | | | | | | | finds nothing), and the current instantiation has dependent base classes, treat the qualified lookup as if it referred to an unknown specialization. Fixes PR6031. llvm-svn: 93433
* Improve key-function computation for templates. In particular:Douglas Gregor2010-01-051-15/+7
| | | | | | | | | | | | | | | | - All classes can have a key function; templates don't change that. non-template classes when computing the key function. - We always mark all of the virtual member functions of class template instantiations. - The vtable for an instantiation of a class template has weak linkage. We could probably use available_externally linkage for vtables of classes instantiated by explicit instantiation declarations (extern templates), but GCC doesn't do this and I'm not 100% that the ABI permits it. llvm-svn: 92753
* Eliminate the ASTContext argument to CXXConstructorDecl::isCopyConstructor, ↵Douglas Gregor2009-12-221-5/+5
| | | | | | since the context is available in the Decl llvm-svn: 91862
* Patch over yet more problems with friend declarations which were provokingJohn McCall2009-12-171-1/+5
| | | | | | | problems on LLVM-Code-Syntax. This proved remarkably easy to "fix" once I settled on how I was going to approach it. llvm-svn: 91633
* getTemplateSpecializationKind should be const.Anders Carlsson2009-12-071-2/+2
| | | | llvm-svn: 90750
* DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated ↵John McCall2009-12-071-11/+11
| | | | | | | | | | | | | | | | | | | | | variables, but the results are imperfect. For posterity, I did: cat <<EOF > $cmdfile s/DeclaratorInfo/TypeSourceInfo/g s/DInfo/TInfo/g s/TypeTypeSourceInfo/TypeSourceInfo/g s/SourceTypeSourceInfo/TypeSourceInfo/g EOF find lib -name '*.cpp' -not -path 'lib/Parse/*' -exec sed -i '' -f $cmdfile '{}' \; find lib -name '*.h' -exec sed -i '' -f $cmdfile '{}' \; find include -name '*.h' -not -path 'include/clang/Parse/*' -not -path 'include/clang/Basic/*' -exec sed -i '' -f $cmdfile '{}' \; llvm-svn: 90743
* Move helper onto CXXMethodDecl.Eli Friedman2009-12-061-0/+19
| | | | llvm-svn: 90716
* Make sure that overridden method decls are always canonical.Anders Carlsson2009-12-041-0/+2
| | | | llvm-svn: 90542
* A new helper function to set various bits in the class whenFariborz Jahanian2009-12-031-0/+12
| | | | | | | a new virtual function is declared/instantiated. it is used in couple of places. llvm-svn: 90470
* Improve source location information for C++ member initializers in aDouglas Gregor2009-12-021-22/+56
| | | | | | | constructor, by keeping the DeclaratorInfo* rather than just the type and a single location. llvm-svn: 90355
* In Sema, whenever we think that a function is going to cause a vtable to be ↵Anders Carlsson2009-12-021-3/+2
| | | | | | generated, we mark any virtual implicit member functions as referenced. llvm-svn: 90327
* r90313, in which OverloadedFunctionDecl is removed and never spoken of again.John McCall2009-12-021-58/+0
| | | | llvm-svn: 90313
OpenPOWER on IntegriCloud