summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-10/+10
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* [MS Compatibility] Handle cleanups we create for a ctor closureDavid Majnemer2015-06-111-0/+1
| | | | | | This fixes PR23801. llvm-svn: 239503
* Enable DLL attribute propagation on explicit instantiation definitions (PR23770)Hans Wennborg2015-06-091-57/+57
| | | | | | | | This is a follow-up to r225570 which enabled adding DLL attributes when a class template goes from explicit instantiation declaration to explicit instantiation definition. llvm-svn: 239375
* Enable propagation of dll attributes to previously instantiated base class ↵Hans Wennborg2015-06-091-6/+22
| | | | | | | | | | | | | | | templates in some cases It is safe to add a dll attribute if the base class template previously only had an explicit instantiation declaration, or was implicitly instantiated. I both those cases, the members would not have been codegenned yet. In the case of explicit instantiation declaration this is natural, and for implicit instantiations, codegen is deferred (see r225570). This is work towards fixing PR23770. llvm-svn: 239373
* Narrow the -Wunsupported-dll-base-class-template warning.Hans Wennborg2015-06-091-16/+8
| | | | | | | | | | | | | Don't warn about not being able to propagate dll attribute to a base class template when that base already has a different attribute. MSVC doesn't actually try to do this; the first attribute that was propagated takes precedence, so Clang is already doing the right thing and there's no need to warn. (This is a step towards fixing PR21718.) llvm-svn: 239372
* clang-cl: Handle dll attributes in explicit class template specialization ↵Hans Wennborg2015-05-271-18/+18
| | | | | | | | | | definitions (PR23667) Previously, we wouldn't call checkDLLAttribute() after the class template specialization definition if the class template was already instantiated by an explicit class template specialization declaration. llvm-svn: 238266
* [Sema] Don't crash on out-of-line virtual constexpr functionsDavid Majnemer2015-05-221-1/+2
| | | | | | | | | | The method wasn't an overrider but didn't have 'virtual' textually written because our CXXMethodDecl was an out-of-line definition. Make sure we use the canonical decl instead. This fixes PR23629. llvm-svn: 237999
* [modules] Support merging a parsed default function/template argument with ↵Richard Smith2015-05-201-27/+51
| | | | | | an imported but hidden one. llvm-svn: 237814
* Give isCompatibleWithMSVC a better interfaceDavid Majnemer2015-05-111-1/+1
| | | | | | | We now use an enum which maps the marketing name (almost always a year) to the major version number. llvm-svn: 236967
* [MS ABI] Import move assignment operatorsDavid Majnemer2015-05-111-9/+9
| | | | | | | MSVC 2015 changed behavior from 2013; it imports move assignment operators. llvm-svn: 236966
* PR23373: A defaulted union copy constructor that is not trivial must still beRichard Smith2015-04-291-2/+6
| | | | | | emitted as a memcpy. llvm-svn: 236142
* Don't dllimport/export class members with internal linkage (PR23308)Hans Wennborg2015-04-221-0/+3
| | | | | | | | | | For example, a function taking a parameter with internal linkage will itself have internal linkage since it cannot be called outside the translation unit. Differential Revision: http://reviews.llvm.org/D9182 llvm-svn: 235471
* Use the most recent previous decl to check if inline is added after a definitionReid Kleckner2015-04-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | This affects this test case: void foo(); template <typename T> class C { friend inline void foo(); }; inline void foo() {} C<int> c; Here, we instantiate the foo friend decl and add it to foo's redecl chain. However, our previous decl pointer happens to reference the first declaration of foo, which is not marked inline. When we check to see if foo was already defined, we implicitly search all previous decls. We should do the same for the inline check, instead of just checking this particular previous decl. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D8872 llvm-svn: 234374
* Minor simplification: do typo-correction before handling inheritingRichard Smith2015-04-011-20/+24
| | | | | | | constructors, instead of having the typo-correction code also dispatch to the inheriting constructor special case. llvm-svn: 233833
* [Sema] Implement DR777Benjamin Kramer2015-03-271-7/+7
| | | | | | | | A parameter pack after a default argument is now valid. PR23029. llvm-svn: 233377
* [Sema] Diagnose default argument on a parameter pack.Benjamin Kramer2015-03-271-2/+11
| | | | | | | | This is ill-formed (and cannot be used anyways). PR23028. llvm-svn: 233376
* MS ABI: Build C++ default argument exprs for exported template classesReid Kleckner2015-03-171-1/+1
| | | | | | This was an omission from r232229. llvm-svn: 232554
* MS ABI: Delay default constructor closure checking until the outermost class ↵Reid Kleckner2015-03-171-0/+38
| | | | | | | | | | | | | | | | | scope ends Previously, we would error out on this code because the default argument wasn't parsed until the end of Outer: struct __declspec(dllexport) Outer { struct __declspec(dllexport) Inner { Inner(void *p = 0); }; }; Now we do the checking on the closing brace of Outer instead of Inner. llvm-svn: 232519
* Sema: Properly track mangling number/name for linkage for using declsDavid Majnemer2015-03-111-1/+6
| | | | | | | | | | | | Using declarations which are aliases to struct types have their name used as the struct type's name for linkage purposes. Otherwise, make sure to give an anonymous struct defined inside a using declaration a mangling number to disambiguate it from other anonymous structs in the same context. This fixes PR22809. llvm-svn: 231909
* Wrap to 80 columns. No behavior change.Nico Weber2015-03-071-2/+3
| | | | llvm-svn: 231573
* Sema: Caught exception objects should be unqualifiedDavid Majnemer2015-03-031-1/+1
| | | | | | | | The exception object should be unqualified. Using a qualified exception object results in the wrong copy constructor getting called when the catch handler executes. llvm-svn: 231054
* Rework our handling of key functions. We used to track a complete list of allRichard Smith2015-02-281-3/+0
| | | | | | | | | | | | | | dynamic classes in the translation unit and check whether each one's key function is defined when we got to the end of the TU (and when we got to the end of each module). This is really terrible for modules performance, since it causes unnecessary deserialization of every dynamic class in every compilation. We now use a much simpler (and, in a modules build, vastly more efficient) system: when we see an out-of-line definition of a virtual function, we check whether that function was in fact its class's key function. (If so, we need to emit the vtable.) llvm-svn: 230830
* [modules] Properly check whether a declaration is std::initializer_list. ThisRichard Smith2015-02-241-1/+1
| | | | | | | bug is not actually modules-specific, but it's a little tricky to tickle it outside of modules builds, so submitting with the reduced testcase I have. llvm-svn: 230303
* Cleanup: remove artificial division between lookup results and const lookupRichard Smith2015-02-211-1/+1
| | | | | | | results. No-one was ever modifying a lookup result, and it would not be reasonable to do so. llvm-svn: 230123
* Improve diagnostic when failing to synthesize implicit member due to ↵Hans Wennborg2015-02-211-0/+6
| | | | | | | | | | | | | | dllexport (PR22591) This is only a problem in C++03 mode targeting MS ABI (MinGW doesn't export inline methods, and C++11 marks these methods implicitly deleted). Since targeting the MS ABI in pre-C++11 mode is a rare configuration, this will probably not get fixed, but we can at least have a better error message. llvm-svn: 230115
* Don't dllexport inline methods when targeting MinGW.Hans Wennborg2015-02-191-2/+2
| | | | | | | | | MinGW neither imports nor exports such methods. The import bit was committed earlier, in r221154, and this takes care of the export part. This also partially fixes PR22591. llvm-svn: 229922
* FIX PR 18432, default args, friends & late-parsed members.Nathan Sidwell2015-02-191-1/+3
| | | | | | | | | | | | Sema::MergeCXXFunctionDecl: propagate hasUnparsedDefaultArg to new decl. Parser::HandleMemberFunctionDeclDelays: check hasUnparsedDefaultArg flag. Parser::ParseLexedMethodDeclaration: handle inherited unparsed default arg case. llvm-svn: 229852
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-2/+2
| | | | | | requiring the macro. NFC; Clang edition. llvm-svn: 229339
* Code cleanupNathan Sidwell2015-01-301-7/+4
| | | | | | | Parser::ParseLexedMethodDeclaration: Use local var for Param Sema::MergeCXXFunctionDecls: Use hasInheritedDefaultArg llvm-svn: 227577
* Don't let virtual calls and dynamic casts call Sema::MarkVTableUsed().Nico Weber2015-01-261-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* SemaDeclCXX.cpp: Suppress a warning. [-Wunused-variable]NAKAMURA Takumi2015-01-191-0/+1
| | | | llvm-svn: 226441
* PR6037Nathan Sidwell2015-01-191-3/+58
| | | | | | Warn on inaccessible direct base llvm-svn: 226423
* Wrap to 80 columns. No behavior change.Nico Weber2015-01-161-1/+2
| | | | llvm-svn: 226320
* Warn about dllexported explicit class template instantiation declarations ↵Hans Wennborg2015-01-151-3/+8
| | | | | | | | | | | | | | | (PR22035) Clang would previously become confused and crash here. It does not make a lot of sense to export these, so warning seems appropriate. MSVC will export some member functions for this kind of specializations, whereas MinGW ignores the dllexport-edness. The latter behaviour seems better. Differential Revision: http://reviews.llvm.org/D6984 llvm-svn: 226208
* Remove ASTConsumer::HandleVTable()'s bool parameter.Nico Weber2015-01-151-1/+2
| | | | | | | | | | | Sema calls HandleVTable() with a bool parameter which is then threaded through three layers. The only effect of this bool is an early return at the last layer. Instead, remove this parameter and call HandleVTable() only if the bool is true. No intended behavior change. llvm-svn: 226096
* Parse: Don't crash when default argument in typedef consists of sole '='David Majnemer2015-01-131-2/+7
| | | | | | | | We'd crash trying to make the SourceRange for the tokens we'd like to highlight. Don't assume there is more than one token makes up the default argument. llvm-svn: 225774
* Fix grammar-o in comment.Nico Weber2015-01-061-1/+1
| | | | llvm-svn: 225324
* Sema: Variable templates cannot be static bitfield membersDavid Majnemer2014-12-281-1/+1
| | | | | | | We correctly forbid variables but not variable templates. Diagnose this case instead of crashing. llvm-svn: 224905
* PR21969: Improve diagnostics for a conversion function that has any pieces of aRichard Smith2014-12-191-4/+88
| | | | | | declared return type (including a trailing-return-type in C++14). llvm-svn: 224561
* Sema: Don't dyn_cast a null pointer in CheckUsingDeclQualifierDavid Majnemer2014-12-171-1/+1
| | | | | | | | | This code was written with the intent that a pointer could be null but we dyn_cast'd it anyway. Change the dyn_cast to a dyn_cast_or_null. This fixes PR21933. llvm-svn: 224411
* DR1684: a constexpr member function need not be a member of a literal class ↵Richard Smith2014-12-161-36/+0
| | | | | | type. llvm-svn: 224388
* Clarify the code in checkDLLAttribute()Hans Wennborg2014-12-161-7/+12
| | | | | | | | Update the comments to make it more clear what's going on, and address Richard's comments from PR21718. This doesn't fix that bug, but hopefully makes the code easier to understand. llvm-svn: 224303
* Parse: MS property members cannot have an in-class initializerDavid Majnemer2014-12-131-4/+5
| | | | | | | | | We would crash trying to treat a property member as a field. These shoudl be forbidden anyway, reject programs which contain them. This fixes PR21840. llvm-svn: 224193
* Handle possible TypoExprs in member initializers.Kaelyn Takata2014-12-081-0/+5
| | | | | | | Includes a new test case since none of the existing tests were hitting this code path. llvm-svn: 223705
* When checking for uninitialized values, do not confuse "std::move" with everyRichard Trieu2014-11-271-1/+2
| | | | | | other function named "move". llvm-svn: 222863
* Fix line endingsNico Rieck2014-11-241-3/+3
| | | | llvm-svn: 222666
* Delay checking overrides for exception specifications if the overriddenRichard Smith2014-11-221-14/+8
| | | | | | specification has not yet been parsed. llvm-svn: 222603
* Extend -Wuninitialized to warn when accessing uninitialized base classes in aRichard Trieu2014-11-211-12/+41
| | | | | | constructor. llvm-svn: 222503
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-4/+4
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* Handle use of default member initializers before end of outermost classReid Kleckner2014-11-171-29/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, when we have this situation: struct A { template <typename T> struct B { int m1 = sizeof(A); }; B<int> m2; }; We can't parse m1's initializer eagerly because we need A to be complete. Therefore we wait until the end of A's class scope to parse it. However, we can trigger instantiation of B before the end of A, which will attempt to instantiate the field decls eagerly, and it would build a bad field decl instantiation that said it had an initializer but actually lacked one. Fixed by deferring instantiation of default member initializers until they are needed during constructor analysis. This addresses a long standing FIXME in the code. Fixes PR19195. Reviewed By: rsmith Differential Revision: http://reviews.llvm.org/D5690 llvm-svn: 222192
OpenPOWER on IntegriCloud