]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Demangle/Demangle.h
Merge clang 7.0.1 and several follow-up changes
[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 #include <cstddef>
11
12 namespace llvm {
13 /// This is a llvm local version of __cxa_demangle. Other than the name and
14 /// being in the llvm namespace it is identical.
15 ///
16 /// The mangled_name is demangled into buf and returned. If the buffer is not
17 /// large enough, realloc is used to expand it.
18 ///
19 /// The *status will be set to a value from the following enumeration
20 enum : int {
21   demangle_unknown_error = -4,
22   demangle_invalid_args = -3,
23   demangle_invalid_mangled_name = -2,
24   demangle_memory_alloc_failure = -1,
25   demangle_success = 0,
26 };
27
28 char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n,
29                       int *status);
30 char *microsoftDemangle(const char *mangled_name, char *buf, size_t *n,
31                         int *status);
32
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();
38
39   ItaniumPartialDemangler(ItaniumPartialDemangler &&Other);
40   ItaniumPartialDemangler &operator=(ItaniumPartialDemangler &&Other);
41
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);
46
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;
50
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;
54
55   /// Get the context name for a function. For "a::b::c", this function returns
56   /// "a::b".
57   char *getFunctionDeclContextName(char *Buf, size_t *N) const;
58
59   /// Get the entire name of this function.
60   char *getFunctionName(char *Buf, size_t *N) const;
61
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;
65
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;
69
70   /// If this symbol describes a constructor or destructor.
71   bool isCtorOrDtor() const;
72
73   /// If this symbol describes a function.
74   bool isFunction() const;
75
76   /// If this symbol describes a variable.
77   bool isData() const;
78
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;
82
83   ~ItaniumPartialDemangler();
84 private:
85   void *RootNode;
86   void *Context;
87 };
88 } // namespace llvm