LLVM  8.0.1
Demangle.h
Go to the documentation of this file.
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 {
29 };
30 
31 char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n,
32  int *status);
33 
34 
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.
44 
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 
90 private:
91  void *RootNode;
92  void *Context;
93 };
94 } // namespace llvm
95 
96 #endif
char * itaniumDemangle(const char *mangled_name, char *buf, size_t *n, int *status)
ItaniumPartialDemangler & operator=(ItaniumPartialDemangler &&Other)
This class represents lattice values for constants.
Definition: AllocatorList.h:24
bool isData() const
If this symbol describes a variable.
bool isFunction() const
If this symbol describes a function.
char * getFunctionName(char *Buf, size_t *N) const
Get the entire name of this function.
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:784
bool isCtorOrDtor() const
If this symbol describes a constructor or destructor.
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
MSDemangleFlags
Definition: Demangle.h:35
char * getFunctionBaseName(char *Buf, size_t *N) const
Get the base name of a function.
bool partialDemangle(const char *MangledName)
Demangle into an AST.
char * getFunctionDeclContextName(char *Buf, size_t *N) const
Get the context name for a function.
char * getFunctionParameters(char *Buf, size_t *N) const
Get the parameters for this function.
char * getFunctionReturnType(char *Buf, size_t *N) const
bool isSpecialName() const
If this symbol is a <special-name>.
bool hasFunctionQualifiers() const
If this function has any any cv or reference qualifiers.
char * finishDemangle(char *Buf, size_t *N) const
Just print the entire mangled name into Buf.
#define N
"Partial" demangler.
Definition: Demangle.h:42
char * microsoftDemangle(const char *mangled_name, char *buf, size_t *n, int *status, MSDemangleFlags Flags=MSDF_None)