summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* PR14558: Compute triviality of special members (etc) at the end of the classRichard Smith2012-12-111-85/+109
| | | | | | | | | definition, rather than at the end of the definition of the set of nested classes. We still defer checking of the user-specified exception specification to the end of the nesting -- we can't check that until we've parsed the in-class initializers for non-static data members. llvm-svn: 169805
* Virtual method overrides can no longer have mismatched calling conventions. ↵Aaron Ballman2012-12-091-0/+35
| | | | | | This fixes PR14339. llvm-svn: 169705
* PR14550: If a system header contains a bogus constexpr function definition,Richard Smith2012-12-091-2/+3
| | | | | | don't mark the function as invalid, since we suppress the error. llvm-svn: 169689
* Finish implementing 'selected constructor' rules for triviality in C++11. InRichard Smith2012-12-081-49/+81
| | | | | | | | | | | | | | | | | | | | | | | | the cases where we can't determine whether special members would be trivial while building the class, we eagerly declare those special members. The impact of this is bounded, since it does not trigger implicit declarations of special members in classes which merely *use* those classes. In order to determine whether we need to apply this rule, we also need to eagerly declare move operations and destructors in cases where they might be deleted. If a move operation were supposed to be deleted, it would instead be suppressed, and we could need overload resolution to determine if we fall back to a trivial copy operation. If a destructor were implicitly deleted, it would cause the move constructor of any derived classes to be suppressed. As discussed on cxx-abi-dev, C++11's selected constructor rules are also retroactively applied as a defect resolution in C++03 mode, in order to identify that class B has a non-trivial copy constructor (since it calls A's constructor template, not A's copy constructor): struct A { template<typename T> A(T &); }; struct B { mutable A a; }; llvm-svn: 169673
* Remove some remnants of the assumption that there is at most one of eachRichard Smith2012-12-081-2/+18
| | | | | | flavour of special member. llvm-svn: 169670
* Properly compute triviality for explicitly-defaulted or deleted special members.Richard Smith2012-12-081-104/+478
| | | | | | | | | | | | | | Remove pre-standard restriction on explicitly-defaulted copy constructors with 'incorrect' parameter types, and instead just make those special members non-trivial as the standard requires. This required making CXXRecordDecl correctly handle classes which have both a trivial and a non-trivial special member of the same kind. This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the new triviality computation technology. llvm-svn: 169667
* Per [dcl.fct.def.default]p1, don't allow variadic special members to be ↵Richard Smith2012-12-071-0/+4
| | | | | | defaulted. llvm-svn: 169574
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-9/+9
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Consistently use 'needsImplicit<special member>' to determine whether we needRichard Smith2012-12-011-5/+9
| | | | | | | an implicit special member, rather than sometimes using '!hasDeclared<special member>'. No functionality change. llvm-svn: 169075
* The declaration of a special member can require overload resolution to beRichard Smith2012-11-291-0/+54
| | | | | | | | | | | performed, to determine whether that special member is deleted or constexpr. That overload resolution process can in turn trigger the instantiation of a template, which can do anything, including triggering the declaration of that very same special member function. When this happens, do not try to recursively declare the special member -- that's impossible. Instead, only try to realise the truth. There is no special member. llvm-svn: 168847
* Store on the CXXRecordDecl whether the class has, or would have, a copyRichard Smith2012-11-281-141/+4
| | | | | | | constructor/assignment operator with a const-qualified parameter type. The prior method for determining this incorrectly used overload resolution. llvm-svn: 168775
* C++ core issue 1344, PR10618: promote "addition of default argument makes thisRichard Smith2012-11-281-9/+16
| | | | | | | | | | | | a special member" diagnostic from warning to error, and fix the cases where it produced diagnostics with incorrect wording. We don't support this as an extension, and we ban it even in C++98 mode. This breaks too much (for instance, the ABI-specified calling convention for a type can change if it acquires a copy constructor through the addition of a default argument). llvm-svn: 168769
* Simplify checking for whether we should implicitly declare special members andRichard Smith2012-11-271-1/+4
| | | | | | add some assertions. No functionality change. llvm-svn: 168725
* A step towards sorting out handling of triviality of special members in C++11.Richard Smith2012-11-161-4/+1
| | | | | | | | | | | | | | Separate out the notions of 'has a trivial special member' and 'has a non-trivial special member', and use them appropriately. These are not opposites of one another (there might be no special member, or in C++11 there might be a trivial one and a non-trivial one). The CXXRecordDecl predicates continue to produce incorrect results, but do so in fewer cases now, and they document the cases where they might be wrong. No functionality changes are intended here (they will come when the predicates start producing the right answers...). llvm-svn: 168119
* Teach the uninitialized field warning about anonymous structs and union members.Nick Lewycky2012-11-151-9/+23
| | | | | | Fixes PR14073! llvm-svn: 168031
* Remove another questionable use of hasTrivial*. The relevant thing for thisRichard Smith2012-11-141-93/+114
| | | | | | | test was whether the /selected/ operator= was trivial, not whether the class had any trivial (or any non-trivial) operator=s. llvm-svn: 167897
* Fix some wrong-code bugs in implicitly-defined assignment operators:Richard Smith2012-11-131-35/+43
| | | | | | | - In C++11, perform overload resolution over all assignment operators, rather than just looking for copy/move assignment operators. - Clean up after temporaries produced by operator= immediately, rather than accumulating them until the end of the function. llvm-svn: 167798
* Factor duplicated implicit memcpy call generation code out of copy/moveRichard Smith2012-11-121-200/+69
| | | | | | | | assignment generation. This incidentally avoids reusing the same Expr* across multiple statements in the same object; that was generating slightly broken ASTs, but I couldn't trigger any observable bad behavior, so no test. llvm-svn: 167779
* Rework my implementation of circular-reference finding to not useDouglas Gregor2012-11-101-7/+34
| | | | | | | CXXRecordDecl::forallBases, which does *not* do what I need. Fixes the failure introduced in r167651. llvm-svn: 167668
* Diagnostic circular inheritance involving dependent base classes. WeDouglas Gregor2012-11-101-4/+31
| | | | | | | would have diagnosed this at instantiation time anyway, if only we didn't hang on all of these test cases. Fixes <rdar://problem/12629723> llvm-svn: 167651
* Put the usage-directive inside the nearest namespace or TU decl. We don't wantNick Lewycky2012-11-041-3/+3
| | | | | | | | to have UsingDirectiveDecl inside anything other than those two. No user-visible functionality change. llvm-svn: 167376
* Rework implementation of DR1492: Apply the resolution to operator delete too,Richard Smith2012-10-201-1/+1
| | | | | | | | | | | | since it also has an implicit exception specification. Downgrade the error to an extwarn, since at least for operator delete, system headers like to declare it as 'noexcept' whereas the implicit definition does not have an explicit exception specification. Move the exception specification for user-declared 'operator delete' functions from the type-as-written into the type, to reflect reality and to allow us to detect whether there was an implicit exception spec or not. llvm-svn: 166372
* Handle diamond inheritance in -Woverloaded-virtual.David Blaikie2012-10-191-13/+29
| | | | llvm-svn: 166254
* Fix Objective-C implicit property synthesis for C++ classes so we use valid Eli Friedman2012-10-181-30/+8
| | | | | | | | | | | source locations in places where it is necessary for diagnostics. By itself, this causes assertions, so while I'm here, also fix property synthesis for properties of C++ class type so we use so we properly set up a scope and mark variable declarations. <rdar://problem/12514189>. llvm-svn: 166219
* Fix -Woverloaded-virtual when the using statement refers to a base ↵David Blaikie2012-10-171-1/+6
| | | | | | | | | | | | | | | declaration of a virtual function. GCC and Clang both do not warn on: struct a { virtual void func(); }; struct b: a { virtual void func(); void func(int); }; struct c: b { void func(int); using b::func; }; but if the "using" was using a::func GCC would still remain silent where Clang would warn. This change makes Clang consistent with GCC's existing behavior. llvm-svn: 166154
* Fix typo correction of one qualified name to another.David Blaikie2012-10-121-1/+2
| | | | | | | | | | | | | | When suggesting "foo::bar" as a correction for "fob::bar" we mistakenly replaced only "bar" with "foo::bar" producing "fob::foo::bar" which was broken. This corrects that replacement in as many places as I could find & provides test cases for all those cases I could find a test case for. There are a couple that don't seem to be reachable (one looks entirely dead, the other just doesn't seem to ever get called with a namespace to namespace change). Review by Richard Smith ( http://llvm-reviews.chandlerc.com/D57 ). llvm-svn: 165817
* Fix stack overflow when trying to create an implicit movingArgyrios Kyrtzidis2012-10-101-1/+1
| | | | | | | | constructor with invalid code. rdar://12240916 llvm-svn: 165623
* Workaround for libstdc++4.6 <atomic> bug: make comment more explicit about ↵Richard Smith2012-10-051-2/+7
| | | | | | what's going on, per Sean Silva's suggestion. llvm-svn: 165286
* Egriegious hack to support libstdc++4.6's broken <atomic> header, which definesRichard Smith2012-10-041-24/+41
| | | | | | | | a non-inline namespace, then reopens it as inline to try to add its symbols to the surrounding namespace. In this one special case, permit the namespace to be reopened as inline, and patch up the name lookup tables to match. llvm-svn: 165263
* Add FP_CONTRACT support for clang.Lang Hames2012-10-021-1/+1
| | | | | | | | Clang will now honor the FP_CONTRACT pragma and emit LLVM fmuladd intrinsics for expressions of the form A * B + C (when they occur in a single statement). llvm-svn: 164989
* Fix for r163013 regression and further __interface enhancement.John McCall2012-09-251-4/+59
| | | | | | Patch by Andy Gibbs! llvm-svn: 164590
* Don't produce diagnostics for missing ctor-initializers during templateRichard Smith2012-09-251-1/+5
| | | | | | instantiations if we encountered errors parsing some of the initializers. llvm-svn: 164578
* Make warnings about uninitialized fields include the field name.Hans Wennborg2012-09-211-1/+1
| | | | | | | | | | | This makes the wording more informative, and consistent with the other warnings about uninitialized variables. Also, me and David who reviewed this couldn't figure out why we would need to do a lookup to get the name of the variable; so just print the name directly. llvm-svn: 164366
* Doxygen-ify a comment.Craig Topper2012-09-211-4/+4
| | | | llvm-svn: 164360
* PR13890: Warn on abstract final classes.David Blaikie2012-09-211-0/+5
| | | | llvm-svn: 164359
* Per C++11 [class.friend]p3, the 'friend' keyword must appear first in aRichard Smith2012-09-201-10/+14
| | | | | | non-function friend declaration. Patch by Josh Magee! llvm-svn: 164273
* Warn about self references in in-class initializers.Hans Wennborg2012-09-181-94/+101
| | | | | | | | | | | | | | This makes Clang warn about self references in in-class initializers, for example: struct S { int a = a + 42; }; This basically just moves UninitializedFieldVisitor up a bit in SemaDeclCXX.cpp, and adds a call to it from ActOnCXXInClassMemberInitializer. llvm-svn: 164131
* Don't write uninitialized values even if nobody ever asks for it.Axel Naumann2012-09-171-1/+1
| | | | llvm-svn: 164033
* When diagnosing multiple mem-initializers in a delegating ctor, point to the ↵Richard Smith2012-09-141-4/+3
| | | | | | delegating initializer, not to the first initializer. For good measure, also highlight the other initializer. llvm-svn: 163919
* As we do with base and member initializers in a dependent class, delayDouglas Gregor2012-09-141-1/+5
| | | | | | | | | type checking for non-static data member initializers in a dependent class, because our ASTs lose too much information to when type-checking an initializer. Fixes <rdar://problem/11974632>, although the result is still rather unsatisfactory. llvm-svn: 163871
* Remove redundant semicolons which are null statements.Dmitri Gribenko2012-09-101-1/+1
| | | | llvm-svn: 163546
* Don't try to check override control for invalid member functions. Fixes a ↵Richard Smith2012-09-061-0/+3
| | | | | | crash in a corner case. Patch by Olivier Goffart! llvm-svn: 163337
* Changed the remaining dead asserts to llvm_unreachable.Joao Matos2012-09-011-7/+5
| | | | llvm-svn: 163039
* Normalize line endings of r163013 (part 2).Joao Matos2012-08-311-30/+30
| | | | llvm-svn: 163032
* Improved MSVC __interface support by adding first class support for it, ↵Joao Matos2012-08-311-14/+30
| | | | | | instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins. llvm-svn: 163013
* Change the representation of builtin functions in the ASTEli Friedman2012-08-311-8/+8
| | | | | | | | | (__builtin_* etc.) so that it isn't possible to take their address. Specifically, introduce a new type to represent a reference to a builtin function, and a new cast kind to convert it to a function pointer in the operand of a call. Fixes PR13195. llvm-svn: 162962
* Push ArrayRef through the Expr hierarchy.Benjamin Kramer2012-08-241-5/+3
| | | | | | No functionality change. llvm-svn: 162552
* Now that ASTMultiPtr is nothing more than a array reference, make it a ↵Benjamin Kramer2012-08-231-16/+13
| | | | | | | | MutableArrayRef. This required changing all get() calls to data() and using the simpler constructors. llvm-svn: 162501
* Remove ASTOwningVector, it doesn't own anything and provides no value over ↵Benjamin Kramer2012-08-231-5/+5
| | | | | | SmallVector. llvm-svn: 162492
* Rip out remnants of move semantic emulation and smart pointers in Sema.Benjamin Kramer2012-08-231-20/+20
| | | | | | | These were nops for quite a while and only lead to confusion. ASTMultiPtr now behaves like a proper dumb array reference. llvm-svn: 162475
OpenPOWER on IntegriCloud