1 //===--- Demangle.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
13 /// This is a llvm local version of __cxa_demangle. Other than the name and
14 /// being in the llvm namespace it is identical.
16 /// The mangled_name is demangled into buf and returned. If the buffer is not
17 /// large enough, realloc is used to expand it.
19 /// The *status will be set to a value from the following enumeration
21 demangle_unknown_error = -4,
22 demangle_invalid_args = -3,
23 demangle_invalid_mangled_name = -2,
24 demangle_memory_alloc_failure = -1,
28 char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n,
30 char *microsoftDemangle(const char *mangled_name, char *buf, size_t *n,
33 /// "Partial" demangler. This supports demangling a string into an AST
34 /// (typically an intermediate stage in itaniumDemangle) and querying certain
35 /// properties or partially printing the demangled name.
36 struct ItaniumPartialDemangler {
37 ItaniumPartialDemangler();
39 ItaniumPartialDemangler(ItaniumPartialDemangler &&Other);
40 ItaniumPartialDemangler &operator=(ItaniumPartialDemangler &&Other);
42 /// Demangle into an AST. Subsequent calls to the rest of the member functions
43 /// implicitly operate on the AST this produces.
44 /// \return true on error, false otherwise
45 bool partialDemangle(const char *MangledName);
47 /// Just print the entire mangled name into Buf. Buf and N behave like the
48 /// second and third parameters to itaniumDemangle.
49 char *finishDemangle(char *Buf, size_t *N) const;
51 /// Get the base name of a function. This doesn't include trailing template
52 /// arguments, ie for "a::b<int>" this function returns "b".
53 char *getFunctionBaseName(char *Buf, size_t *N) const;
55 /// Get the context name for a function. For "a::b::c", this function returns
57 char *getFunctionDeclContextName(char *Buf, size_t *N) const;
59 /// Get the entire name of this function.
60 char *getFunctionName(char *Buf, size_t *N) const;
62 /// Get the parameters for this function.
63 char *getFunctionParameters(char *Buf, size_t *N) const;
64 char *getFunctionReturnType(char *Buf, size_t *N) const;
66 /// If this function has any any cv or reference qualifiers. These imply that
67 /// the function is a non-static member function.
68 bool hasFunctionQualifiers() const;
70 /// If this symbol describes a constructor or destructor.
71 bool isCtorOrDtor() const;
73 /// If this symbol describes a function.
74 bool isFunction() const;
76 /// If this symbol describes a variable.
79 /// If this symbol is a <special-name>. These are generally implicitly
80 /// generated by the implementation, such as vtables and typeinfo names.
81 bool isSpecialName() const;
83 ~ItaniumPartialDemangler();