summaryrefslogtreecommitdiffstats
path: root/lld/Common/Strings.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2019-09-27 12:24:03 +0000
committerMartin Storsjo <martin@martin.st>2019-09-27 12:24:03 +0000
commitdd71b2d4c31c72cb58c95c07c1eb7175fe16e7a9 (patch)
treecf8a6fc9b95f14d4ee565831018075c286782f4c /lld/Common/Strings.cpp
parentbf6f4e99329ec2e038904e73193f0e9fe2fc128a (diff)
downloadbcm5719-llvm-dd71b2d4c31c72cb58c95c07c1eb7175fe16e7a9.tar.gz
bcm5719-llvm-dd71b2d4c31c72cb58c95c07c1eb7175fe16e7a9.zip
[LLD] Convert demangleItanium to use the higher level llvm::demangle function. NFC.
This avoids a few lines of boilerplate of dealing with C string allocations. Add a testcase for a case where demangling shouldn't happen. Differential Revision: https://reviews.llvm.org/D68014 llvm-svn: 373076
Diffstat (limited to 'lld/Common/Strings.cpp')
-rw-r--r--lld/Common/Strings.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/lld/Common/Strings.cpp b/lld/Common/Strings.cpp
index 5cb44e9a8fe..4b40abeda5e 100644
--- a/lld/Common/Strings.cpp
+++ b/lld/Common/Strings.cpp
@@ -22,18 +22,16 @@ using namespace lld;
Optional<std::string> lld::demangleItanium(StringRef name) {
// itaniumDemangle can be used to demangle strings other than symbol
// names which do not necessarily start with "_Z". Name can be
- // either a C or C++ symbol. Don't call itaniumDemangle if the name
+ // either a C or C++ symbol. Don't call demangle if the name
// does not look like a C++ symbol name to avoid getting unexpected
// result for a C symbol that happens to match a mangled type name.
if (!name.startswith("_Z"))
return None;
- char *buf = itaniumDemangle(name.str().c_str(), nullptr, nullptr, nullptr);
- if (!buf)
+ std::string demangled = demangle(name);
+ if (demangled == name)
return None;
- std::string s(buf);
- free(buf);
- return s;
+ return demangled;
}
StringMatcher::StringMatcher(ArrayRef<StringRef> pat) {
OpenPOWER on IntegriCloud