kamleshbhalui updated this revision to Diff 233919. kamleshbhalui added a comment.
added validation check in testcase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70537/new/ https://reviews.llvm.org/D70537 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGenCXX/pr42710.cpp Index: clang/test/CodeGenCXX/pr42710.cpp =================================================================== --- /dev/null +++ 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<typename ...> + inline static const int identifier = counter++; + + template<typename... Args> + inline static const int value = identifier<Args...>; + +}; + +int main() +{ + return TypeId::value<int>; +} +} + +// 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<typename ...> + inline static const auto identifier = counter++; + + template<typename... Args> + inline static const auto value = identifier<Args...>; +}; + +int main() +{ + return TypeId::value<int>; +} +} + Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -1428,6 +1428,10 @@ if (isa<VarTemplatePartialSpecializationDecl>(V)) continue; + if (isa<VarTemplateSpecializationDecl>(V) + && V->getType()->isUndeducedType()) + continue; + // Reuse the existing static member declaration if one exists auto MI = StaticDataMemberCache.find(V->getCanonicalDecl()); if (MI != StaticDataMemberCache.end()) {
Index: clang/test/CodeGenCXX/pr42710.cpp =================================================================== --- /dev/null +++ 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<typename ...> + inline static const int identifier = counter++; + + template<typename... Args> + inline static const int value = identifier<Args...>; + +}; + +int main() +{ + return TypeId::value<int>; +} +} + +// 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<typename ...> + inline static const auto identifier = counter++; + + template<typename... Args> + inline static const auto value = identifier<Args...>; +}; + +int main() +{ + return TypeId::value<int>; +} +} + Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -1428,6 +1428,10 @@ if (isa<VarTemplatePartialSpecializationDecl>(V)) continue; + if (isa<VarTemplateSpecializationDecl>(V) + && V->getType()->isUndeducedType()) + continue; + // Reuse the existing static member declaration if one exists auto MI = StaticDataMemberCache.find(V->getCanonicalDecl()); if (MI != StaticDataMemberCache.end()) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits