[lld] r233460 - ELF: Do less if HAVE_CXXABI_H is not defined.
Rui Ueyama
ruiu at google.com
Fri Mar 27 17:47:13 PDT 2015
Author: ruiu
Date: Fri Mar 27 19:47:13 2015
New Revision: 233460
URL: http://llvm.org/viewvc/llvm-project?rev=233460&view=rev
Log:
ELF: Do less if HAVE_CXXABI_H is not defined.
If HAVE_CXXABI_H is not defined, this function is the identity function.
Because HAVE_CXXABI_H did not protect the entire function, it did
extra stuffs before returning the argument.
The new code calls fewer functions. This should help developers understand
this piece of code.
Modified:
lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=233460&r1=233459&r2=233460&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Fri Mar 27 19:47:13 2015
@@ -219,6 +219,7 @@ void ELFLinkingContext::notifySymbolTabl
}
std::string ELFLinkingContext::demangle(StringRef symbolName) const {
+#if defined(HAVE_CXXABI_H)
if (!demangleSymbols())
return symbolName;
@@ -226,21 +227,20 @@ std::string ELFLinkingContext::demangle(
if (!symbolName.startswith("_Z"))
return symbolName;
-#if defined(HAVE_CXXABI_H)
SmallString<256> symBuff;
StringRef nullTermSym = Twine(symbolName).toNullTerminatedStringRef(symBuff);
const char *cstr = nullTermSym.data();
int status;
char *demangled = abi::__cxa_demangle(cstr, nullptr, nullptr, &status);
- if (demangled != NULL) {
- std::string result(demangled);
- // __cxa_demangle() always uses a malloc'ed buffer to return the result.
- free(demangled);
- return result;
- }
-#endif
-
+ if (demangled == NULL)
+ return symbolName;
+ std::string result(demangled);
+ // __cxa_demangle() always uses a malloc'ed buffer to return the result.
+ free(demangled);
+ return result;
+#else
return symbolName;
+#endif
}
void ELFLinkingContext::setUndefinesResolver(std::unique_ptr<File> resolver) {
More information about the llvm-commits
mailing list