summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merging r310983:Hans Wennborg2017-08-211-3/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r310983 | rsmith | 2017-08-15 18:49:53 -0700 (Tue, 15 Aug 2017) | 31 lines PR19668, PR23034: Fix handling of move constructors and deleted copy constructors when deciding whether classes should be passed indirectly. This fixes ABI differences between Clang and GCC: * Previously, Clang ignored the move constructor when making this determination. It now takes the move constructor into account, per https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may seem recent, but the ABI change was agreed on the Itanium C++ ABI list a long time ago). * Previously, Clang's behavior when the copy constructor was deleted was unstable -- depending on whether the lazy declaration of the copy constructor had been triggered, you might get different behavior. We now eagerly declare the copy constructor whenever its deletedness is unclear, and ignore deleted copy/move constructors when looking for a trivial such constructor. This also fixes an ABI difference between Clang and MSVC: * If the copy constructor would be implicitly deleted (but has not been lazily declared yet), for instance because the class has an rvalue reference member, we would pass it directly. We now pass such a class indirectly, matching MSVC. Based on a patch by Vassil Vassilev, which was based on a patch by Bernd Schmidt, which was based on a patch by Reid Kleckner! This is a re-commit of r310401, which was reverted in r310464 due to ARM failures (which should now be fixed). ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@311410 91177308-0d34-0410-b5e6-96231b3b80d8
* Recommit r306103: PR26195: Set correct NestedNameSpecifierLoc for theAlex Lorenz2017-06-271-0/+9
| | | | | | | | | | | | | | | | | | | | | dependent initializer This commit fixes incorrect source positions of dependent c'tor initializers like in the following code: template<typename MyBase> struct Derived: MyBase::InnerIterator { Derived() : MyBase::InnerIterator() {} /// This line is problematic: all positions point to InnerIterator and nothing points to MyBase }; Patch by Serge Preis! Differential Revision: https://reviews.llvm.org/D32439 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306392 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Fix a crash-on-invalid when a template parameter list has a classAkira Hatanaka2017-06-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | definition or non-reference class type. The crash occurs when there is a template parameter list in a class that is missing the closing angle bracket followed by a definition of a struct. For example: class C0 { public: template<typename T, typename T1 = T // missing closing angle bracket struct S0 {}; C0() : m(new S0<int>) {} S0<int> *m; }; This happens because the parsed struct is added to the scope of the enclosing class without having its access specifier set, which results in an assertion failure in SemaAccess.cpp later. This commit fixes the crash by adding the parsed struct to the enclosing file scope and marking structs as invalid if they are defined in template parameter lists. rdar://problem/31783961 rdar://problem/19570630 Differential Revision: https://reviews.llvm.org/D33606 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306317 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r306103: "PR26195: Set correct NestedNameSpecifierLoc for theAlex Lorenz2017-06-231-9/+0
| | | | | | | | | | dependent initializer" It caused buildbot failures such as this one: http://bb.pgr.jp/builders/test-clang-msc-x64-on-i686-linux-RA/builds/3777/steps/test_clang/logs/Clang%20%3A%3A%20Index__ctor-init-source-loc.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306111 91177308-0d34-0410-b5e6-96231b3b80d8
* PR26195: Set correct NestedNameSpecifierLoc for the dependent initializerAlex Lorenz2017-06-231-0/+9
| | | | | | | | | | | | | | | | | | | This commit fixes incorrect source positions of dependent c'tor initializers like in the following code: template<typename MyBase> struct Derived: MyBase::InnerIterator { Derived() : MyBase::InnerIterator() {} /// This line is problematic: all positions point to InnerIterator and nothing points to MyBase }; Patch by Serge Preis! Differential Revision: https://reviews.llvm.org/D32439 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306103 91177308-0d34-0410-b5e6-96231b3b80d8
* Function with unparsed body is a definitionSerge Pavlov2017-06-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While a function body is being parsed, the function declaration is not considered as a definition because it does not have a body yet. In some cases it leads to incorrect interpretation, the case is presented in https://bugs.llvm.org/show_bug.cgi?id=14785: ``` template<typename T> struct Somewhat { void internal() const {} friend void operator+(int const &, Somewhat<T> const &) {} }; void operator+(int const &, Somewhat<char> const &x) { x.internal(); } ``` When statement `x.internal()` in the body of global `operator+` is parsed, the type of `x` must be completed, so the instantiation of `Somewhat<char>` is started. It instantiates the declaration of `operator+` defined inline, and makes a check for redefinition. The check does not detect another definition because the declaration of `operator+` is still not defining as does not have a body yet. To solves this problem the function `isThisDeclarationADefinition` considers a function declaration as a definition if it has flag `WillHaveBody` set. This change fixes PR14785. Differential Revision: https://reviews.llvm.org/D30375 This is a recommit of 305379, reverted in 305381, with small changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305903 91177308-0d34-0410-b5e6-96231b3b80d8
* Reverted 305379 (Function with unparsed body is a definition)Serge Pavlov2017-06-141-3/+0
| | | | | | | | It broke clang-x86_64-linux-selfhost-modules-2 and some other buildbots. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305381 91177308-0d34-0410-b5e6-96231b3b80d8
* Function with unparsed body is a definitionSerge Pavlov2017-06-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | While a function body is being parsed, the function declaration is not considered as a definition because it does not have a body yet. In some cases it leads to incorrect interpretation, the case is presented in https://bugs.llvm.org/show_bug.cgi?id=14785: ``` template<typename T> struct Somewhat { void internal() const {} friend void operator+(int const &, Somewhat<T> const &) {} }; void operator+(int const &, Somewhat<char> const &x) { x.internal(); } ``` When statement `x.internal()` in the body of global `operator+` is parsed, the type of `x` must be completed, so the instantiation of `Somewhat<char>` is started. It instantiates the declaration of `operator+` defined inline, and makes a check for redefinition. The check does not detect another definition because the declaration of `operator+` is still not defining as does not have a body yet. To solves this problem the function `isThisDeclarationADefinition` considers a function declaration as a definition if it has flag `WillHaveBody` set. This change fixes PR14785. Differential Revision: https://reviews.llvm.org/D30375 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305379 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not inherit default arguments for friend function in class template.Serge Pavlov2017-06-081-11/+17
| | | | | | | | | | | | | | | | | | | | A function declared in a friend declaration may have declarations prior to the containing class definition. If such declaration defines default argument, the friend function declaration inherits them. This behavior causes problems if the class where the friend is declared is a template: during the class instantiation the friend function looks like if it had default arguments, so error is triggered. With this change friend functions declared in class templates do not inherit default arguments. Actual set of them will be defined at the point where the containing class is instantiated. This change fixes PR12724. Differential Revision: https://reviews.llvm.org/D30393 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304965 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve diagnostics if friend function redefines file-level function.Serge Pavlov2017-06-081-1/+6
| | | | | | | | | | | | | | | | | | | | | | | Clang makes check for function redefinition after it merged the new declaration with the existing one. As a result, it produces poor diagnostics in the case of a friend function defined inline, as in the code: ``` void func() {} class C { friend void func() {} }; ``` Error message in this case states that `inline declaration of 'func' follows non-inline definition`, which is misleading, as `func` does not have explicit `inline` specifier. With this changes compiler reports function redefinition if the new function is a friend defined inline and it does not have explicit `inline` specifier. Differential Revision: https://reviews.llvm.org/D26065 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304964 91177308-0d34-0410-b5e6-96231b3b80d8
* PR33318: Add missing full-expression checking to static_assert expression.Richard Smith2017-06-061-0/+8
| | | | | | | | This fixes missing lambda-captures for variables referenced only inside a static_assert (!), among other things. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304760 91177308-0d34-0410-b5e6-96231b3b80d8
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-031-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304651 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch from using a DiagnosticTrap and a note for "while defining a specialRichard Smith2017-05-251-142/+113
| | | | | | | | | | | | | | | | | | | | | | | | member function" context notes to registering an entry on the context stack. Also reorder the steps within defining special members to be consistent. This has a few benefits: if multiple diagnostics are produced while checking such a member, the note is now attached to the first such diagnostic rather than the last, this prepares us for persisting these diagnostics between the point at which we require the implicit instantiation of a template and the point at which that instantiation is actually performed, and this fixes some cases where we would fail to produce a full note stack leading back to user code in the case of such a diagnostic. The reordering exposed a case where we could recursively attempt to define a defaulted destructor while we're already defining one (and other such cases also appear to be possible, with or without this change), so this change also reuses the "willHaveBody" flag on function declarations to track that we're in the middle of synthesizing a body for the function and bails out if we try to define a function that we're already defining. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303930 91177308-0d34-0410-b5e6-96231b3b80d8
* Add #pragma clang attributeAlex Lorenz2017-04-181-0/+2
| | | | | | | | | | | | | | | | | | This is a recommit of r300539 that was reverted in r300543 due to test failures. The original commit message is displayed below: 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300556 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300543 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300539 91177308-0d34-0410-b5e6-96231b3b80d8
* [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299316 91177308-0d34-0410-b5e6-96231b3b80d8
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-301-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299083 91177308-0d34-0410-b5e6-96231b3b80d8
* [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299015 91177308-0d34-0410-b5e6-96231b3b80d8
* [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299008 91177308-0d34-0410-b5e6-96231b3b80d8
* Test CommitBrian Kelley2017-03-291-1/+1
| | | | | | Remove trailing whitespace. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299007 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298877 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296572 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296275 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor out more commonality between handling of deletion and exception ↵Richard Smith2017-02-241-86/+128
| | | | | | specifications for special member functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296173 91177308-0d34-0410-b5e6-96231b3b80d8
* Factor out some common code between SpecialMemberExceptionSpecInfo and ↵Richard Smith2017-02-241-78/+70
| | | | | | | | | SpecialMemberDeletionInfo. To simplify this, convert SpecialMemberOverloadResult to a value type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296073 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify and pass a more useful source location when computing an exceptionRichard Smith2017-02-241-14/+3
| | | | | | | specification for an implicit special member. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296068 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor computation of exception specification for special members to removeRichard Smith2017-02-241-361/+135
| | | | | | | some of the repetition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296067 91177308-0d34-0410-b5e6-96231b3b80d8
* Add context note to diagnostics that occur while declaring an implicit ↵Richard Smith2017-02-231-5/+20
| | | | | | special member function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296020 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295919 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295686 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295491 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294853 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++1z] Enforce restriction that deduction guide is declared in the same ↵Richard Smith2017-02-101-1/+14
| | | | | | scope as its template. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294778 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++1z] Disallow deduction guides with deduced types that don't ↵Richard Smith2017-02-101-3/+37
| | | | | | syntactically match the template being deduced. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294773 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++1z] P0512R0: support for 'explicit' specifier on deduction-guides.Richard Smith2017-02-101-0/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294693 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename IsExplicitSpecialization -> IsMemberSpecialization when we're talkingRichard Smith2017-02-091-4/+4
| | | | | | | about member specializations to avoid ambiguous and confusing terminology. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294622 91177308-0d34-0410-b5e6-96231b3b80d8
* [c++1z] P0091R3: Basic support for deducing class template arguments via ↵Richard Smith2017-02-091-1/+1
| | | | | | deduction-guides. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294613 91177308-0d34-0410-b5e6-96231b3b80d8
* More fixes for places where 'decltype(auto)' is permitted in the C++ grammar ↵Richard Smith2017-02-081-0/+3
| | | | | | but makes no sense. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294509 91177308-0d34-0410-b5e6-96231b3b80d8
* 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294401 91177308-0d34-0410-b5e6-96231b3b80d8
* Diagnose an attempt to give a deduction-guide a function body.Richard Smith2017-02-081-0/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294397 91177308-0d34-0410-b5e6-96231b3b80d8
* P0091R3: Improved syntactic checking of deduction-guides.Richard Smith2017-02-081-1/+90
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294395 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294266 91177308-0d34-0410-b5e6-96231b3b80d8
* [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292927 91177308-0d34-0410-b5e6-96231b3b80d8
* PR31692: Don't mark a declaration as invalid if we haven't necessarily ↵Richard Smith2017-01-231-3/+3
| | | | | | emitted a (user-visible) error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292847 91177308-0d34-0410-b5e6-96231b3b80d8
* [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291453 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291382 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291318 91177308-0d34-0410-b5e6-96231b3b80d8
* [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291045 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290744 91177308-0d34-0410-b5e6-96231b3b80d8