summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* [c++1z] Support [[deprecated]] attributes on namespaces. Note that it only ↵Aaron Ballman2014-11-141-2/+11
| | | | | | applies to situations where the namespace is mentioned. Thus, use on anonymous namespaces is diagnosed. llvm-svn: 222054
* Remove some redundant virtual specifiers on overriden functions.David Blaikie2014-11-141-9/+9
| | | | llvm-svn: 222024
* PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith2014-11-131-0/+46
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* Mark TypeDecls used in member initializers as referenced.Nico Weber2014-11-121-0/+1
| | | | | | | | | | | | | | | | | | Without this, -Wunused-local-typedef would incorrectly warn on the two typedefs in this program: void foo() { struct A {}; struct B : public A { typedef A INHERITED; B() : INHERITED() {} typedef B SELF; B(int) : SELF() {} }; } llvm-svn: 221765
* clang-format a few lines, fixes one 80col violation. nfc.Nico Weber2014-11-121-6/+5
| | | | llvm-svn: 221764
* Instantiate exception specifications when instantiating function types (otherRichard Smith2014-11-121-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | than the type of a function declaration). We previously didn't instantiate these at all! This also covers the pathological case where the only mention of a parameter pack is within the exception specification; this gives us a second way (other than alias templates) to reach the horrible state where a type contains an unexpanded pack, but its canonical type does not. This is a re-commit of r219977: r219977 was reverted in r220038 because it hit a wrong-code bug in GCC 4.7.2. (That's gcc.gnu.org/PR56135, and affects any implicit lambda-capture of 'this' within a template.) r219977 was a re-commit of r217995, r218011, and r218053: r217995 was reverted in r218058 because it hit a rejects-valid bug in MSVC. (Incorrect overload resolution in the presence of using-declarations.) It was re-committed in r219977 with a workaround for the MSVC rejects-valid. r218011 was a workaround for an MSVC parser bug. (Incorrect desugaring of unbraced range-based for loop). llvm-svn: 221750
* Further restrict issuance of 'override' warning if methodFariborz Jahanian2014-11-031-5/+7
| | | | | | is argument to a macro which is defined in system header. llvm-svn: 221172
* Don't allow dllimport/export on classes with internal linkage (PR21399)Hans Wennborg2014-11-031-0/+6
| | | | | | | | | | | Trying to import or export such classes doesn't make sense, and Clang would assert trying to export vtables for them. This is consistent with how we treat functions with internal linkage, but it is stricter than MSVC so we may have to back down if it breaks real code. llvm-svn: 221160
* Don't dllimport inline functions when targeting MinGW (PR21366)Hans Wennborg2014-11-031-9/+18
| | | | | | | | | | | | It turns out that MinGW never dllimports of exports inline functions. This means that code compiled with Clang would fail to link with MinGW-compiled libraries since we might try to import functions that are not imported. To fix this, make Clang never dllimport inline functions when targeting MinGW. llvm-svn: 221154
* Fix a bug where -Wuninitialized would skip arguments to a function call.Richard Trieu2014-11-011-0/+2
| | | | llvm-svn: 221030
* Have -Wuninitialized catch uninitalized use in overloaded operator arguments.Richard Trieu2014-10-311-0/+11
| | | | llvm-svn: 221000
* C++-11 [qoi]. Do not warn on missing 'verride' on use ofFariborz Jahanian2014-10-311-0/+6
| | | | | | | macros in user code when macros themselves are defined in a system header. rdar://18295240 llvm-svn: 220992
* c++11 patch to issue warning on missing 'override' on Fariborz Jahanian2014-10-271-1/+29
| | | | | | | overriding methods. Patch review by Richard Smith. rdar://18295240 llvm-svn: 220703
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-13/+14
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. llvm-svn: 220693
* Fix style issue from r220363. No functional change.Richard Trieu2014-10-221-1/+1
| | | | llvm-svn: 220370
* Disable the uninitialized field warning in uninstantiated classes.Richard Trieu2014-10-221-0/+3
| | | | | | | | If a templated class is not instantiated, then the AST for it could be missing some things that would throw the field checker off. Wait until specialization before emitting these warnings. llvm-svn: 220363
* SemaDeclCXX.cpp: UninitializedFieldVisitor: Avoid member initializers to ↵NAKAMURA Takumi2014-10-171-4/+5
| | | | | | appease msc17. llvm-svn: 220111
* Fix typo in comment.Nick Lewycky2014-10-171-1/+1
| | | | llvm-svn: 220098
* Add support for initializer lists on field initializers for -WuninitializedRichard Trieu2014-10-171-12/+90
| | | | llvm-svn: 220087
* Revert r219977, "Re-commit r217995 and follow-up patches (r217997, r218011, ↵NAKAMURA Takumi2014-10-171-17/+15
| | | | | | | | | | | | | r218053). These were" It broke some builders. I guess it'd be reproducible with --vg. Failing Tests (3): Clang :: CXX/except/except.spec/p1.cpp Clang :: SemaTemplate/instantiate-exception-spec-cxx11.cpp Clang :: SemaTemplate/instantiate-exception-spec.cpp llvm-svn: 220038
* Re-commit r217995 and follow-up patches (r217997, r218011, r218053). These wereRichard Smith2014-10-161-15/+17
| | | | | | | | | | | | | | | reverted in r218058 because they triggered a rejects-valid bug in MSVC. Original commit message from r217995: Instantiate exception specifications when instantiating function types (other than the type of a function declaration). We previously didn't instantiate these at all! This also covers the pathological case where the only mention of a parameter pack is within the exception specification; this gives us a second way (other than alias templates) to reach the horrible state where a type contains an unexpanded pack, but its canonical type does not. llvm-svn: 219977
* Revert r218925 - "Patch to warn if 'override' is missing"Alexander Potapenko2014-10-031-39/+1
| | | | | | | | | | | | | | | | | | | | This CL has caused bootstrap failures on Linux and OSX buildbots running with -Werror. Example report from http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/13183/steps/bootstrap%20clang/logs/stdio: ================================================================ [ 91%] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ShowEnabledWarnings.cpp.o In file included from /home/dtoolsbot/build/sanitizer-x86_64-linux/build/llvm/lib/Target/R600/AMDGPUISelDAGToDAG.cpp:20: In file included from /home/dtoolsbot/build/sanitizer-x86_64-linux/build/llvm/lib/Target/R600/SIISelLowering.h:19: /home/dtoolsbot/build/sanitizer-x86_64-linux/build/llvm/lib/Target/R600/SIInstrInfo.h:71:8: error: 'getLdStBaseRegImmOfs' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] bool getLdStBaseRegImmOfs(MachineInstr *LdSt, ^ /home/dtoolsbot/build/sanitizer-x86_64-linux/build/llvm/include/llvm/Target/TargetInstrInfo.h:815:16: note: overridden virtual function is here virtual bool getLdStBaseRegImmOfs(MachineInstr *LdSt, ^ ================================================================ llvm-svn: 218969
* Patch to warn if 'override' is missingFariborz Jahanian2014-10-021-1/+39
| | | | | | | | | | | | for an overriding method if class has at least one 'override' specified on one of its methods. Reviewed by Doug Gregor. rdar://18295240 (I have already checked in all llvm files with missing 'override' methods and Bob Wilson has fixed a TableGen of FastISel so no warnings are expected from build of llvm after this patch. I have already verified this). llvm-svn: 218925
* c++ error recovery. Build a valid AST when tryingFariborz Jahanian2014-10-011-1/+3
| | | | | | | | | to recover from parse error parsing the default argument. Patch prevents crash after spewing 100s of errors caused by someone who forgot to compile in c++11 mode. So no test. rdar://18508589 llvm-svn: 218780
OpenPOWER on IntegriCloud