[PATCH] D68015: [LLD] Simplify the demangleItanium function. NFC.
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 05:25:00 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373077: [LLD] Simplify the demangleItanium function. NFC. (authored by mstorsjo, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D68015?vs=221709&id=222144#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68015/new/
https://reviews.llvm.org/D68015
Files:
lld/trunk/Common/Strings.cpp
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/Symbols.cpp
lld/trunk/include/lld/Common/Strings.h
lld/trunk/wasm/Symbols.cpp
Index: lld/trunk/Common/Strings.cpp
===================================================================
--- lld/trunk/Common/Strings.cpp
+++ lld/trunk/Common/Strings.cpp
@@ -18,20 +18,17 @@
using namespace llvm;
using namespace lld;
-// Returns the demangled C++ symbol name for Name.
-Optional<std::string> lld::demangleItanium(StringRef name) {
+// Returns the demangled C++ symbol name for name.
+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 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;
+ return name;
- std::string demangled = demangle(name);
- if (demangled == name)
- return None;
- return demangled;
+ return demangle(name);
}
StringMatcher::StringMatcher(ArrayRef<StringRef> pat) {
Index: lld/trunk/include/lld/Common/Strings.h
===================================================================
--- lld/trunk/include/lld/Common/Strings.h
+++ lld/trunk/include/lld/Common/Strings.h
@@ -18,8 +18,8 @@
namespace lld {
// Returns a demangled C++ symbol name. If Name is not a mangled
-// name, it returns Optional::None.
-llvm::Optional<std::string> demangleItanium(llvm::StringRef name);
+// name, it returns name.
+std::string demangleItanium(llvm::StringRef name);
std::vector<uint8_t> parseHex(llvm::StringRef s);
bool isValidCIdentifier(llvm::StringRef s);
Index: lld/trunk/wasm/Symbols.cpp
===================================================================
--- lld/trunk/wasm/Symbols.cpp
+++ lld/trunk/wasm/Symbols.cpp
@@ -304,8 +304,7 @@
std::string lld::maybeDemangleSymbol(StringRef name) {
if (config->demangle)
- if (Optional<std::string> s = demangleItanium(name))
- return *s;
+ return demangleItanium(name);
return name;
}
Index: lld/trunk/ELF/Symbols.cpp
===================================================================
--- lld/trunk/ELF/Symbols.cpp
+++ lld/trunk/ELF/Symbols.cpp
@@ -45,8 +45,7 @@
// Returns a symbol for an error message.
static std::string demangle(StringRef symName) {
if (config->demangle)
- if (Optional<std::string> s = demangleItanium(symName))
- return *s;
+ return demangleItanium(symName);
return symName;
}
namespace lld {
Index: lld/trunk/ELF/SymbolTable.cpp
===================================================================
--- lld/trunk/ELF/SymbolTable.cpp
+++ lld/trunk/ELF/SymbolTable.cpp
@@ -123,10 +123,7 @@
for (Symbol *sym : symVector) {
if (!sym->isDefined() && !sym->isCommon())
continue;
- if (Optional<std::string> s = demangleItanium(sym->getName()))
- (*demangledSyms)[*s].push_back(sym);
- else
- (*demangledSyms)[sym->getName()].push_back(sym);
+ (*demangledSyms)[demangleItanium(sym->getName())].push_back(sym);
}
}
return *demangledSyms;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68015.222144.patch
Type: text/x-patch
Size: 3098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190927/7600e4d7/attachment.bin>
More information about the llvm-commits
mailing list