]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Demangle/Demangle.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Demangle / Demangle.h
1 //===--- Demangle.h ---------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_DEMANGLE_DEMANGLE_H
11 #define LLVM_DEMANGLE_DEMANGLE_H
12
13 #include <cstddef>
14
15 namespace llvm {
16 /// This is a llvm local version of __cxa_demangle. Other than the name and
17 /// being in the llvm namespace it is identical.
18 ///
19 /// The mangled_name is demangled into buf and returned. If the buffer is not
20 /// large enough, realloc is used to expand it.
21 ///
22 /// The *status will be set to a value from the following enumeration
23 enum : int {
24   demangle_unknown_error = -4,
25   demangle_invalid_args = -3,
26   demangle_invalid_mangled_name = -2,
27   demangle_memory_alloc_failure = -1,
28   demangle_success = 0,
29 };
30
31 char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n,
32                       int *status);
33
34
35 enum MSDemangleFlags { MSDF_None = 0, MSDF_DumpBackrefs = 1 << 0 };
36 char *microsoftDemangle(const char *mangled_name, char *buf, size_t *n,
37                         int *status, MSDemangleFlags Flags = MSDF_None);
38
39 /// "Partial" demangler. This supports demangling a string into an AST
40 /// (typically an intermediate stage in itaniumDemangle) and querying certain
41 /// properties or partially printing the demangled name.
42 struct ItaniumPartialDemangler {
43   ItaniumPartialDemangler();
44
45   ItaniumPartialDemangler(ItaniumPartialDemangler &&Other);
46   ItaniumPartialDemangler &operator=(ItaniumPartialDemangler &&Other);
47
48   /// Demangle into an AST. Subsequent calls to the rest of the member functions
49   /// implicitly operate on the AST this produces.
50   /// \return true on error, false otherwise
51   bool partialDemangle(const char *MangledName);
52
53   /// Just print the entire mangled name into Buf. Buf and N behave like the
54   /// second and third parameters to itaniumDemangle.
55   char *finishDemangle(char *Buf, size_t *N) const;
56
57   /// Get the base name of a function. This doesn't include trailing template
58   /// arguments, ie for "a::b<int>" this function returns "b".
59   char *getFunctionBaseName(char *Buf, size_t *N) const;
60
61   /// Get the context name for a function. For "a::b::c", this function returns
62   /// "a::b".
63   char *getFunctionDeclContextName(char *Buf, size_t *N) const;
64
65   /// Get the entire name of this function.
66   char *getFunctionName(char *Buf, size_t *N) const;
67
68   /// Get the parameters for this function.
69   char *getFunctionParameters(char *Buf, size_t *N) const;
70   char *getFunctionReturnType(char *Buf, size_t *N) const;
71
72   /// If this function has any any cv or reference qualifiers. These imply that
73   /// the function is a non-static member function.
74   bool hasFunctionQualifiers() const;
75
76   /// If this symbol describes a constructor or destructor.
77   bool isCtorOrDtor() const;
78
79   /// If this symbol describes a function.
80   bool isFunction() const;
81
82   /// If this symbol describes a variable.
83   bool isData() const;
84
85   /// If this symbol is a <special-name>. These are generally implicitly
86   /// generated by the implementation, such as vtables and typeinfo names.
87   bool isSpecialName() const;
88
89   ~ItaniumPartialDemangler();
90 private:
91   void *RootNode;
92   void *Context;
93 };
94 } // namespace llvm
95
96 #endif