Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -1433,6 +1433,9 @@ if (isa(V)) continue; + if (isa(V)) + 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,18 @@ +// RUN: %clang %s -S -emit-llvm -g -o - -std=c++17 +// expected-no-diagnostics + +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; +}