Revert "PR47792: Include the type of a pointer or reference non-type template"
authorJonas Devlieghere <jonas@devlieghere.com>
Mon, 12 Oct 2020 03:14:00 +0000 (20:14 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Mon, 12 Oct 2020 03:16:46 +0000 (20:16 -0700)
This reverts commit 849c60541b630ddf8cabf9179fa771b3f4207ec8 because it
results in a stage 2 build failure:

llvm-project/clang/include/clang/AST/ExternalASTSource.h:409:20: error:
definition with same mangled name
'_ZN5clang25LazyGenerationalUpdatePtrIPKNS_4DeclEPS1_XadL_ZNS_17ExternalASTSource19CompleteRedeclChainES3_EEE9makeValueERKNS_10ASTContextES4_'
as another definition

  static ValueType makeValue(const ASTContext &Ctx, T Value);

clang/lib/AST/ASTContext.cpp
clang/lib/AST/TemplateBase.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

index 7c96038..a82d954 100644 (file)
@@ -5890,7 +5890,7 @@ ASTContext::getCanonicalTemplateArgument(const TemplateArgument &Arg) const {
 
     case TemplateArgument::Declaration: {
       auto *D = cast<ValueDecl>(Arg.getAsDecl()->getCanonicalDecl());
-      return TemplateArgument(D, getCanonicalType(Arg.getParamTypeForDecl()));
+      return TemplateArgument(D, Arg.getParamTypeForDecl());
     }
 
     case TemplateArgument::NullPtr:
index e4303fd..a911372 100644 (file)
@@ -244,8 +244,7 @@ void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
     break;
 
   case Declaration:
-    ID.AddPointer(getAsDecl() ? getAsDecl()->getCanonicalDecl() : nullptr);
-    getParamTypeForDecl().Profile(ID);
+    ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : nullptr);
     break;
 
   case Template:
@@ -295,8 +294,7 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
     return TypeOrValue.V == Other.TypeOrValue.V;
 
   case Declaration:
-    return getAsDecl() == Other.getAsDecl() &&
-           getParamTypeForDecl() == Other.getParamTypeForDecl();
+    return getAsDecl() == Other.getAsDecl();
 
   case Integral:
     return getIntegralType() == Other.getIntegralType() &&
index 6949a2e..7538de3 100644 (file)
@@ -459,23 +459,3 @@ namespace PR46637 {
   X<f> y;
   int n = y.call(); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
 }
-
-namespace PR47792 {
-  using I = int;
-
-  template<decltype(auto)> int a;
-  const int n = 0;
-  const I n2 = 0;
-  static_assert(&a<n> == &a<0>, "both should have type 'int'");
-  static_assert(&a<n2> == &a<0>, "both should have type 'int'");
-
-  // FIXME: We will need to mangle these cases differently too!
-  int m;
-  const int &r1 = m;
-  int &r2 = m;
-  static_assert(&a<r1> != &a<r2>, "should have different types");
-
-  const I &r3 = m;
-  static_assert(&a<r1> == &a<r3>, "should have different types");
-  static_assert(&a<r2> != &a<r3>, "should have different types");
-}