summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Demangle/ItaniumDemangle.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-07-17 19:42:29 +0000
committerZachary Turner <zturner@google.com>2018-07-17 19:42:29 +0000
commit8a0efd09190e75c283dc929a8c739c76b5d0917e (patch)
tree9b24026fede8e8207d0651fb280367a3feda4a5f /llvm/lib/Demangle/ItaniumDemangle.cpp
parentf989a92dea46f96548bdc83a394ff0a12c5ffa6b (diff)
downloadbcm5719-llvm-8a0efd09190e75c283dc929a8c739c76b5d0917e.tar.gz
bcm5719-llvm-8a0efd09190e75c283dc929a8c739c76b5d0917e.zip
Add some helper functions to the demangle utility classes.
These are all methods that, while not currently used in the Itanium demangler, are generally useful enough that it's likely the itanium demangler could find a use for them. More importantly, they are all necessary for the Microsoft demangler which is up and coming in a subsequent patch. Rather than combine these into a single monolithic patch, I think it makes sense to commit this utility code first since it is very simple, this way it won't detract from the substance of the MS demangler patch. llvm-svn: 337316
Diffstat (limited to 'llvm/lib/Demangle/ItaniumDemangle.cpp')
-rw-r--r--llvm/lib/Demangle/ItaniumDemangle.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/llvm/lib/Demangle/ItaniumDemangle.cpp b/llvm/lib/Demangle/ItaniumDemangle.cpp
index 31cac48dcf3..10ec84815e9 100644
--- a/llvm/lib/Demangle/ItaniumDemangle.cpp
+++ b/llvm/lib/Demangle/ItaniumDemangle.cpp
@@ -4925,32 +4925,24 @@ bool initializeOutputStream(char *Buf, size_t *N, OutputStream &S,
} // unnamed namespace
-enum {
- unknown_error = -4,
- invalid_args = -3,
- invalid_mangled_name = -2,
- memory_alloc_failure = -1,
- success = 0,
-};
-
char *llvm::itaniumDemangle(const char *MangledName, char *Buf,
size_t *N, int *Status) {
if (MangledName == nullptr || (Buf != nullptr && N == nullptr)) {
if (Status)
- *Status = invalid_args;
+ *Status = demangle_invalid_args;
return nullptr;
}
- int InternalStatus = success;
+ int InternalStatus = demangle_success;
Db Parser(MangledName, MangledName + std::strlen(MangledName));
OutputStream S;
Node *AST = Parser.parse();
if (AST == nullptr)
- InternalStatus = invalid_mangled_name;
+ InternalStatus = demangle_invalid_mangled_name;
else if (initializeOutputStream(Buf, N, S, 1024))
- InternalStatus = memory_alloc_failure;
+ InternalStatus = demangle_memory_alloc_failure;
else {
assert(Parser.ForwardTemplateRefs.empty());
AST->print(S);
@@ -4962,7 +4954,7 @@ char *llvm::itaniumDemangle(const char *MangledName, char *Buf,
if (Status)
*Status = InternalStatus;
- return InternalStatus == success ? Buf : nullptr;
+ return InternalStatus == demangle_success ? Buf : nullptr;
}
namespace llvm {
OpenPOWER on IntegriCloud