LLVM  8.0.0svn
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 /// Calls the callback \c Callback with \c Ctx as an argument whenever a type is
35 /// encountered. Returns true if \c MangledName couldn't be parsed.
36 bool itaniumFindTypesInMangledName(const char *MangledName, void *Ctx,
37  void (*Callback)(void *, const char *));
38 
39 
41 char *microsoftDemangle(const char *mangled_name, char *buf, size_t *n,
42  int *status, MSDemangleFlags Flags = MSDF_None);
43 
44 /// "Partial" demangler. This supports demangling a string into an AST
45 /// (typically an intermediate stage in itaniumDemangle) and querying certain
46 /// properties or partially printing the demangled name.
49 
52 
53  /// Demangle into an AST. Subsequent calls to the rest of the member functions
54  /// implicitly operate on the AST this produces.
55  /// \return true on error, false otherwise
56  bool partialDemangle(const char *MangledName);
57 
58  /// Just print the entire mangled name into Buf. Buf and N behave like the
59  /// second and third parameters to itaniumDemangle.
60  char *finishDemangle(char *Buf, size_t *N) const;
61 
62  /// Get the base name of a function. This doesn't include trailing template
63  /// arguments, ie for "a::b<int>" this function returns "b".
64  char *getFunctionBaseName(char *Buf, size_t *N) const;
65 
66  /// Get the context name for a function. For "a::b::c", this function returns
67  /// "a::b".
68  char *getFunctionDeclContextName(char *Buf, size_t *N) const;
69 
70  /// Get the entire name of this function.
71  char *getFunctionName(char *Buf, size_t *N) const;
72 
73  /// Get the parameters for this function.
74  char *getFunctionParameters(char *Buf, size_t *N) const;
75  char *getFunctionReturnType(char *Buf, size_t *N) const;
76 
77  /// If this function has any any cv or reference qualifiers. These imply that
78  /// the function is a non-static member function.
79  bool hasFunctionQualifiers() const;
80 
81  /// If this symbol describes a constructor or destructor.
82  bool isCtorOrDtor() const;
83 
84  /// If this symbol describes a function.
85  bool isFunction() const;
86 
87  /// If this symbol describes a variable.
88  bool isData() const;
89 
90  /// If this symbol is a <special-name>. These are generally implicitly
91  /// generated by the implementation, such as vtables and typeinfo names.
92  bool isSpecialName() const;
93 
95 private:
96  void *RootNode;
97  void *Context;
98 };
99 } // namespace llvm
100 
101 #endif
char * itaniumDemangle(const char *mangled_name, char *buf, size_t *n, int *status)
ItaniumPartialDemangler & operator=(ItaniumPartialDemangler &&Other)
Compute iterated dominance frontiers using a linear time algorithm.
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:773
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:40
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 itaniumFindTypesInMangledName(const char *MangledName, void *Ctx, void(*Callback)(void *, const char *))
Calls the callback Callback with Ctx as an argument whenever a type is encountered.
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:47
char * microsoftDemangle(const char *mangled_name, char *buf, size_t *n, int *status, MSDemangleFlags Flags=MSDF_None)