diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1428,6 +1428,10 @@ if (isa(V)) continue; + if (isa(V) + && V->getType()->isUndeducedType()) + continue; + // Reuse the existing static member declaration if one exists auto MI = StaticDataMemberCache.find(V->getCanonicalDecl()); if (MI != StaticDataMemberCache.end()) { diff --git a/clang/test/CodeGenCXX/pr42710.cpp b/clang/test/CodeGenCXX/pr42710.cpp new file mode 100644 --- /dev/null +++ b/clang/test/CodeGenCXX/pr42710.cpp @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -std=c++17 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=CHECK + +namespace INT { +struct TypeId +{ + inline static int counter{}; + + template + inline static const int identifier = counter++; + + template + inline static const int value = identifier; + +}; + +int main() +{ + return TypeId::value; +} +} + +// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "identifier", linkageName: "_ZN3INT6TypeId10identifierIJiEEE" +// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "identifier", linkageName: "_ZN4AUTO6TypeId10identifierIJiEEE" +// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "counter", linkageName: "_ZN3INT6TypeId7counterE" +// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "value", linkageName: "_ZN3INT6TypeId5valueIJiEEE" +// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "counter", linkageName: "_ZN4AUTO6TypeId7counterE" +// CHECK: ![[L:[0-9]+]] = distinct !DIGlobalVariable(name: "value", linkageName: "_ZN4AUTO6TypeId5valueIJiEEE" + +namespace AUTO { +struct TypeId +{ + inline static int counter{}; + + template + inline static const auto identifier = counter++; + + template + inline static const auto value = identifier; +}; + +int main() +{ + return TypeId::value; +} +} +