aboutsummaryrefslogtreecommitdiffstats
path: root/Common/Strings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Common/Strings.cpp')
-rw-r--r--Common/Strings.cpp34
1 files changed, 6 insertions, 28 deletions
diff --git a/Common/Strings.cpp b/Common/Strings.cpp
index 0bf06626cc7a..627435f141da 100644
--- a/Common/Strings.cpp
+++ b/Common/Strings.cpp
@@ -18,39 +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 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;
+ return name;
- char *buf = itaniumDemangle(name.str().c_str(), nullptr, nullptr, nullptr);
- if (!buf)
- return None;
- std::string s(buf);
- free(buf);
- return s;
-}
-
-Optional<std::string> lld::demangleMSVC(StringRef name) {
- std::string prefix;
- if (name.consume_front("__imp_"))
- prefix = "__declspec(dllimport) ";
-
- // Demangle only C++ names.
- if (!name.startswith("?"))
- return None;
-
- char *buf = microsoftDemangle(name.str().c_str(), nullptr, nullptr, nullptr);
- if (!buf)
- return None;
- std::string s(buf);
- free(buf);
- return prefix + s;
+ return demangle(name);
}
StringMatcher::StringMatcher(ArrayRef<StringRef> pat) {
@@ -96,7 +74,7 @@ bool lld::isValidCIdentifier(StringRef s) {
// Write the contents of the a buffer to a file
void lld::saveBuffer(StringRef buffer, const Twine &path) {
std::error_code ec;
- raw_fd_ostream os(path.str(), ec, sys::fs::OpenFlags::F_None);
+ raw_fd_ostream os(path.str(), ec, sys::fs::OpenFlags::OF_None);
if (ec)
error("cannot create " + path + ": " + ec.message());
os << buffer;