DebugInfo: workaround for context-sensitive use of non-type-template-parameter intege...
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 20 Sep 2021 03:58:47 +0000 (20:58 -0700)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 2 Nov 2021 00:08:26 +0000 (17:08 -0700)
commit8bf12445383b2f3149a9d095bfbc0f6d5b00dfaa
tree3c5e077f7aab7cf4e2bfc40b5fdf391aca456b82
parent0d59efbba4e99140ef2dfb5c9f14a9d641e0ebe2
DebugInfo: workaround for context-sensitive use of non-type-template-parameter integer suffixes

There's a nuanced check about when to use suffixes on these integer
non-type-template-parameters, but when rebuilding names for
-gsimple-template-names there isn't enough data in the DWARF to
determine when to use suffixes or not. So turn on suffixes always to
make it easy to match up names in llvm-dwarfdump --verify.

I /think/ if we correctly modelled auto non-type-template parameters
maybe we could put suffixes only on those. But there's also some logic
in Clang that puts the suffixes on overloaded functions - at least
that's what the parameter says (see D77598 and printTemplateArguments
"TemplOverloaded" parameter) - but I think maybe it's for anything that
/can/ be overloaded, not necessarily only the things that are overloaded
(the argument value is hardcoded at the various callsites, doesn't seem
to depend on overload resolution/searching for overloaded functions). So
maybe with "auto" modeled more accurately, and differentiating between
function templates (always using type suffixes there) and class/variable
templates (only using the suffix for "auto" types) we could correctly
use integer type suffixes only in the minimal set of cases.

But that seems all too much fuss, so let's just put integer type
suffixes everywhere always in the debug info of integer non-type
template parameters in template names.

(more context:
* https://reviews.llvm.org/D77598#inline-1057607
* https://groups.google.com/g/llvm-dev/c/ekLMllbLIZg/m/-dhJ0hO1AAAJ )

Differential Revision: https://reviews.llvm.org/D111477
12 files changed:
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/AST/PrettyPrinter.h
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/DeclTemplate.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CodeGenCXX/debug-info-template.cpp
clang/test/Modules/lsv-debuginfo.cpp
libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp