aboutsummaryrefslogtreecommitdiff
path: root/deps/lld/Common/Strings.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-17 17:29:21 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-01-17 17:29:21 -0500
commit4aed7ea6f89a091aede10ccf0fb45b3ce12c710d (patch)
tree1e29f13ad17bfc841c33f6ac3d0ccb092404f409 /deps/lld/Common/Strings.cpp
parent48cd808185f54e935714539d101585a9a0a41673 (diff)
downloadzig-4aed7ea6f89a091aede10ccf0fb45b3ce12c710d.tar.gz
zig-4aed7ea6f89a091aede10ccf0fb45b3ce12c710d.zip
update embedded LLD to 6.0.0rc1
Diffstat (limited to 'deps/lld/Common/Strings.cpp')
-rw-r--r--deps/lld/Common/Strings.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/deps/lld/Common/Strings.cpp b/deps/lld/Common/Strings.cpp
new file mode 100644
index 0000000000..6cd4ad8d60
--- /dev/null
+++ b/deps/lld/Common/Strings.cpp
@@ -0,0 +1,32 @@
+//===- Strings.cpp -------------------------------------------------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lld/Common/Strings.h"
+#include "llvm/Demangle/Demangle.h"
+
+using namespace llvm;
+using namespace lld;
+
+// Returns the demangled C++ symbol name for Name.
+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
+ // 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)
+ return None;
+ std::string S(Buf);
+ free(Buf);
+ return S;
+}