[llvm-branch-commits] [clang] [clang] add fallback to expr in the template differ when comparing ValueDecl (PR #93266)
Matheus Izvekov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri May 24 07:29:20 PDT 2024
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/93266
>From e74a7e69381731465efb8332890e0ebdc061fbb1 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Thu, 23 May 2024 23:57:01 -0300
Subject: [PATCH 1/2] [clang] add fallback to expr in the template differ when
comparing ValueDecl
---
clang/docs/ReleaseNotes.rst | 1 +
clang/lib/AST/ASTDiagnostic.cpp | 5 +++++
clang/test/Misc/diag-template-diffing-cxx26.cpp | 4 ++--
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6e8687fadc6f7..5e217a76c81a1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -784,6 +784,7 @@ Miscellaneous Bug Fixes
- Fixed an infinite recursion in ASTImporter, on return type declared inside
body of C++11 lambda without trailing return (#GH68775).
- Fixed declaration name source location of instantiated function definitions (GH71161).
+- Missing fallback to expression in the template differ when comparing ValueDecls.
Miscellaneous Clang Crashes Fixed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 7e4a5709a44ce..1885b21178666 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -1936,6 +1936,11 @@ class TemplateDiff {
return;
}
+ if (E) {
+ PrintExpr(E);
+ return;
+ }
+
OS << "(no argument)";
}
diff --git a/clang/test/Misc/diag-template-diffing-cxx26.cpp b/clang/test/Misc/diag-template-diffing-cxx26.cpp
index cc174d6c334fb..2b6dd86a9885d 100644
--- a/clang/test/Misc/diag-template-diffing-cxx26.cpp
+++ b/clang/test/Misc/diag-template-diffing-cxx26.cpp
@@ -19,10 +19,10 @@ namespace GH93068 {
// expected-note@#A {{no known conversion from 'A<0>' to 'const A<&n[1]> &' for 1st argument}}
// expected-note@#A {{no known conversion from 'A<0>' to 'A<&n[1]> &&' for 1st argument}}
- // notree-error@#2 {{no viable conversion from 'A<n>' to 'A<(no argument)>'}}
+ // notree-error@#2 {{no viable conversion from 'A<n>' to 'A<n + 1>'}}
/* tree-error@#2 {{no viable conversion
A<
- [n != (no argument)]>}}*/
+ [n != n + 1]>}}*/
A<n + 1> v2 = A<n>(); // #2
// expected-note@#A {{no known conversion from 'A<n>' to 'const A<&n[1]> &' for 1st argument}}
>From 4b12139395d8bcabd053ed6db11aa049ee95d5c3 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Fri, 24 May 2024 11:29:13 -0300
Subject: [PATCH 2/2] Update clang/docs/ReleaseNotes.rst
Co-authored-by: Erich Keane <ekeane at nvidia.com>
---
clang/docs/ReleaseNotes.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5e217a76c81a1..a63b0c2460cd7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -784,7 +784,7 @@ Miscellaneous Bug Fixes
- Fixed an infinite recursion in ASTImporter, on return type declared inside
body of C++11 lambda without trailing return (#GH68775).
- Fixed declaration name source location of instantiated function definitions (GH71161).
-- Missing fallback to expression in the template differ when comparing ValueDecls.
+- Improve diagnostic output to print an expression instead of 'no argument` when comparing Values as template arguments.
Miscellaneous Clang Crashes Fixed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
More information about the llvm-branch-commits
mailing list