summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225774 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix grammar-o in comment.Nico Weber2015-01-061-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225324 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224905 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224561 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224411 91177308-0d34-0410-b5e6-96231b3b80d8
* DR1684: a constexpr member function need not be a member of a literal class ↵Richard Smith2014-12-161-36/+0
| | | | | | type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224388 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224303 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224193 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223705 91177308-0d34-0410-b5e6-96231b3b80d8
* When checking for uninitialized values, do not confuse "std::move" with everyRichard Trieu2014-11-271-1/+2
| | | | | | | other function named "move". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222863 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix line endingsNico Rieck2014-11-241-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222666 91177308-0d34-0410-b5e6-96231b3b80d8
* Delay checking overrides for exception specifications if the overriddenRichard Smith2014-11-221-14/+8
| | | | | | | specification has not yet been parsed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222603 91177308-0d34-0410-b5e6-96231b3b80d8
* Extend -Wuninitialized to warn when accessing uninitialized base classes in aRichard Trieu2014-11-211-12/+41
| | | | | | | constructor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222503 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222335 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222192 91177308-0d34-0410-b5e6-96231b3b80d8
* [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222054 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove some redundant virtual specifiers on overriden functions.David Blaikie2014-11-141-9/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222024 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221918 91177308-0d34-0410-b5e6-96231b3b80d8
* 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() {} }; } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221765 91177308-0d34-0410-b5e6-96231b3b80d8
* clang-format a few lines, fixes one 80col violation. nfc.Nico Weber2014-11-121-6/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221764 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221750 91177308-0d34-0410-b5e6-96231b3b80d8
* Further restrict issuance of 'override' warning if methodFariborz Jahanian2014-11-031-5/+7
| | | | | | | | is argument to a macro which is defined in system header. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221172 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221160 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221154 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug where -Wuninitialized would skip arguments to a function call.Richard Trieu2014-11-011-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221030 91177308-0d34-0410-b5e6-96231b3b80d8
* Have -Wuninitialized catch uninitalized use in overloaded operator arguments.Richard Trieu2014-10-311-0/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221000 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220992 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220703 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-13/+14
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220693 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix style issue from r220363. No functional change.Richard Trieu2014-10-221-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220370 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220363 91177308-0d34-0410-b5e6-96231b3b80d8
* SemaDeclCXX.cpp: UninitializedFieldVisitor: Avoid member initializers to ↵NAKAMURA Takumi2014-10-171-4/+5
| | | | | | appease msc17. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220111 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo in comment.Nick Lewycky2014-10-171-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220098 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for initializer lists on field initializers for -WuninitializedRichard Trieu2014-10-171-12/+90
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220087 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220038 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219977 91177308-0d34-0410-b5e6-96231b3b80d8
* 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, ^ ================================================================ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218969 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218925 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218780 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve -Wuninitialized warnings for fields that are record types.Richard Trieu2014-10-011-31/+59
| | | | | | | | Get the record handling code from SelfReferenceChecker into UninitializedFieldVisitor as well as copying the testcases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218740 91177308-0d34-0410-b5e6-96231b3b80d8
* CUDA: Fix incorrect target inference for implicit members.Eli Bendersky2014-09-291-4/+51
| | | | | | | | | | | | | | | As PR20495 demonstrates, Clang currenlty infers the CUDA target (host/device, etc) for implicit members (constructors, etc.) incorrectly. This causes errors and even assertions in Clang when compiling code (assertions in C++11 mode where implicit move constructors are added into the mix). Fix the problem by inferring the target from the methods the implicit member should call (depending on its base classes and fields). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218624 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix "unsupported friend" diagnostic to also appear for friend functions with ↵Richard Smith2014-09-291-1/+5
| | | | | | dependent scopes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218590 91177308-0d34-0410-b5e6-96231b3b80d8
* Move calls to ResolveExceptionSpec out of SetDeclDefaulted and into ↵Ben Langmuir2014-09-251-5/+30
| | | | | | | | | DefineImplicit* This fixes an assertion failure in CodeGen where we were not resolving an exception specification. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218466 91177308-0d34-0410-b5e6-96231b3b80d8
* Add increment/decrement operators and compound assignment operators to theRichard Trieu2014-09-251-0/+11
| | | | | | | uninitialized checkers that did not have them before. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218435 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r217995 and follow-ups:Hans Wennborg2014-09-181-17/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r218053: Use exceptions() instead of getNumExceptions()/getExceptionType() to avoid r218011: Work around MSVC parser bug by putting redundant braces around the body of r217997: Skip parens when detecting whether we're instantiating a function declaration. r217995: Instantiate exception specifications when instantiating function types (other The Windows build was broken for 16 hours and no one had any good ideas of how to fix it. Reverting for now to make the builders green. See the cfe-commits thread [1] for more info. This was the build error (from [2]): C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang\lib\Sema\SemaTemplateInstantiate.cpp(1590) : error C2668: '`anonymous-namespace'::TemplateInstantiator::TransformFunctionProtoType' : ambiguous call to overloaded function C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang\lib\Sema\SemaTemplateInstantiate.cpp(1313): could be 'clang::QualType `anonymous-namespace'::TemplateInstantiator::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>>(clang::TypeLocBuilder &,clang::FunctionProtoTypeLoc,clang::CXXRecordDecl *,unsigned int,Fn)' with [ Fn=clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735> ] c:\bb-win7\ninja-clang-i686-msc17-r\llvm-project\clang\lib\sema\TreeTransform.h(4532): or 'clang::QualType clang::TreeTransform<Derived>::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>>(clang::TypeLocBuilder &,clang::FunctionProtoTypeLoc,clang::CXXRecordDecl *,unsigned int,Fn)' with [ Derived=`anonymous-namespace'::TemplateInstantiator, Fn=clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735> ] while trying to match the argument list '(clang::TypeLocBuilder, clang::FunctionProtoTypeLoc, clang::CXXRecordDecl *, unsigned int, clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>)' 1. http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140915/115011.html 2. http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/10515/steps/build_clang_tools_1/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218058 91177308-0d34-0410-b5e6-96231b3b80d8
* Instantiate exception specifications when instantiating function types (otherRichard Smith2014-09-171-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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217995 91177308-0d34-0410-b5e6-96231b3b80d8
* Check delegating constructors for using uninitialized fields.Richard Trieu2014-09-121-0/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217716 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Make NamespaceAliasDecl redeclarable, as it should be. This fixesRichard Smith2014-09-031-30/+33
| | | | | | | | merging of namespace aliases across modules and improves source fidelity. Incidentally also fixes PR20816. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217103 91177308-0d34-0410-b5e6-96231b3b80d8
* Split off CUDA-specific Sema parts to a new fileEli Bendersky2014-09-031-40/+0
| | | | | | | | | | | | | | In line with SemaOpenMP.cpp, etc. CUDA-specific semantic analysis code goes into a separate file. This is in anticipation of adding extra functionality here in the near future. No change in functionality. Review: http://reviews.llvm.org/D5160 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217043 91177308-0d34-0410-b5e6-96231b3b80d8
* Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor ↵Craig Topper2014-08-301-2/+1
| | | | | | and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216824 91177308-0d34-0410-b5e6-96231b3b80d8