summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [c++1z] Enforce restriction that deduction guide is declared in the same ↵Richard Smith2017-02-101-1/+14
| | | | | | scope as its template. llvm-svn: 294778
* [c++1z] Disallow deduction guides with deduced types that don't ↵Richard Smith2017-02-101-3/+37
| | | | | | syntactically match the template being deduced. llvm-svn: 294773
* [c++1z] P0512R0: support for 'explicit' specifier on deduction-guides.Richard Smith2017-02-101-0/+10
| | | | llvm-svn: 294693
* Rename IsExplicitSpecialization -> IsMemberSpecialization when we're talkingRichard Smith2017-02-091-4/+4
| | | | | | about member specializations to avoid ambiguous and confusing terminology. llvm-svn: 294622
* [c++1z] P0091R3: Basic support for deducing class template arguments via ↵Richard Smith2017-02-091-1/+1
| | | | | | deduction-guides. llvm-svn: 294613
* More fixes for places where 'decltype(auto)' is permitted in the C++ grammar ↵Richard Smith2017-02-081-0/+3
| | | | | | but makes no sense. llvm-svn: 294509
* Sema: add warning for c++ member variable shadowingSaleem Abdulrasool2017-02-081-0/+55
| | | | | | | | | | Add a warning for shadowed variables across records. Referencing a shadow'ed variable may not give the desired variable. Add an optional warning for the shadowing. Patch by James Sun! llvm-svn: 294401
* Diagnose an attempt to give a deduction-guide a function body.Richard Smith2017-02-081-0/+3
| | | | llvm-svn: 294397
* P0091R3: Improved syntactic checking of deduction-guides.Richard Smith2017-02-081-1/+90
| | | | llvm-svn: 294395
* P0091R3: Implement basic parsing support for C++17 deduction-guides.Richard Smith2017-02-071-0/+15
| | | | | | | | | | | We model deduction-guides as functions with a new kind of name that identifies the template whose deduction they guide; the bulk of this patch is adding the new name kind. This gives us a clean way to attach an extensible list of guides to a class template in a way that doesn't require any special handling in AST files etc (and we're going to need these functions we come to performing deduction). llvm-svn: 294266
* [Sema] Fix assumption about typo corrections containing no decl.Benjamin Kramer2017-01-241-3/+6
| | | | | | | This can happen when the typo correction is coming from an external sema source. Test case will follow in clang-tools-extra. llvm-svn: 292927
* PR31692: Don't mark a declaration as invalid if we haven't necessarily ↵Richard Smith2017-01-231-3/+3
| | | | | | emitted a (user-visible) error. llvm-svn: 292847
* [MS] Mark default args of exported default constructors as usedReid Kleckner2017-01-091-2/+20
| | | | | | | | | | Fixes a regression introduced in r291045, which would lead to link errors. While we should no longer encounter unparsed or uninstantiated default arguments in this codepath, we still need to call CheckCXXDefaultArgExpr to mark the default argument expressions as ODR-used. llvm-svn: 291453
* PR18402: work around bug in libstdc++4.8's detection of whether ::gets exists.Richard Smith2017-01-081-0/+10
| | | | | | | This should allow clang to successfully compile libstdc++4.8's headers in C++14 mode. llvm-svn: 291382
* PR23135: Don't instantiate constexpr functions referenced in unevaluated ↵Richard Smith2017-01-071-3/+17
| | | | | | | | | | | | | | | | | | | | | operands where possible. This implements something like the current direction of DR1581: we use a narrow syntactic check to determine the set of places where a constant expression could be evaluated, and only instantiate a constexpr function or variable if it's referenced in one of those contexts, or is odr-used. It's not yet clear whether this is the right set of syntactic locations; we currently consider all contexts within templates that would result in odr-uses after instantiation, and contexts within list-initialization (narrowing conversions take another victim...), as requiring instantiation. We could in principle restrict the former cases more (only const integral / reference variable initializers, and contexts in which a constant expression is required, perhaps). However, this is sufficient to allow us to accept libstdc++ code, which relies on GCC's behavior (which appears to be somewhat similar to this approach). llvm-svn: 291318
* [MS] Instantiate default args during instantiation of exported default ctorsReid Kleckner2017-01-051-54/+21
| | | | | | | | | | | | | | | | | | | | Summary: Replace some old code that probably pre-dated the change to delay emission of dllexported code until after the closing brace of the outermost record type. Only uninstantiated default argument expressions need to be handled now. It is enough to instantiate default argument expressions when instantiating dllexported default ctors. This also fixes some double-diagnostic issues in this area. Fixes PR31500 Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28274 llvm-svn: 291045
* Allow lexer to handle string_view literals. Patch from Anton Bikineev.Eric Fiselier2016-12-301-1/+1
| | | | | | | This implements the compiler side of p0403r0. This patch was reviewed as https://reviews.llvm.org/D26829. llvm-svn: 290744
* [c++1z] P0195R2: Support pack-expansion of using-declarations.Richard Smith2016-12-201-22/+52
| | | | | | | | | | | | | | This change introduces UsingPackDecl as a marker for the set of UsingDecls produced by pack expansion of a single (unresolved) using declaration. This is not strictly necessary (we just need to be able to map from the original using declaration to its expansions somehow), but it's useful to maintain the invariant that each declaration reference instantiates to refer to one declaration. This is a re-commit of r290080 (reverted in r290092) with a fix for a use-after-lifetime bug. llvm-svn: 290203
* Revert "[c++1z] P0195R2: Support pack-expansion of using-declarations."Daniel Jasper2016-12-191-52/+22
| | | | | | | This reverts commit r290080 as it leads to many Clang crashes, e.g.: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/1814 llvm-svn: 290092
* [c++1z] P0195R2: Support pack-expansion of using-declarations.Richard Smith2016-12-191-22/+52
| | | | | | | | | | | This change introduces UsingPackDecl as a marker for the set of UsingDecls produced by pack expansion of a single (unresolved) using declaration. This is not strictly necessary (we just need to be able to map from the original using declaration to its expansions somehow), but it's useful to maintain the invariant that each declaration reference instantiates to refer to one declaration. llvm-svn: 290080
* Fix name hiding and redeclaration checking for dependent localRichard Smith2016-12-181-16/+24
| | | | | | using-declarations. llvm-svn: 290072
* Fix some interactions between C++11 and C++14 features and using-declarations:Richard Smith2016-12-181-9/+41
| | | | | | | | | | | * a dependent non-type using-declaration within a function template can be valid, as it can refer to an enumerator, so don't reject it in the template definition * we can partially substitute into a dependent using-declaration if it appears within a (local class in a) generic lambda within a function template, which means an UnresolvedUsing*Decl doesn't necessarily instantiate to a UsingDecl. llvm-svn: 290071
* [c++1z] P0195R2: Allow multiple using-declarators in a single using-declaration.Richard Smith2016-12-161-4/+2
| | | | llvm-svn: 289905
* Remove custom handling of array copies in lambda by-value array capture andRichard Smith2016-12-141-85/+19
| | | | | | | | | | | copy constructors of classes with array members, instead using ArrayInitLoopExpr to represent the initialization loop. This exposed a bug in the static analyzer where it was unable to differentiate between zero-initialized and unknown array values, which has also been fixed here. llvm-svn: 289618
* [c++1z] P0490R0, NB comment GB 20: if std::tuple_size<T> is complete, use theRichard Smith2016-12-081-5/+2
| | | | | | | | tuple-like interpretation of decomposition declaration even if there is no ::value member. We already did this, anticipating this resolution, just update comments and tweak a testcase. llvm-svn: 289021
* Disable -Wweak-vtables when there are no key functionsReid Kleckner2016-12-061-13/+17
| | | | | | | | | | | | Our -Wweak-vtables diagnostic is powered by our key function calculation, which checks if key functions are enabled. We won't find any key functions in C++ ABIs that lack key functions, so -Wweak-vtables was warning on every dynamic class before this change. So, turn off this warning in ABIs without key functions. Addresses PR31220 llvm-svn: 288850
* Fix stack-use-after-scope in CheckExplicitlyDefaultedMemberExceptionSpecVitaly Buka2016-12-051-2/+2
| | | | | | | | | | | | | | | Summary: Similar to r288685. getExceptionSpec returned structure with pointers to temporarily object created by computeImplicitExceptionSpec. Reviewers: rsmith Subscribers: aizatsky, cfe-commits Differential Revision: https://reviews.llvm.org/D27422 llvm-svn: 288689
* Fix stack-use-after-scope in EvaluateImplicitExceptionSpecVitaly Buka2016-12-051-1/+2
| | | | | | | | | | | | | | Summary: getExceptionSpec returns structure with pointers to temporarily object created by computeImplicitExceptionSpec. Reviewers: rsmith Subscribers: aizatsky, cfe-commits Differential Revision: https://reviews.llvm.org/D27420 llvm-svn: 288685
* [Sema] Pass APSInts by const ref, avoiding copies.Benjamin Kramer2016-11-241-3/+3
| | | | | | | No functionality change intended. Fix by clang-tidy's performance-unnecessary-value-param check. llvm-svn: 287890
* Remove C++ default arg side table for MS ABI ctor closuresReid Kleckner2016-11-231-10/+5
| | | | | | | | | | | | | | | | | | | Summary: We don't need a side table in ASTContext to hold CXXDefaultArgExprs. The important part of building the CXXDefaultArgExprs was to ODR use the default argument expressions, not to make AST nodes. Refactor the code to only check the default argument, and remove the side table in ASTContext which wasn't being serialized. Fixes PR31121 Reviewers: thakis, rsmith, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27007 llvm-svn: 287774
* Make diagnostic for use of default member initializer before enclosing class isRichard Smith2016-11-221-8/+3
| | | | | | | complete a little more general; it is produced in other cases than the one that it previously talked about. llvm-svn: 287713
* Sema, CodeGen: Ensure that an implicit copy ctor is available more often ↵Peter Collingbourne2016-11-221-0/+11
| | | | | | | | | | | | | | | | under the Microsoft C++ ABI. This is needed because whether the constructor is deleted can control whether we pass structs by value directly. To fix this properly we probably want a more direct way for CodeGen to ask whether the constructor was deleted. Fixes PR31049. Differential Revision: https://reviews.llvm.org/D26822 llvm-svn: 287600
* Sema: As of MSVC 2015, a user-declared move operation causes the deletion of ↵Peter Collingbourne2016-11-191-4/+9
| | | | | | | | both copy operations. Differential Revision: https://reviews.llvm.org/D26868 llvm-svn: 287411
* Fixes for r287241. Use placement new. Apply clang-format.Malcolm Parsons2016-11-171-1/+2
| | | | llvm-svn: 287258
* Use unique_ptr for cached tokens for default arguments in C++.Malcolm Parsons2016-11-171-3/+1
| | | | | | | | | | | | | | | | | Summary: This changes pointers to cached tokens for default arguments in C++ from raw pointers to unique_ptrs. There was a fixme in the code where the cached tokens are created about using a smart pointer. The change is straightforward, though I did have to track down and fix a memory corruption caused by the change. memcpy was being used to copy parameter information. This duplicated the unique_ptr, which led to the cached token buffer being deleted prematurely. Patch by David Tarditi! Reviewers: malcolm.parsons Subscribers: arphaman, malcolm.parsons, cfe-commits Differential Revision: https://reviews.llvm.org/D26435 llvm-svn: 287241
* Correctly ignore unnamed bit-fields when checking whether a union has fields.Richard Smith2016-11-081-2/+7
| | | | llvm-svn: 286189
* Add a note that points to the linkage specifier for the C++ linkage errorsAlex Lorenz2016-11-021-0/+3
| | | | | | | | | | | | This commit improves the "must have C++ linkage" error diagnostics that are emitted for C++ declarations like templates and literal operators by adding an additional note that points to the appropriate extern "C" linkage specifier. rdar://19021120 Differential Revision: https://reviews.llvm.org/D26189 llvm-svn: 285823
* [modules] Mark deleted functions as implicitly inline to allow mergingEric Fiselier2016-10-311-0/+3
| | | | | | | | | | | | Summary: When merging definitions with ModulesLocalVisibility enabled it's important to make deleted definitions implicitly inline, otherwise they'll be diagnosed as a redefinition. Reviewers: silvas, manmanren, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26143 llvm-svn: 285655
* When diagnosing that a defaulted function is ill-formed because it would beRichard Smith2016-10-311-1/+6
| | | | | | | implicitly deleted and overrides a non-deleted function, explain why the function is deleted. For PR30844. llvm-svn: 285610
* [modules] PR28812: Modules can return duplicate field decls.Vassil Vassilev2016-10-261-2/+9
| | | | | | | | | | | | | If two modules contain duplicate class definitions the lookup result can contain more than 2 elements. Sift the lookup results until we find a field decl. It is not necessary to do ODR checks in place as they done elsewhere. This should fix issues when compiling with libstdc++ 5.2 and 6.2. Patch developed in collaboration with Richard Smith! llvm-svn: 285184
* Don't try to use !Previous.empty() as a proxy for "Is this a redeclaration?" --Richard Smith2016-10-211-4/+3
| | | | | | | | | | | we don't collapse that down to a single entry if it's not a redeclaration. Instead, set the Redeclaration bit on the Declarator to indicate whether a function is a redeclaration (which may not have been linked into the redeclaration chain if it's a dependent context friend). Fixes a rejects-valid; see testcase. llvm-svn: 284802
* [c++1z] Fix assertion failure when using the wrong number of bindings for aRichard Smith2016-10-201-1/+3
| | | | | | struct with unnamed bitfields. llvm-svn: 284761
* P0012R1: Make exception specifications be part of the type system. ThisRichard Smith2016-10-161-3/+0
| | | | | | | implements the bulk of the change (modifying the type system to include exception specifications), but not all the details just yet. llvm-svn: 284337
* Sema: honour dllexport in itanium more faithfullySaleem Abdulrasool2016-10-141-1/+2
| | | | | | | | | Although the itanium environment uses the itanium layout for C++, treat the dllexport semantics more similarly to the MSVC specification. This preserves the existing behaviour for the use of the itanium ABI on non-windows-itanium environments. Export the inline definitions too. llvm-svn: 284288
* Re-commit r283722, reverted in r283750, with a fix for a CUDA-specific use ofRichard Smith2016-10-101-15/+11
| | | | | | | | | | | past-the-end iterator. Original commit message: P0035R4: Semantic analysis and code generation for C++17 overaligned allocation. llvm-svn: 283789
* [Sema] Prevent using member declaration diagnostic if the base class is invalid.Eric Fiselier2016-10-101-5/+7
| | | | | | | | | | | | | | | Summary: Once a base class has been made invalid (by a static_assert for example) all using-member declarations in the derived classes will result in a "not a base class" diagnostic. This diagnostic is very misleading and should not be emitted. This change is needed to help libc++ produce reasonable diagnostics in `std::optional` and `std::variant`. Reviewers: rsmith, majnemer, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25430 llvm-svn: 283755
* Revert "P0035R4: Semantic analysis and code generation for C++17 overaligned ↵Daniel Jasper2016-10-101-11/+15
| | | | | | | | | | | | 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-15/+11
| | | | | | allocation. llvm-svn: 283722
* Do not find friend function definitions inside non-instantiated class.Serge Pavlov2016-10-041-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously if a file-level function was defined inside befriending template class, it always was treated as defined. For instance, the code like: ``` int func(int x); template<typename T> class C1 { friend int func(int x) { return x; } }; template<typename T> class C2 { friend int func(int x) { return x; } }; ``` could not be compiled due to function redefinition, although not of the templates is instantiated. Moreover, the body of friend function can contain use of template parameters, attempt to get definition of such function outside any instantiation causes compiler abnormal termination. Other compilers (gcc, icc) follow viewpoint that the body of the function defined in friend declaration becomes available when corresponding class is instantiated. This patch implements this viewpoint in clang. Definitions introduced by friend declarations in template classes are not added to the redeclaration chain of corresponding function. Only when the template is instantiated, instantiation of the function definition is placed to the chain. The fix was made in collaboration with Richard Smith. This change fixes PR8035, PR17923, PR22307 and PR25848. Differential Revision: http://reviews.llvm.org/D16989 llvm-svn: 283207
* [coroutines] Switch to using std::experimental namespace per P0057R5Gor Nishanov2016-10-041-0/+14
| | | | | | | | | | | | | | Summary: Look for coroutine_traits and friends in std::experimental namespace. Patch (mostly) by EricWF. Reviewers: cfe-commits, EricWF, rsmith Subscribers: majnemer, mehdi_amini Differential Revision: https://reviews.llvm.org/D25068 llvm-svn: 283170
OpenPOWER on IntegriCloud