forked from OSchip/llvm-project
DebugInfo: Include default template arguments in template type names
This was committed 4 years ago in 108916 with insufficient testing to explain why the "getTypeAsWritten" case was appropriate. Experience says that it isn't - the presence or absence of an explicit instantiation declaration was causing this code to generate either i<int> or i<int, int>. That didn't seem to be a useful distinction, and omitting the template arguments was destructive to debuggers being able to associate the two types across translation units or across compilers (GCC, reasonably, never omitted the arguments). llvm-svn: 205447
This commit is contained in:
parent
20b0790df7
commit
65813a3bce
|
@ -228,34 +228,20 @@ StringRef CGDebugInfo::getSelectorName(Selector S) {
|
||||||
/// getClassName - Get class name including template argument list.
|
/// getClassName - Get class name including template argument list.
|
||||||
StringRef
|
StringRef
|
||||||
CGDebugInfo::getClassName(const RecordDecl *RD) {
|
CGDebugInfo::getClassName(const RecordDecl *RD) {
|
||||||
const ClassTemplateSpecializationDecl *Spec
|
// quick optimization to avoid having to intern strings that are already
|
||||||
= dyn_cast<ClassTemplateSpecializationDecl>(RD);
|
// stored reliably elsewhere
|
||||||
if (!Spec)
|
if (!isa<ClassTemplateSpecializationDecl>(RD))
|
||||||
return RD->getName();
|
return RD->getName();
|
||||||
|
|
||||||
const TemplateArgument *Args;
|
SmallString<128> Name;
|
||||||
unsigned NumArgs;
|
|
||||||
if (TypeSourceInfo *TAW = Spec->getTypeAsWritten()) {
|
|
||||||
const TemplateSpecializationType *TST =
|
|
||||||
cast<TemplateSpecializationType>(TAW->getType());
|
|
||||||
Args = TST->getArgs();
|
|
||||||
NumArgs = TST->getNumArgs();
|
|
||||||
} else {
|
|
||||||
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
|
|
||||||
Args = TemplateArgs.data();
|
|
||||||
NumArgs = TemplateArgs.size();
|
|
||||||
}
|
|
||||||
StringRef Name = RD->getIdentifier()->getName();
|
|
||||||
PrintingPolicy Policy(CGM.getLangOpts());
|
|
||||||
SmallString<128> TemplateArgList;
|
|
||||||
{
|
{
|
||||||
llvm::raw_svector_ostream OS(TemplateArgList);
|
llvm::raw_svector_ostream OS(Name);
|
||||||
TemplateSpecializationType::PrintTemplateArgumentList(OS, Args, NumArgs,
|
RD->getNameForDiagnostic(OS, CGM.getContext().getPrintingPolicy(),
|
||||||
Policy);
|
/*Qualified*/ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy this name on the side and use its reference.
|
// Copy this name on the side and use its reference.
|
||||||
return internString(Name, TemplateArgList);
|
return internString(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getOrCreateFile - Get the file debug info descriptor for the input location.
|
/// getOrCreateFile - Get the file debug info descriptor for the input location.
|
||||||
|
|
|
@ -84,3 +84,10 @@ template<> void i<int>::f();
|
||||||
extern template class i<int>;
|
extern template class i<int>;
|
||||||
i<int> ii;
|
i<int> ii;
|
||||||
// CHECK: ; [ DW_TAG_structure_type ] [i<int>] {{.*}} [def]
|
// CHECK: ; [ DW_TAG_structure_type ] [i<int>] {{.*}} [def]
|
||||||
|
|
||||||
|
template <typename T1, typename T2 = T1>
|
||||||
|
struct j {
|
||||||
|
};
|
||||||
|
extern template class j<int>;
|
||||||
|
j<int> jj;
|
||||||
|
// CHECK: ; [ DW_TAG_structure_type ] [j<int, int>]
|
||||||
|
|
Loading…
Reference in New Issue