LLVM  7.0.0
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 #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 {
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.
38 
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 
84 private:
85  void *RootNode;
86  void *Context;
87 };
88 } // namespace llvm
char * itaniumDemangle(const char *mangled_name, char *buf, size_t *n, int *status)
bool partialDemangle(const char *MangledName)
Demangle into an AST.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
ItaniumPartialDemangler & operator=(ItaniumPartialDemangler &&Other)
bool isData() const
If this symbol describes a variable.
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.
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:773
char * microsoftDemangle(const char *mangled_name, char *buf, size_t *n, int *status)
std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
char * getFunctionReturnType(char *Buf, size_t *N) const
char * getFunctionName(char *Buf, size_t *N) const
Get the entire name of this function.
bool isCtorOrDtor() const
If this symbol describes a constructor or destructor.
bool isFunction() const
If this symbol describes a function.
char * finishDemangle(char *Buf, size_t *N) const
Just print the entire mangled name into Buf.
bool isSpecialName() const
If this symbol is a <special-name>.
#define N
bool hasFunctionQualifiers() const
If this function has any any cv or reference qualifiers.
"Partial" demangler.
Definition: Demangle.h:36
char * getFunctionBaseName(char *Buf, size_t *N) const
Get the base name of a function.