diff options
author | Amy Huang <akhuang@google.com> | 2021-01-29 12:08:35 -0800 |
---|---|---|
committer | Amy Huang <akhuang@google.com> | 2021-02-05 09:49:11 -0800 |
commit | a740af4de970405fd7196219307a1e4cc53a35cf (patch) | |
tree | 3c9644552753cae51e2eb53587690b26537e51f2 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | |
parent | 0f3fd3b2810d7549d5cf7356b269701d5c5032fa (diff) | |
download | llvm-a740af4de970405fd7196219307a1e4cc53a35cf.zip llvm-a740af4de970405fd7196219307a1e4cc53a35cf.tar.gz llvm-a740af4de970405fd7196219307a1e4cc53a35cf.tar.bz2 |
[CodeView][DebugInfo] Update the code for removing template arguments from the display name of a codeview function id.
Previously the code split the string at the first '<', which
incorrectly truncated names like `operator<`.
Differential Revision: https://reviews.llvm.org/D95893
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index b15e750..08eb206 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -358,6 +358,25 @@ TypeIndex CodeViewDebug::getScopeIndex(const DIScope *Scope) { return recordTypeIndexForDINode(Scope, TI); } +static StringRef removeTemplateArgs(StringRef Name) { + // Remove template args from the display name. Assume that the template args + // are the last thing in the name. + if (Name.empty() || Name.back() != '>') + return Name; + + int OpenBrackets = 0; + for (size_t i = Name.size() - 1; i >= 0; --i) { + if (Name[i] == '>') + ++OpenBrackets; + else if (Name[i] == '<') { + --OpenBrackets; + if (OpenBrackets == 0) + return Name.substr(0, i); + } + } + return Name; +} + TypeIndex CodeViewDebug::getFuncIdForSubprogram(const DISubprogram *SP) { assert(SP); @@ -367,8 +386,9 @@ TypeIndex CodeViewDebug::getFuncIdForSubprogram(const DISubprogram *SP) { return I->second; // The display name includes function template arguments. Drop them to match - // MSVC. - StringRef DisplayName = SP->getName().split('<').first; + // MSVC. We need to have the template arguments in the DISubprogram name + // because they are used in other symbol records, such as S_GPROC32_IDs. + StringRef DisplayName = removeTemplateArgs(SP->getName()); const DIScope *Scope = SP->getScope(); TypeIndex TI; |