summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r300539 - Add #pragma clang attributeAlex Lorenz2017-04-181-2/+0
| | | | | | | Some tests fail on the Windows buildbots. I will have to investigate more. This commit reverts r300539, r300540 and r300542. llvm-svn: 300543
* Add #pragma clang attributeAlex Lorenz2017-04-181-0/+2
| | | | | | | | | | | | | | The new '#pragma clang attribute' directive can be used to apply attributes to multiple declarations. An attribute must satisfy the following conditions to be supported by the pragma: - It must have a subject list that's defined in the TableGen file. - It must be documented. - It must not be late parsed. - It must have a GNU/C++11 spelling. Differential Revision: https://reviews.llvm.org/D30009 llvm-svn: 300539
* [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped EnumFaisal Vali2017-04-011-3/+6
| | | | | | | | - also replace direct equality checks against the ConstantEvaluated enumerator with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17. - update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed. llvm-svn: 299316
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-301-2/+2
| | | | llvm-svn: 299083
* [Objective-C] Miscellaneous -fobjc-weak FixesBrian Kelley2017-03-291-2/+1
| | | | | | | | | | | | | | Summary: After examining the remaining uses of LangOptions.ObjCAutoRefCount, found a some additional places to also check for ObjCWeak not covered by previous test cases. Added a test file to verify all the code paths that were changed. Reviewers: rsmith, doug.gregor, rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31007 llvm-svn: 299015
* [Objective-C] C++ Classes with __weak Members non-POD Types when using ↵Brian Kelley2017-03-291-5/+2
| | | | | | | | | | | | | | | | -fobjc-weak Summary: When adding an Objective-C retainable type member to a C++ class, also check the LangOpts.ObjCWeak flag and the lifetime qualifier so __weak qualified Objective-C pointer members cause the class to be a non-POD type with non-trivial special members, so the compiler always emits the necessary runtime calls for copying, moving, and destroying the weak member. Otherwise, Objective-C++ classes with weak Objective-C pointer members compiled with -fobjc-weak exhibit undefined behavior if the C++ class is classified as a POD type. Reviewers: rsmith, benlangmuir, doug.gregor, rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31003 llvm-svn: 299008
* Test CommitBrian Kelley2017-03-291-1/+1
| | | | | | Remove trailing whitespace. llvm-svn: 299007
* Encapsulate FPOptions and use it consistentlyAdam Nemet2017-03-271-1/+1
| | | | | | | | | | | | | | | | | | Sema holds the current FPOptions which is adjusted by 'pragma STDC FP_CONTRACT'. This then gets propagated into expression nodes as they are built. This encapsulates FPOptions so that this propagation happens opaquely rather than directly with the fp_contractable on/off bit. This allows controlled transitioning of fp_contractable to a ternary value (off, on, fast). It will also allow adding more fast-math flags later. This is toward moving fp-contraction=fast from an LLVM TargetOption to a FastMathFlag in order to fix PR25721. Differential Revision: https://reviews.llvm.org/D31166 llvm-svn: 298877
* Add warning for inconsistent overrides on destructor.Richard Trieu2017-03-011-5/+6
| | | | | | | | | The exisiting warning for inconsistent overrides does not include the destructor as it was noted in review that it was too noisy. Instead, add to a separate warning group that is off by default for users who want consistent warnings between methods and destructors. llvm-svn: 296572
* C++ DR1611, 1658, 2180: implement "potentially constructed subobject" rules ↵Richard Smith2017-02-251-11/+23
| | | | | | | | | | | | | | | | | | | | | | for special member functions. Essentially, as a base class constructor does not construct virtual bases, such a constructor for an abstract class does not need the corresponding base class construction to be valid, and likewise for destructors. This creates an awkward situation: clang will sometimes generate references to the complete object and deleting destructors for an abstract class (it puts them in the construction vtable for a derived class). But we can't generate a "correct" version of these because we can't generate references to base class constructors any more (if they're template specializations, say, we might not have instantiated them and can't assume any other TU will emit a copy). Fortunately, we don't need to, since no correct program can ever invoke them, so instead emit symbols that just trap. We should stop emitting references to these symbols, but still need to emit definitions for compatibility. llvm-svn: 296275
* Factor out more commonality between handling of deletion and exception ↵Richard Smith2017-02-241-86/+128
| | | | | | specifications for special member functions. llvm-svn: 296173
* Factor out some common code between SpecialMemberExceptionSpecInfo and ↵Richard Smith2017-02-241-78/+70
| | | | | | | | SpecialMemberDeletionInfo. To simplify this, convert SpecialMemberOverloadResult to a value type. llvm-svn: 296073
* Simplify and pass a more useful source location when computing an exceptionRichard Smith2017-02-241-14/+3
| | | | | | specification for an implicit special member. llvm-svn: 296068
* Refactor computation of exception specification for special members to removeRichard Smith2017-02-241-361/+135
| | | | | | some of the repetition. llvm-svn: 296067
* Add context note to diagnostics that occur while declaring an implicit ↵Richard Smith2017-02-231-5/+20
| | | | | | special member function. llvm-svn: 296020
* Rename ActiveTemplateInstantiation to CodeSynthesisContext in preparation forRichard Smith2017-02-231-4/+4
| | | | | | | using it for other kinds of context (where we currently produce context notes in a highly ad-hoc manner). llvm-svn: 295919
* Factor out function to determine whether we're performing a templateRichard Smith2017-02-211-1/+1
| | | | | | | | | instantiation. In preparation for converting the template stack to a more general context stack (so we can include context notes for other kinds of context). llvm-svn: 295686
* Add an explicit derived class of FunctionDecl to model deduction guides ratherRichard Smith2017-02-171-3/+4
| | | | | | | | than just treating them as FunctionDecls with a funny name. No functionality change intended. llvm-svn: 295491
* Sema: simplify conditional execution (NFC)Saleem Abdulrasool2017-02-111-4/+1
| | | | | | | The conditional cast is unnecessary since we know that it will always succeed. NFC. llvm-svn: 294853
* [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
OpenPOWER on IntegriCloud