summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add the TypeSourceInfo for the lambda call operator to the lambda'sEli Friedman2012-09-191-2/+3
| | | | | | | | definition info; it needs to be there because the mangler needs to access it before we're finished defining the lambda class. PR12808. llvm-svn: 164186
* Normalize line endings of r163013 (part 2).Joao Matos2012-08-311-16/+16
| | | | llvm-svn: 163032
* Improved MSVC __interface support by adding first class support for it, ↵Joao Matos2012-08-311-14/+16
| | | | | | instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins. llvm-svn: 163013
* [analyzer] Correctly devirtualize virtual method calls in constructors.Jordan Rose2012-08-151-3/+10
| | | | | | | | | This is the other half of C++11 [class.cdtor]p4 (the destructor side was added in r161915). This also fixes an issue with post-call checks where the 'this' value was already being cleaned out of the state, thus being omitted from a reconstructed CXXConstructorCall. llvm-svn: 161981
* Fix ambiguity detection in GetBestOverloadCandidateSimple.Benjamin Kramer2012-07-301-2/+2
| | | | | | | | | | When performing the simplistic overload resolution for single-argument methods, don't check the best overload for ambiguity with itself when the best overload doesn't happen to be the first one. Fixes PR13480. llvm-svn: 160961
* When we have an Objective-C object with non-trivial lifetime in aDouglas Gregor2012-07-231-3/+6
| | | | | | | | structor class under ARC, that struct/class does not have a trivial move constructor or move assignment operator. Fixes the rest of <rdar://problem/11738725>. llvm-svn: 160615
* Stop instantiating a class if we hit a static_assert failure. Also, if theRichard Smith2012-07-111-3/+5
| | | | | | | static_assert fails when parsing the template, don't diagnose it again on every instantiation. llvm-svn: 160088
* CXXRecordDecl: Split getBases/getVBases into a slow and a fast path.Benjamin Kramer2012-07-041-0/+8
| | | | | | | This avoids costly computation of getASTContext() and drops the header dependency from DeclCXX.h to ASTContext.h. llvm-svn: 159716
* Fix a crash I introduced in r159212.Rafael Espindola2012-06-271-1/+1
| | | | llvm-svn: 159279
* During codegen of a virtual call we would extract any casts in the expressionRafael Espindola2012-06-261-0/+49
| | | | | | | | to see if we had an underlying final class or method, but we would then use the cast type to do the call, resulting in a direct call to the wrong method. llvm-svn: 159212
* Documentation cleanup: Made a parameter name in a \param command match the codeJames Dennett2012-06-151-1/+1
| | | | llvm-svn: 158564
* Remove CXXRecordDecl flags which are unused after r158289.Richard Smith2012-06-101-70/+6
| | | | | | | | | | | | | | | | | | | | | We need an efficient mechanism to determine whether a defaulted default constructor is constexpr, in order to determine whether a class is a literal type, so keep the incrementally-built form on CXXRecordDecl. Remove the on-demand computation of same, so that we only have one method for determining whether a default constructor is constexpr. This doesn't affect correctness, since default constructor lookup is much simpler than selecting a constructor for copying or moving. We don't need a corresponding mechanism for defaulted copy or move constructors, since they can't affect whether a type is a literal type. Conversely, checking whether such functions are constexpr can require non-trivial effort, so we defer such checks until the copy or move constructor is required. Thus we now only compute whether a copy or move constructor is constexpr on demand, and only compute whether a default constructor is constexpr in advance. This is unfortunate, but seems like the best solution. llvm-svn: 158290
* PR13051: If a constructor is explicitly defaulted, it isn't marked as beingRichard Smith2012-06-081-0/+12
| | | | | | | | | | | | constexpr until we get to the end of the class definition. When that happens, be sure to remember that the class actually does have a constexpr constructor. This is a stopgap solution, which still doesn't cover the case of a class with multiple copy constructors (only some of which are constexpr). We should be performing constructor lookup when implicitly defining a constructor in order to determine whether all constructors it invokes are constexpr. llvm-svn: 158228
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-4/+4
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* A non-explicit constructor template with a second parameter that is aDouglas Gregor2012-06-051-1/+3
| | | | | | parameter pack is a converting constructor. Fixes PR13003. llvm-svn: 158040
* A union can have a constexpr defaulted default constructor, if it has anRichard Smith2012-05-071-5/+8
| | | | | | | | | in-class initializer for one of its fields. Value-initialization of such a type should use the in-class initializer! The former was just a bug, the latter is a (reported) standard defect. llvm-svn: 156274
* A conversion operator in a base class shouldn't hide another conversion operatorRichard Smith2012-05-061-2/+4
| | | | | | in the same class, even if they convert to the same type. Fixes PR12712. llvm-svn: 156247
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-4/+4
| | | | | | | | | | | | | filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-3/+3
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Make sure the accessors for overridden methods don't return inherited ↵Eli Friedman2012-03-101-4/+9
| | | | | | constructors. Fixes PR12219. llvm-svn: 152470
* Teach CXXRecordDecl::hasIrrelevantDestructor to check the base classes andRichard Smith2012-02-251-2/+10
| | | | | | | | | data members for deleted or user-provided destructors. Now it's computed in advance, serialize it, and in passing fix all the other record DefinitionData flags whose serialization was missing. llvm-svn: 151441
* Generate an AST for the conversion from a lambda closure type to aDouglas Gregor2012-02-221-10/+0
| | | | | | | | | | | | | | | block pointer that returns a block literal which captures (by copy) the lambda closure itself. Some aspects of the block literal are left unspecified, namely the capture variable (which doesn't actually exist) and the body (which will be filled in by IRgen because it can't be written as an AST). Because we're switching to this model, this patch also eliminates tracking the copy-initialization expression for the block capture of the conversion function, since that information is now embedded in the synthesized block literal. -1 side tables FTW. llvm-svn: 151131
* Improve our handling of lambda expressions that occur within defaultDouglas Gregor2012-02-211-2/+2
| | | | | | | | | | | | | | | | | | | arguments. There are two aspects to this: - Make sure that when marking the declarations referenced in a default argument, we don't try to mark local variables, both because it's a waste of time and because the semantics are wrong: we're not in a place where we could capture these variables again even if it did make sense. - When a lambda expression occurs in a default argument of a function template, make sure that the corresponding closure type is considered dependent, so that it will get properly instantiated. The second bit is a bit of a hack; to fix it properly, we may have to rearchitect our handling of default arguments, parsing them only after creating the function definition. However, I'd like to separate that work from the lambdas work. llvm-svn: 151076
* Rework the Sema/AST/IRgen dance for the lambda closure type'sDouglas Gregor2012-02-171-0/+6
| | | | | | | | | | | | | | | | | | | | conversion to function pointer. Rather than having IRgen synthesize the body of this function, we instead introduce a static member function "__invoke" with the same signature as the lambda's operator() in the AST. Sema then generates a body for the conversion to function pointer which simply returns the address of __invoke. This approach makes it easier to evaluate a call to the conversion function as a constant, makes the linkage of the __invoke function follow the normal rules for member functions, and may make life easier down the road if we ever want to constexpr'ify some of lambdas. Note that IR generation is responsible for filling in the body of __invoke (Sema just adds a dummy body), because the body can't generally be expressed in C++. Eli, please review! llvm-svn: 150783
* 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
* Split the storage of lambda information between the LambdaExpr and theDouglas Gregor2012-02-131-51/+1
| | | | | | | | | | | | 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-131-1/+20
| | | | | | | synthesize a by-copy captured array in a lambda. This information will be needed by IR generation. llvm-svn: 150396
* Move the storage of lambda captures and capture initializers fromDouglas Gregor2012-02-131-11/+42
| | | | | | | | 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-131-2/+2
| | | | | | | | | | | | | | | | | | | | 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
* const-qualify CXXRecordDecl::getCaptureFields.Eli Friedman2012-02-111-1/+1
| | | | llvm-svn: 150284
* 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
* CWG issue 1405: mutable members are allowed in literal types, but can't undergoRichard Smith2012-02-091-5/+1
| | | | | | lvalue-to-rvalue conversions in constant expressions. llvm-svn: 150145
* Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer2012-02-071-1/+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
* Move various diagnostic operator<< overloads out of line and remove includes ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | | of Diagnostic.h. Fix all the files that depended on transitive includes of Diagnostic.h. With this patch in place changing a diagnostic no longer requires a full rebuild of the StaticAnalyzer. llvm-svn: 149781
* constexpr:Richard Smith2012-02-021-0/+5
| | | | | | | * support the gcc __builtin_constant_p() ? ... : ... folding hack in C++11 * check for unspecified values in pointer comparisons and pointer subtractions llvm-svn: 149578
* Remove redundant checks in CXXRecordDecl::isCLike(), as suggested by Sebastian.Argyrios Kyrtzidis2012-02-011-5/+1
| | | | llvm-svn: 149476
* Change HasMutableFields to HasOnlyCMembers and consider that a tag insideArgyrios Kyrtzidis2012-01-261-4/+7
| | | | | | another tag does not break C-like-ness. rdar://10756831 llvm-svn: 149071
* In CXXRecordDecl::isCLike(), also check for PODness.Argyrios Kyrtzidis2012-01-241-1/+2
| | | | llvm-svn: 148765
* Introduce CXXRecordDecl::isCLike() that is true if the class is C-like,Argyrios Kyrtzidis2012-01-231-1/+17
| | | | | | | | | without C++-specific features. Use it to set the language to C++ when indexing non-C-like structs. rdar://10732579 llvm-svn: 148708
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-171-1/+1
| | | | | | This allows -Wswitch-enum to find switches that need updating when these enums are modified. llvm-svn: 148281
* De-virtualize getPreviousDecl() and getMostRecentDecl() when we knowDouglas Gregor2012-01-141-4/+4
| | | | | | | | | | | | we have a redeclarable type, and only use the new virtual versions (getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have that type information. This keeps us from penalizing users with strict type information (and is the moral equivalent of a "final" method). Plus, settle on the names getPreviousDecl() and getMostRecentDecl() throughout. llvm-svn: 148187
* constexpr: fix typo resulting in move constructors sometimes not beingRichard Smith2012-01-111-2/+2
| | | | | | implicitly marked constexpr when they should be. llvm-svn: 147955
* Pack UsingDecl more.Benjamin Kramer2012-01-071-6/+7
| | | | | | 88 -> 80 bytes on x86_64. llvm-svn: 147736
* Switch NamespaceDecl from its own hand-rolled redeclaration chain overDouglas Gregor2012-01-071-9/+19
| | | | | | | | | | | | to Redeclarable<NamespaceDecl>, so that we benefit from the improveed redeclaration deserialization and merging logic provided by Redeclarable<T>. Otherwise, no functionality change. As a drive-by fix, collapse the "inline" bit into the low bit of the original namespace/anonymous namespace, saving 8 bytes per NamespaceDecl on x86_64. llvm-svn: 147729
* More lambda work: semantic analysis of capturing 'this'. It's a bit ↵Eli Friedman2012-01-071-2/+2
| | | | | | complicated, but we have to be careful about when exactly captures are marked given PotentiallyPotentiallyEvaluated contexts. (Actually, it's not 100% correct yet, but it's close enough for the moment.) llvm-svn: 147723
* When creating declarations that are deserialized from an module file,Douglas Gregor2012-01-051-12/+108
| | | | | | | go through a central allocation routine Decl::AllocateDeserializedDecl(). No actual functionality change (yet). llvm-svn: 147614
* PR11614: Mark defaulted special constructors as constexpr if their implicitRichard Smith2011-12-221-9/+109
| | | | | | definition would satisfy the constexpr requirements. llvm-svn: 147128
* Unweaken vtables as per ↵David Blaikie2011-12-201-0/+26
| | | | | | http://llvm.org/docs/CodingStandards.html#ll_virtual_anch llvm-svn: 146959
* When we notice that a member function is defined with "= delete" or "=Douglas Gregor2011-11-071-5/+5
| | | | | | | | | | | | default", make a note of which is used when creating the initial declaration. Previously, we would wait until later to handle default/delete as a definition, but this is too late: when adding the declaration, we already treated the declaration as "user-provided" when in fact it was merely "user-declared". Fixes PR10861 and PR10442, along with a bunch of FIXMEs. llvm-svn: 144011
* Rework the AST for the initializer of a delegating constructor, soDouglas Gregor2011-11-011-10/+23
| | | | | | | | | that it retains source location information for the type. Aside from general goodness (being able to walk the types described in that information), we now have a proper representation for dependent delegating constructors. Fixes PR10457 (for real). llvm-svn: 143410
OpenPOWER on IntegriCloud