r364476 - Revert r363191 "[MS] Pretend constexpr variable template specializations are inline"

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 4 01:34:03 PDT 2019


Re-committed in r370850 for PR42843.

On Wed, Jun 26, 2019 at 11:16 PM Reid Kleckner via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
>
> Author: rnk
> Date: Wed Jun 26 14:16:51 2019
> New Revision: 364476
>
> URL: http://llvm.org/viewvc/llvm-project?rev=364476&view=rev
> Log:
> Revert r363191 "[MS] Pretend constexpr variable template specializations are inline"
>
> The next Visual Studio update will fix this issue, and it doesn't make
> sense to implement this non-conforming behavior going forward.
>
> Removed:
>     cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp
> Modified:
>     cfe/trunk/lib/AST/ASTContext.cpp
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=364476&r1=364475&r2=364476&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jun 26 14:16:51 2019
> @@ -9809,25 +9809,10 @@ static GVALinkage basicGVALinkageForVari
>      return StrongLinkage;
>
>    case TSK_ExplicitSpecialization:
> -    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;
> +    return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
> +                   VD->isStaticDataMember()
> +               ? GVA_StrongODR
> +               : StrongLinkage;
>
>    case TSK_ExplicitInstantiationDefinition:
>      return GVA_StrongODR;
>
> Removed: cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp?rev=364475&view=auto
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/ms-constexpr-var-template.cpp (removed)
> @@ -1,11 +0,0 @@
> -// RUN: %clang_cc1 -emit-llvm -triple=x86_64-windows-msvc -fms-compatibility %s -o - | FileCheck %s
> -
> -template <typename> constexpr bool _Is_integer = false;
> -template <> constexpr bool _Is_integer<int> = true;
> -template <> constexpr bool _Is_integer<char> = false;
> -extern "C" const bool *escape = &_Is_integer<int>;
> -
> -// CHECK: @"??$_Is_integer at H@@3_NB" = linkonce_odr dso_local constant i8 1, comdat, align 1
> -//   Should not emit _Is_integer<char>, since it's not referenced.
> -// CHECK-NOT: @"??$_Is_integer at D@@3_NB"
> -// CHECK: @escape = dso_local global i8* @"??$_Is_integer at H@@3_NB", align 8
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list