summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/special/class.dtor
Commit message (Collapse)AuthorAgeFilesLines
* [cxx2a] P0641R2: (Some) type mismatches on defaulted functions onlyRichard Smith2018-09-281-1/+1
| | | | | | | | | | | | | | | | render the function deleted instead of rendering the program ill-formed. This change also adds an enabled-by-default warning for the case where an explicitly-defaulted special member function of a non-template class is implicitly deleted by the type checking rules. (This fires either due to this language change or due to pre-C++20 reasons for the member being implicitly deleted). I've tested this on a large codebase and found only bugs (where the program means something that's clearly different from what the programmer intended), so this is enabled by default, but we should revisit this if there are problems with this being enabled by default. llvm-svn: 343285
* Fix tracking of whether a destructor would be deleted.Richard Smith2017-09-221-0/+21
| | | | | | | | | | I've been unable to find any cases whose behavior is actually changed by this, but only because an implicitly deleted destructor also results in it being impossible to have a trivial (non-deleted) copy constructor, which the place where this really matters (choosing whether to pass a class in registers) happens to also check. llvm-svn: 313948
* [Sema] Improve the error diagnostic for dot destructor calls on pointer objectsAlex Lorenz2017-01-201-1/+1
| | | | | | | | | | | | | This commit improves the mismatched destructor type error by detecting when the destructor call has used a '.' instead of a '->' on a pointer to the destructed type. The diagnostic now suggests to use '->' instead of '.', and adds a fixit where appropriate. rdar://28766702 Differential Revision: https://reviews.llvm.org/D25817 llvm-svn: 292615
* Cleanup the handling of noinline function attributes, -fno-inline,Chandler Carruth2016-12-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -fno-inline-functions, -O0, and optnone. These were really, really tangled together: - We used the noinline LLVM attribute for -fno-inline - But not for -fno-inline-functions (breaking LTO) - But we did use it for -finline-hint-functions (yay, LTO is happy!) - But we didn't for -O0 (LTO is sad yet again...) - We had weird structuring of CodeGenOpts with both an inlining enumeration and a boolean. They interacted in weird ways and needlessly. - A *lot* of set smashing went on with setting these, and then got worse when we considered optnone and other inlining-effecting attributes. - A bunch of inline affecting attributes were managed in a completely different place from -fno-inline. - Even with -fno-inline we failed to put the LLVM noinline attribute onto many generated function definitions because they didn't show up as AST-level functions. - If you passed -O0 but -finline-functions we would run the normal inliner pass in LLVM despite it being in the O0 pipeline, which really doesn't make much sense. - Lastly, we used things like '-fno-inline' to manipulate the pass pipeline which forced the pass pipeline to be much more parameterizable than it really needs to be. Instead we can *just* use the optimization level to select a pipeline and control the rest via attributes. Sadly, this causes a bunch of churn in tests because we don't run the optimizer in the tests and check the contents of attribute sets. It would be awesome if attribute sets were a bit more FileCheck friendly, but oh well. I think this is a significant improvement and should remove the semantic need to change what inliner pass we run in order to comply with the requested inlining semantics by relying completely on attributes. It also cleans up tho optnone and related handling a bit. One unfortunate aspect of this is that for generating alwaysinline routines like those in OpenMP we end up removing noinline and then adding alwaysinline. I tried a bunch of other approaches, but because we recompute function attributes from scratch and don't have a declaration here I couldn't find anything substantially cleaner than this. Differential Revision: https://reviews.llvm.org/D28053 llvm-svn: 290398
* When diagnosing that a defaulted function is ill-formed because it would beRichard Smith2016-10-312-2/+2
| | | | | | | implicitly deleted and overrides a non-deleted function, explain why the function is deleted. For PR30844. llvm-svn: 285610
* Re-commit r283722, reverted in r283750, with a fix for a CUDA-specific use ofRichard Smith2016-10-101-3/+16
| | | | | | | | | | | past-the-end iterator. Original commit message: P0035R4: Semantic analysis and code generation for C++17 overaligned allocation. llvm-svn: 283789
* Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned ↵Daniel Jasper2016-10-101-16/+3
| | | | | | | | | | | | allocation." This reverts commit r283722. Breaks: Clang.SemaCUDA.device-var-init.cu Clang.CodeGenCUDA.device-var-init.cu http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/884/ llvm-svn: 283750
* P0035R4: Semantic analysis and code generation for C++17 overalignedRichard Smith2016-10-101-3/+16
| | | | | | allocation. llvm-svn: 283722
* Fix all tests under test/CXX (and test/Analysis) to pass if clang's defaultRichard Smith2016-08-311-3/+15
| | | | | | C++ language standard is not C++98. llvm-svn: 280309
* Unify warnings/errors from "maybe you meant" to "did you mean".Eric Christopher2015-04-021-2/+2
| | | | llvm-svn: 233981
* Don't let virtual calls and dynamic casts call Sema::MarkVTableUsed().Nico Weber2015-01-261-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang currently calls MarkVTableUsed() for classes that get their virtual methods called or that participate in a dynamic_cast. This is unnecessary, since CodeGen only emits vtables when it generates constructor, destructor, and vtt code. (*) Note that Sema::MarkVTableUsed() doesn't cause the emission of a vtable. Its main user-visible effect is that it instantiates virtual member functions of template classes, to make sure that if codegen decides to write a vtable all the entries in the vtable are defined. While this shouldn't change the behavior of codegen (other than being faster), it does make clang more permissive: virtual methods of templates (in particular destructors) end up being instantiated less often. In particular, classes that have members that are smart pointers to incomplete types will now get their implicit virtual destructor instantiated less frequently. For example, this used to not compile but does now compile: template <typename T> struct OwnPtr { ~OwnPtr() { static_assert((sizeof(T) > 0), "TypeMustBeComplete"); } }; class ScriptLoader; struct Base { virtual ~Base(); }; struct Sub : public Base { virtual void someFun() const {} OwnPtr<ScriptLoader> m_loader; }; void f(Sub *s) { s->someFun(); } The more permissive behavior matches both gcc (where this is not often observable, since in practice most things with virtual methods have a key function, and Sema::DefineUsedVTables() skips vtables for classes with key functions) and cl (which is my motivation for this change) – this fixes PR20337. See this issue and the review thread for some discussions about optimizations. This is similar to r213109 in spirit. r225761 was a prerequisite for this change. Various tests relied on "a->f()" marking a's vtable as used (in the sema sense), switch these to just construct a on the stack. This forces instantiation of the implicit constructor, which will mark the vtable as used. (*) The exception is -fapple-kext mode: In this mode, qualified calls to virtual functions (`a->Base::f()`) still go through the vtable, and since the vtable pointer off this doesn't point to Base's vtable, this needs to reference Base's vtable directly. To keep this working, keep referencing the vtable for virtual calls in apple kext mode. llvm-svn: 227073
* [Win32 ABI] Defer operator delete checks until vtable is marked usedHans Wennborg2014-02-241-19/+0
| | | | | | | | | | We were previously checking at every destructor declaration, but that was a bit excessive. Since the deleting destructor is emitted with the vtable, do the check when the vtable is marked used. Differential Revision: http://llvm-reviews.chandlerc.com/D2851 llvm-svn: 202046
* When formatting a C++-only declaration name, enable C++ mode in the formatter'sRichard Smith2014-01-221-1/+1
| | | | | | | | | language options. This is not really ideal -- we should require the right language options to be passed in, or not require language options to format a name -- but it fixes a number of *obviously* wrong formattings. Patch by Olivier Goffart! llvm-svn: 199778
* Remove the -cxx-abi command-line flag.Hans Wennborg2014-01-142-3/+3
| | | | | | | | | | | | | | | This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples, Itanium otherwise. It's no longer possible to do weird combinations. To be able to run a test with a specific ABI without constraining it to a specific triple, new substitutions are added to lit: %itanium_abi_triple and %ms_abi_triple can be used to get the current target triple adjusted to the desired ABI. For example, if the test suite is running with the i686-pc-win32 target, %itanium_abi_triple will expand to i686-pc-mingw32. Differential Revision: http://llvm-reviews.chandlerc.com/D2545 llvm-svn: 199250
* Update tests in preparation for using the MS ABI for Win32 targetsHans Wennborg2014-01-132-2/+28
| | | | | | | | | | In preparation for making the Win32 triple imply MS ABI mode, make all tests pass in this mode, or make them use the Itanium mode explicitly. Differential Revision: http://llvm-reviews.chandlerc.com/D2401 llvm-svn: 199130
* If a defaulted special member is implicitly deleted, check whether it'sRichard Smith2013-04-021-2/+3
| | | | | | | overriding a non-deleted virtual function. The existing check for this doesn't catch this case, because it fires before we mark the method as deleted. llvm-svn: 178563
* Try to get buildbots to pass these tests.Bill Wendling2013-02-211-1/+1
| | | | llvm-svn: 175784
* Attempt to clean up tests for non-X86 platforms.Bill Wendling2013-02-201-6/+3
| | | | llvm-svn: 175652
* Remove target-specific features.Bill Wendling2013-02-201-3/+3
| | | | llvm-svn: 175610
* Modify the tests to use attribute group references instead of listing theBill Wendling2013-02-201-2/+7
| | | | | | function attributes. llvm-svn: 175606
* Rework implementation of DR1492: Apply the resolution to operator delete too,Richard Smith2012-10-201-2/+2
| | | | | | | | | | | | 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
* Prior to adding the new "expected-no-diagnostics" directive to ↵Andy Gibbs2012-10-191-0/+1
| | | | | | VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive. llvm-svn: 166280
* DR1492: In a definition of a destructor, the exception specification must beRichard Smith2012-10-162-1/+18
| | | | | | explicitly specified iff it was specified in the declaration. llvm-svn: 166071
* [class.copy]p23: Fix an assertion caused by incorrect argument numbering in aRichard Smith2012-04-291-4/+4
| | | | | | | diagnostic, add a test for this paragraph, and tighten up the diagnostic wording a little. llvm-svn: 155784
* Finish PR10217: Ensure we say that a special member was implicitly, notRichard Smith2012-04-021-5/+5
| | | | | | explicitly, deleted in all relevant cases, and explain why. llvm-svn: 153894
* PR10217: Provide diagnostics explaining why an implicitly-deleted specialRichard Smith2012-03-301-27/+28
| | | | | | member function is deleted. llvm-svn: 153773
* Ensure that we delete destructors in the right cases. Specifically:Richard Smith2012-02-261-0/+103
| | | | | | | | | | | | | | - variant members with nontrivial destructors make the containing class's destructor deleted - check for a virtual destructor after checking for overridden methods in the base class(es) - check for an inaccessible operator delete for a class with a virtual destructor. Do not try to call an anonymous union field's destructor from the destructor of the containing class. llvm-svn: 151483
* Support decltype in pseudo destructors and dependent destructor calls.David Blaikie2011-12-161-5/+18
| | | | | | Reviewed by Eli Friedman. llvm-svn: 146738
* Fix/test decltype dtor calls with invalid base expression.David Blaikie2011-12-121-0/+1
| | | | llvm-svn: 146354
* Decltype in non-pseudo (& non-dependent) dtor calls.David Blaikie2011-12-081-0/+25
| | | | llvm-svn: 146155
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-132-2/+2
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* Start fixing up clang tests to work on the clang-native-arm-cortex-a9 builder.Eli Friedman2011-06-061-10/+10
| | | | llvm-svn: 132691
* Fix PR9941 for out-of-line template destructors too.Sebastian Redl2011-05-201-0/+6
| | | | llvm-svn: 131722
* Fix PR9941 again, this time for templates.Sebastian Redl2011-05-191-0/+29
| | | | llvm-svn: 131640
* Reapply r121528, fixing PR9941 by delaying the exception specification check ↵Sebastian Redl2011-05-191-0/+142
| | | | | | for destructors until the class is complete and destructors have been adjusted. llvm-svn: 131632
* Revert r121528 as it breaks a simple testcase, which leads to, amongAlexis Hunt2011-05-181-127/+0
| | | | | | other things, libcxx not building. llvm-svn: 131573
* Implement implicit exception specifications of destructors.Sebastian Redl2011-05-181-0/+127
| | | | llvm-svn: 131528
* Rvalue references for *this: Douglas Gregor2011-01-261-0/+10
| | | | | | | | | | | | - Add ref-qualifiers to the type system; they are part of the canonical type. Print & profile ref-qualifiers - Translate the ref-qualifier from the Declarator chunk for functions to the function type. - Diagnose mis-uses of ref-qualifiers w.r.t. static member functions, free functions, constructors, destructors, etc. - Add serialization and deserialization of ref-qualifiers. llvm-svn: 124281
* Add a test case for P%7346, which was fixed by not doing the operatorJohn McCall2010-08-041-0/+13
| | | | | | delete lookup until the end of the class definition. llvm-svn: 110176
* Only look up an 'operator delete' on the definition of a destructor, not onJohn McCall2010-08-041-1/+25
| | | | | | a declaration. llvm-svn: 110175
* Look through using declarations when deciding whether to use an operatorJohn McCall2010-08-041-0/+48
| | | | | | | | delete for a virtual destructor. Diagnose ambiguities. Fixes PR7803. llvm-svn: 110173
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Pretend destructors are const and volatile. This allows calling them with ↵Sebastian Redl2009-11-181-0/+7
const and/or volatile objects. Fixes PR5548. llvm-svn: 89244
OpenPOWER on IntegriCloud