diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-09-07 11:21:48 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-09-07 11:21:48 +0000 |
commit | 668007a2dec842f36eef4b27bb4b18dff3111855 (patch) | |
tree | e1abd44f1287e8a4d14bc87bd154eda3e65805f3 /lib/AST/ASTContext.cpp | |
parent | 24632cab8a0c7485d3c7b3a77625967ff9c7958f (diff) | |
download | src-9fba71a4ed1038caaec287e4b7e9c52b67fdcd41.tar.gz src-9fba71a4ed1038caaec287e4b7e9c52b67fdcd41.zip |
Vendor import of clang release_90 branch r371301:vendor/clang/clang-release_90-r371301
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 468c7f47657d..93bdaafc2ac6 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -9814,10 +9814,25 @@ static GVALinkage basicGVALinkageForVariable(const ASTContext &Context, return StrongLinkage; case TSK_ExplicitSpecialization: - return Context.getTargetInfo().getCXXABI().isMicrosoft() && - VD->isStaticDataMember() - ? GVA_StrongODR - : StrongLinkage; + if (Context.getTargetInfo().getCXXABI().isMicrosoft()) { + // If this is a fully specialized constexpr variable template, pretend it + // was marked inline. MSVC 14.21.27702 headers define _Is_integral in a + // header this way, and we don't want to emit non-discardable definitions + // of these variables in every TU that includes <type_traits>. This + // behavior is non-conforming, since another TU could use an extern + // template declaration for this variable, but for constexpr variables, + // it's unlikely for a user to want to do that. This behavior can be + // removed if the headers change to explicitly mark such variable template + // specializations inline. + if (isa<VarTemplateSpecializationDecl>(VD) && VD->isConstexpr()) + return GVA_DiscardableODR; + + // Use ODR linkage for static data members of fully specialized templates + // to prevent duplicate definition errors with MSVC. + if (VD->isStaticDataMember()) + return GVA_StrongODR; + } + return StrongLinkage; case TSK_ExplicitInstantiationDefinition: return GVA_StrongODR; |