<div dir="ltr"><div class="gmail_quote"><div class="gmail_attr">The bots don't seem happy building with a Clang that incorporates this change:</div><div class="gmail_attr">```<br></div><div class="gmail_attr">/b/sanitizer-x86_64-linux-bootstrap/build/llvm-project/clang/lib/ASTMatchers/ASTMatchersInternal.cpp:943:5: error: redefinition of 'hasAnyName' with a different type: 'const VariadicFunction<...>' vs 'const VariadicFunction<...>'<br>    hasAnyName = {};<br>    ^<br>/b/sanitizer-x86_64-linux-bootstrap/build/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h:2771:5: note: previous declaration is here<br>    hasAnyName;<br>    ^</div><div class="gmail_attr">```</div><div class="gmail_attr">(from <a href="http://lab.llvm.org:8011/#/builders/99/builds/49/steps/2/logs/build_clang_asan">http://lab.llvm.org:8011/#/builders/99/builds/49/steps/2/logs/build_clang_asan</a>)</div><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">On Sun, Oct 11, 2020 at 7:00 PM Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Richard Smith<br>
Date: 2020-10-11T15:59:49-07:00<br>
New Revision: 849c60541b630ddf8cabf9179fa771b3f4207ec8<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/849c60541b630ddf8cabf9179fa771b3f4207ec8" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/849c60541b630ddf8cabf9179fa771b3f4207ec8</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/849c60541b630ddf8cabf9179fa771b3f4207ec8.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/849c60541b630ddf8cabf9179fa771b3f4207ec8.diff</a><br>
<br>
LOG: PR47792: Include the type of a pointer or reference non-type template<br>
parameter in its notion of template argument identity.<br>
<br>
We already did this for all the other kinds of non-type template<br>
argument. We're still missing the type from the mangling, so we continue<br>
to be able to see collisions at link time; that's an open ABI issue.<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    clang/lib/AST/ASTContext.cpp<br>
    clang/lib/AST/TemplateBase.cpp<br>
    clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp<br>
index a82d95461bb9..7c96038629fb 100644<br>
--- a/clang/lib/AST/ASTContext.cpp<br>
+++ b/clang/lib/AST/ASTContext.cpp<br>
@@ -5890,7 +5890,7 @@ ASTContext::getCanonicalTemplateArgument(const TemplateArgument &Arg) const {<br>
<br>
     case TemplateArgument::Declaration: {<br>
       auto *D = cast<ValueDecl>(Arg.getAsDecl()->getCanonicalDecl());<br>
-      return TemplateArgument(D, Arg.getParamTypeForDecl());<br>
+      return TemplateArgument(D, getCanonicalType(Arg.getParamTypeForDecl()));<br>
     }<br>
<br>
     case TemplateArgument::NullPtr:<br>
<br>
diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp<br>
index a9113720fd45..e4303fdb7731 100644<br>
--- a/clang/lib/AST/TemplateBase.cpp<br>
+++ b/clang/lib/AST/TemplateBase.cpp<br>
@@ -244,7 +244,8 @@ void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,<br>
     break;<br>
<br>
   case Declaration:<br>
-    ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : nullptr);<br>
+    ID.AddPointer(getAsDecl() ? getAsDecl()->getCanonicalDecl() : nullptr);<br>
+    getParamTypeForDecl().Profile(ID);<br>
     break;<br>
<br>
   case Template:<br>
@@ -294,7 +295,8 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {<br>
     return TypeOrValue.V == Other.TypeOrValue.V;<br>
<br>
   case Declaration:<br>
-    return getAsDecl() == Other.getAsDecl();<br>
+    return getAsDecl() == Other.getAsDecl() &&<br>
+           getParamTypeForDecl() == Other.getParamTypeForDecl();<br>
<br>
   case Integral:<br>
     return getIntegralType() == Other.getIntegralType() &&<br>
<br>
diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp<br>
index 7538de330902..6949a2eaad48 100644<br>
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp<br>
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp<br>
@@ -459,3 +459,23 @@ namespace PR46637 {<br>
   X<f> y;<br>
   int n = y.call(); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}<br>
 }<br>
+<br>
+namespace PR47792 {<br>
+  using I = int;<br>
+<br>
+  template<decltype(auto)> int a;<br>
+  const int n = 0;<br>
+  const I n2 = 0;<br>
+  static_assert(&a<n> == &a<0>, "both should have type 'int'");<br>
+  static_assert(&a<n2> == &a<0>, "both should have type 'int'");<br>
+<br>
+  // FIXME: We will need to mangle these cases <br>
diff erently too!<br>
+  int m;<br>
+  const int &r1 = m;<br>
+  int &r2 = m;<br>
+  static_assert(&a<r1> != &a<r2>, "should have <br>
diff erent types");<br>
+<br>
+  const I &r3 = m;<br>
+  static_assert(&a<r1> == &a<r3>, "should have <br>
diff erent types");<br></blockquote><div>I think the text of the static_assert string here is a copy-paste error.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+  static_assert(&a<r2> != &a<r3>, "should have <br>
diff erent types");<br>
+}<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>