LLVM  7.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 #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
20 /// unknown_error: -4
21 /// invalid_args: -3
22 /// invalid_mangled_name: -2
23 /// memory_alloc_failure: -1
24 /// success: 0
25 
26 char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n,
27  int *status);
28 
29 /// "Partial" demangler. This supports demangling a string into an AST
30 /// (typically an intermediate stage in itaniumDemangle) and querying certain
31 /// properties or partially printing the demangled name.
34 
37 
38  /// Demangle into an AST. Subsequent calls to the rest of the member functions
39  /// implicitly operate on the AST this produces.
40  /// \return true on error, false otherwise
41  bool partialDemangle(const char *MangledName);
42 
43  /// Just print the entire mangled name into Buf. Buf and N behave like the
44  /// second and third parameters to itaniumDemangle.
45  char *finishDemangle(char *Buf, size_t *N) const;
46 
47  /// Get the base name of a function. This doesn't include trailing template
48  /// arguments, ie for "a::b<int>" this function returns "b".
49  char *getFunctionBaseName(char *Buf, size_t *N) const;
50 
51  /// Get the context name for a function. For "a::b::c", this function returns
52  /// "a::b".
53  char *getFunctionDeclContextName(char *Buf, size_t *N) const;
54 
55  /// Get the entire name of this function.
56  char *getFunctionName(char *Buf, size_t *N) const;
57 
58  /// Get the parameters for this function.
59  char *getFunctionParameters(char *Buf, size_t *N) const;
60  char *getFunctionReturnType(char *Buf, size_t *N) const;
61 
62  /// If this function has any any cv or reference qualifiers. These imply that
63  /// the function is a non-static member function.
64  bool hasFunctionQualifiers() const;
65 
66  /// If this symbol describes a constructor or destructor.
67  bool isCtorOrDtor() const;
68 
69  /// If this symbol describes a function.
70  bool isFunction() const;
71 
72  /// If this symbol describes a variable.
73  bool isData() const;
74 
75  /// If this symbol is a <special-name>. These are generally implicitly
76  /// generated by the implementation, such as vtables and typeinfo names.
77  bool isSpecialName() const;
78 
80 private:
81  void *RootNode;
82  void *Context;
83 };
84 } // namespace llvm
char * itaniumDemangle(const char *mangled_name, char *buf, size_t *n, int *status)
This is a llvm local version of __cxa_demangle.
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:770
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:32
char * getFunctionBaseName(char *Buf, size_t *N) const
Get the base name of a function.