Author: David Blaikie
Date: 2022-04-08T00:00:46Z
New Revision: 1cee3d9db77b2c62a03efe1cce45f627dcbe6457

URL: 
https://github.com/llvm/llvm-project/commit/1cee3d9db77b2c62a03efe1cce45f627dcbe6457
DIFF: 
https://github.com/llvm/llvm-project/commit/1cee3d9db77b2c62a03efe1cce45f627dcbe6457.diff

LOG: DebugInfo: Consider the type of NTTP when simplifying template names

Since the NTTP may need to be cast to the type when rebuilding the name,
check that the type can be rebuilt when determining whether a template
name can be simplified.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGDebugInfo.cpp
    clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
    
cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 63b89f258a8ac..c18dbccf82936 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5167,7 +5167,8 @@ std::string CGDebugInfo::GetName(const Decl *D, bool 
Qualified) const {
             // harder to parse back into a large integer, etc - so punting on
             // this for now. Re-parsing the integers back into APInt is 
probably
             // feasible some day.
-            return TA.getAsIntegral().getBitWidth() <= 64;
+            return TA.getAsIntegral().getBitWidth() <= 64 &&
+                   IsReconstitutableType(TA.getIntegralType());
           case TemplateArgument::Type:
             return IsReconstitutableType(TA.getAsType());
           default:

diff  --git a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp 
b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
index 190d121937a03..98faa0fc6f0bb 100644
--- a/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
+++ b/clang/test/CodeGenCXX/debug-info-simple-template-names.cpp
@@ -31,6 +31,10 @@ struct t4 {
 };
   
 t4 v1;
+enum { UnnamedEnum1 };
+template<decltype(UnnamedEnum1)>
+void f4() {
+}
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "t3<(anonymous 
namespace)::LocalEnum, ((anonymous namespace)::LocalEnum)0>"
 void f() {
   // Basic examples of simplifiable/rebuildable names
@@ -122,4 +126,7 @@ void f() {
   int fnrt() __attribute__((noreturn));
   f1<decltype(fnrt)>();
   // CHECK: !DISubprogram(name: "f1<int () __attribute__((noreturn))>",
+  
+  f4<UnnamedEnum1>();
+  // CHECK: !DISubprogram(name: "f4<((unnamed enum at {{.*}}))0>"
 }

diff  --git 
a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
 
b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
index 9bc14f8ce6577..b68d4e8c04b94 100644
--- 
a/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
+++ 
b/cross-project-tests/debuginfo-tests/clang_llvm_roundtrip/simplified_template_names.cpp
@@ -179,6 +179,10 @@ struct t12 {
   t11<LocalEnum, LocalEnum1> v1;
 };
 
+template<decltype(ns::AnonEnum1)>
+void f10() {
+}
+
 int main() {
   struct { } A;
   auto L = []{};
@@ -327,6 +331,7 @@ int main() {
   f1<decltype(fcc)>();
   int fnrt() __attribute__((noreturn));
   f1<decltype(fnrt)>();
+  f10<ns::AnonEnum1>();
 }
 void t8::mem() {
   struct t7 { };


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to