summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove unused and undesirable reference from BindingDecl to DecompositionDecl.Richard Smith2016-08-121-3/+2
| | | | llvm-svn: 278448
* P0217R3: Constant expression evaluation for decomposition declarations.Richard Smith2016-08-121-2/+3
| | | | llvm-svn: 278447
* P0217R3: Perform semantic checks and initialization for the bindings in aRichard Smith2016-08-111-0/+12
| | | | | | | decomposition declaration for arrays, aggregate-like structs, tuple-like types, and (as an extension) for complex and vector types. llvm-svn: 278435
* P0217R3: Parsing support and framework for AST representation of C++1zRichard Smith2016-07-221-0/+38
| | | | | | | | | | | decomposition declarations. There are a couple of things in the wording that seem strange here: decomposition declarations are permitted at namespace scope (which we partially support here) and they are permitted as the declaration in a template (which we reject). llvm-svn: 276492
* [ASTMatchers] New forEachOverriden matcher.Clement Courbet2016-07-051-0/+7
| | | | | | Matches methods overridden by the given method. llvm-svn: 274531
* P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991:Richard Smith2016-06-281-35/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace inheriting constructors implementation with new approach, voted into C++ last year as a DR against C++11. Instead of synthesizing a set of derived class constructors for each inherited base class constructor, we make the constructors of the base class visible to constructor lookup in the derived class, using the normal rules for using-declarations. For constructors, UsingShadowDecl now has a ConstructorUsingShadowDecl derived class that tracks the requisite additional information. We create shadow constructors (not found by name lookup) in the derived class to model the actual initialization, and have a new expression node, CXXInheritedCtorInitExpr, to model the initialization of a base class from such a constructor. (This initialization is special because it performs real perfect forwarding of arguments.) In cases where argument forwarding is not possible (for inalloca calls, variadic calls, and calls with callee parameter cleanup), the shadow inheriting constructor is not emitted and instead we directly emit the initialization code into the caller of the inherited constructor. Note that this new model is not perfectly compatible with the old model in some corner cases. In particular: * if B inherits a private constructor from A, and C uses that constructor to construct a B, then we previously required that A befriends B and B befriends C, but the new rules require A to befriend C directly, and * if a derived class has its own constructors (and so its implicit default constructor is suppressed), it may still inherit a default constructor from a base class llvm-svn: 274049
* Revert "[ASTMatchers] New forEachOverriden matcher."Chandler Carruth2016-06-111-7/+0
| | | | | | | This reverts commit r272386. It doesn't compile with MSVC and those bots have been red the entire day as a consequence. llvm-svn: 272453
* [ASTMatchers] New forEachOverriden matcher.Clement Courbet2016-06-101-0/+7
| | | | | | Matches methods overridden by the given method. llvm-svn: 272386
* [MSVC] Support for __unaligned qualifier in functionsAndrey Bokhanko2016-05-261-1/+1
| | | | | | | | | | | | | | | This implements support for MS-specific __unaligned qualifier in functions and makes the following test case both compile and mangle correctly: struct S { void f() __unaligned; }; void S::f() __unaligned { } Differential Revision: http://reviews.llvm.org/D20437 llvm-svn: 270834
* [AST] Cleanup comments regarding CXXRecordDecl::isEmptyDavid Majnemer2016-05-221-8/+11
| | | | | | | | | We were missing references to the standard, some of our home-grown verbiage didn't make any sense. No functional change is intended. llvm-svn: 270353
* PR27754: CXXRecordDecl::data() needs to perform an update even if it's calledRichard Smith2016-05-171-1/+1
| | | | | | on a declaration that already knows the location of the DefinitionData object. llvm-svn: 269858
* Add support for derived class special members hiding functions brought in fromRichard Smith2016-05-131-0/+10
| | | | | | | | | a base class via a using-declaration. If a class has a using-declaration declaring either a constructor or an assignment operator, eagerly declare its special members in case they need to displace a shadow declaration from a using-declaration. llvm-svn: 269398
* P0017R1: In C++1z, an aggregate class can have (public non-virtual) base ↵Richard Smith2016-03-081-5/+20
| | | | | | classes; these are initialized as if they were data members. llvm-svn: 262963
* Fix rejects-valid caused by r261297.Nico Weber2016-02-241-0/+3
| | | | | | | | | | | | | | | | r261297 called hasUserProvidedDefaultConstructor() to check if defining a const object is ok. This is incorrect for this example: struct X { template<typename ...T> X(T...); int n; }; const X x; // formerly OK, now bogus error Instead, track if a class has a defaulted default constructor, and disallow a const object for classes that either have defaulted default constructors or if they need an implicit constructor. Bug report and fix approach by Richard Smith, thanks! llvm-svn: 261770
* Fix SemaTemplate/instantiate-field.cpp after r261297.Nico Weber2016-02-191-1/+1
| | | | | | | | | | | | | | For templates, fields can have incomplete types: template <class T> struct A2 { struct B; B b; }; Don't try to touch the DefinitionData of those fields. llvm-svn: 261301
* Implement the likely resolution of core issue 253.Nico Weber2016-02-191-28/+37
| | | | | | | | | | | | | | | | | | C++11 requires const objects to have a user-provided constructor, even for classes without any fields. DR 253 relaxes this to say "If the implicit default constructor initializes all subobjects, no initializer should be required." clang is currently the only compiler that implements this C++11 rule, and e.g. libstdc++ relies on something like DR 253 to compile in newer versions. This change makes it possible to build code that says `const vector<int> v;' again when using libstdc++5.2 and _GLIBCXX_DEBUG (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284). Fixes PR23381. http://reviews.llvm.org/D16552 llvm-svn: 261297
* [ptr-traits] Move methods manipulating PointerUnions, DenseMap pointerChandler Carruth2015-12-301-0/+28
| | | | | | | | | | | | | | | keys, and PointerIntPairs where the pointee types are incomplete out-of-line to where we have the complete type. This is the standard pattern used throughout the AST library to address the inherently mutually cross referenced nature of the AST. This is part of a series of patches to allow LLVM to check for complete pointee types when computing its pointer traits. This is absolutely necessary to get correct (or reproducible) results for things like how many low bits are guaranteed to be zero. llvm-svn: 256612
* [TrailingObjects] Convert Decl* classes.James Y Knight2015-12-291-4/+3
| | | | | | | | Also remove now-redundant explicit alignment specification on some of the classes converted prior to TrailingObjects automatically ensuring proper alignment. llvm-svn: 256585
* Revert r256399 "[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC"Craig Topper2015-12-251-5/+6
| | | | | | It broke lldb build. llvm-svn: 256403
* [Sema] ArrayRef-ize ActOnBaseSpecifiers. NFCCraig Topper2015-12-241-6/+5
| | | | llvm-svn: 256399
* [AST] Turn the callbacks of lookupInBases and forallBases into a function_refBenjamin Kramer2015-07-251-7/+1
| | | | | | | | | This lets us pass functors (and lambdas) without void * tricks. On the downside we can't pass CXXRecordDecl's Find* members (which are now type safe) to lookupInBases directly, but a lambda trampoline is a small price to pay. No functionality change intended. llvm-svn: 243217
* [modules] When determining the visible module set during templateRichard Smith2015-07-081-3/+3
| | | | | | | instantiation, use the set of modules visible from the template definition, not from whichever declaration the specialization was instantiated from. llvm-svn: 241662
* Update -Winvalid-noreturn to handle destructors better.Richard Trieu2015-05-281-0/+22
| | | | | | | | | | When checking if a function is noreturn, consider a codepath to be noreturn if the path destroys a class and the class destructor, base class destructors, or member field destructors are marked noreturn. Differential Revision: http://reviews.llvm.org/D9454 llvm-svn: 238382
* [modules] Deserialize CXXCtorInitializer list for a constructor lazily.Richard Smith2015-03-241-0/+4
| | | | | | | | | | | | | Previously we'd deserialize the list of mem-initializers for a constructor when we deserialized the declaration of the constructor. That could trigger a significant amount of unnecessary work (pulling in all base classes recursively, for a start) and was causing problems for the modules buildbot due to cyclic deserializations. We now deserialize these on demand. This creates a certain amount of duplication with the handling of CXXBaseSpecifiers; I'll look into reducing that next. llvm-svn: 233052
* [modules] Don't clobber a destructor's operator delete when adding another one;Richard Smith2015-03-101-0/+9
| | | | | | | move the operator delete updating into a separate update record so we can cope with updating another module's destructor's operator delete. llvm-svn: 231735
* Cleanup: remove artificial division between lookup results and const lookupRichard Smith2015-02-211-5/+5
| | | | | | | results. No-one was ever modifying a lookup result, and it would not be reasonable to do so. llvm-svn: 230123
* Revert r167816 and replace it with a proper fix for the issue: do notRichard Smith2015-02-211-3/+2
| | | | | | | invalidate lookup_iterators and lookup_results for some name within a DeclContext if the lookup results for a *different* name change. llvm-svn: 230121
* Update APIs that return a pair of iterators to return an iterator_range instead.Benjamin Kramer2015-02-061-2/+2
| | | | | | Convert uses of those APIs into ranged for loops. NFC. llvm-svn: 228404
* DebugInfo: Correct the debug location of non-static data member initializersDavid Blaikie2015-01-181-3/+3
| | | | | | | | | | This was causing some trouble for otherwise dead code removed in r225085 (reverted in r225361). The location being set for function arguments was leaking out to the call which wasn't setting its own location (so a quality bug turned into a crasher with r225085). Fix this so r225085 can be recommitted. llvm-svn: 226382
* If a non-template constructor instantiated to X(X),John McCall2014-12-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | ignore it during overload resolution when initializing X from a value of type cv X. Previously, our rule here only ignored specializations of constructor templates. That's probably because the standard says that constructors are outright ill-formed if their first parameter is literally X and they're callable with one argument. However, Clang only enforces that prohibition against non-implicit instantiations; I'm not sure why, but it seems to be deliberate. Given that, the most sensible thing to do is to just ignore the "illegal" constructor regardless of where it came from. Also, stop ignoring such constructors silently: print a note explaining why they're being ignored. Fixes <rdar://19199836>. llvm-svn: 224205
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-2/+2
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* Factor code into CXXRecordDecl::getTemplateInstantiationPattern() helperReid Kleckner2014-10-141-0/+38
| | | | | | | | | | | | | | | | | This moves some code from SemaType.cpp's hasVisibleDefinition() into DeclCXX.cpp so that it can be used elsewhere. I found one other instance of code trying to do the same thing, there are probably more. Search for getInstantiatedFrom() to try to find more. No functionality change. Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5783 llvm-svn: 219714
* Fix an assertion failure trying to emit a trivial destructor in ObjC++Ben Langmuir2014-09-261-20/+14
| | | | | | | | | | | | | | | | | | If a base class declares a destructor, we will add the implicit destructor for the subclass in ActOnFields -> AddImplicitlyDeclaredMembersToClass But in Objective C++, we did not compute whether we have a trivial destructor until after that in CXXRecordDecl::completeDefinition() This was leading to a mismatch between the class, which thought it had no trivial destructor, and the CXXDestructorDecl, which considered itself trivial. It turns out the reason we delayed setting this until completeDefinition() was for a warning that has since been removed as part of -Warc-abi, so we just do it eagerly now. llvm-svn: 218520
* [modules] Make NamespaceAliasDecl redeclarable, as it should be. This fixesRichard Smith2014-09-031-2/+13
| | | | | | | merging of namespace aliases across modules and improves source fidelity. Incidentally also fixes PR20816. llvm-svn: 217103
* C++1y is now C++14!Aaron Ballman2014-08-191-1/+1
| | | | | | Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording. llvm-svn: 215982
* Add missing initialization found due to a valgrind false positive.Richard Smith2014-07-211-1/+1
| | | | | | | | This field is never inspected in the object state initialized by this constructor; however, initializing it seems reasonable, since it has a meaningful value. llvm-svn: 213499
* MS ABI: Fix inheritance model calculation in CRTPDavid Majnemer2014-06-131-2/+7
| | | | | | | | | | | | | | | | | CRTP-like patterns involve a class which inherits from another class using itself as a template parameter. However, the base class itself may try to create a pointer-to-member which involves the derived class. This is problematic because we may not have finished parsing the most derived classes' base specifiers yet. It turns out that MSVC simply uses the unspecified inheritance model instead of doing anything fancy. This fixes PR19987. llvm-svn: 210886
* Avoid allocating extra memory to handle the lazy definition data pointer forRichard Smith2014-05-221-3/+3
| | | | | | CXXRecordDecls when modules is enabled. llvm-svn: 209482
* If a declaration is loaded, and then a module import adds a redeclaration, thenRichard Smith2014-05-161-41/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ensure that querying the first declaration for its most recent declaration checks for redeclarations from the imported module. This works as follows: * The 'most recent' pointer on a canonical declaration grows a pointer to the external AST source and a generation number (space- and time-optimized for the case where there is no external source). * Each time the 'most recent' pointer is queried, if it has an external source, we check whether it's up to date, and update it if not. * The ancillary data stored on the canonical declaration is allocated lazily to avoid filling it in for declarations that end up being non-canonical. We'll still perform a redundant (ASTContext) allocation if someone asks for the most recent declaration from a decl before setPreviousDecl is called, but such cases are probably all bugs, and are now easy to find. Some finessing is still in order here -- in particular, we use a very general mechanism for handling the DefinitionData pointer on CXXRecordData, and a more targeted approach would be more compact. Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was addressing only a corner of the full problem space here. That's not covered by this patch. Early performance benchmarks show that this makes no measurable difference to Clang performance without modules enabled (and fixes a major correctness issue with modules enabled). I'll revert if a full performance comparison shows any problems. llvm-svn: 209046
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-56/+65
| | | | llvm-svn: 208517
* Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.Benjamin Kramer2014-05-101-1/+1
| | | | | | | Required pulling LambdaExpr::Capture into its own header. No functionality change. llvm-svn: 208470
* Stop all the Decl classes poking at Redeclarable's data member directly, and ↵Richard Smith2014-05-101-2/+2
| | | | | | make getNextRedeclaration follow the pattern of its friends getPreviousDecl and getMostRecentDecl. llvm-svn: 208467
* Recognize simple cases of trivial explicitly defaulted public dtors as ↵Stephan Tolksdorf2014-03-271-3/+8
| | | | | | | | irrelevant Reviewed in http://llvm-reviews.chandlerc.com/D3190 llvm-svn: 204953
* [C++11] Replacing CXXRecordDecl iterators vbases_begin() and vbases_end() ↵Aaron Ballman2014-03-131-6/+4
| | | | | | with iterator_range vbases(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203808
* [C++11] Replacing CXXRecordDecl iterators bases_begin() and bases_end() with ↵Aaron Ballman2014-03-131-20/+13
| | | | | | iterator_range bases(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203803
* Introduce and use Decl::getAsFunction() to simplify templated function checksAlp Toker2014-01-221-7/+3
| | | | | | | | | | | | | | Lift the getFunctionDecl() utility out of the parser into a general Decl::getAsFunction() and use it to simplify other parts of the implementation. Reduce isFunctionOrFunctionTemplate() to a simple type check that works the same was as the other is* functions and move unwrapping of shadowed decls to callers so it doesn't get run twice. Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer. There's no need to query when we already know the body can't be skipped. llvm-svn: 199794
* PR18232: implement instantiation for class-scope explicit specializations ofRichard Smith2013-12-141-1/+1
| | | | | | class templates (a Microsoft extension). llvm-svn: 197298
* Implement DR1460: fix handling of default initializers in unions; don't allowRichard Smith2013-12-101-4/+19
| | | | | | | | | more than one such initializer in a union, make mem-initializers override default initializers for other union members, handle anonymous unions with anonymous struct members better. Fix a couple of semi-related bugs exposed by the tests for same. llvm-svn: 196892
* Move these virtual methods out of line.Rafael Espindola2013-11-261-2/+10
| | | | llvm-svn: 195767
* Take cv-qualifiers on fields of class type into account when determiningRichard Smith2013-11-251-0/+7
| | | | | | whether a defaulted special member function should be deleted. llvm-svn: 195620
OpenPOWER on IntegriCloud