Skip to content

Commit 23a5797

Browse files
committed
[llvm] auto-annotate Demangle library interface with IDS
1 parent 0abde0a commit 23a5797

File tree

4 files changed

+61
-57
lines changed

4 files changed

+61
-57
lines changed

llvm/include/llvm/Demangle/Demangle.h

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_DEMANGLE_DEMANGLE_H
1010
#define LLVM_DEMANGLE_DEMANGLE_H
1111

12+
#include "llvm/Demangle/Visibility.h"
1213
#include <cstddef>
1314
#include <optional>
1415
#include <string>
@@ -33,7 +34,7 @@ enum : int {
3334
/// Returns a non-NULL pointer to a NUL-terminated C style string
3435
/// that should be explicitly freed, if successful. Otherwise, may return
3536
/// nullptr if mangled_name is not a valid mangling or is nullptr.
36-
char *itaniumDemangle(std::string_view mangled_name, bool ParseParams = true);
37+
DEMANGLE_ABI char *itaniumDemangle(std::string_view mangled_name, bool ParseParams = true);
3738

3839
enum MSDemangleFlags {
3940
MSDF_None = 0,
@@ -52,87 +53,87 @@ enum MSDemangleFlags {
5253
/// bytes of the input string were consumed.
5354
/// status receives one of the demangle_ enum entries above if it's not nullptr.
5455
/// Flags controls various details of the demangled representation.
55-
char *microsoftDemangle(std::string_view mangled_name, size_t *n_read,
56+
DEMANGLE_ABI char *microsoftDemangle(std::string_view mangled_name, size_t *n_read,
5657
int *status, MSDemangleFlags Flags = MSDF_None);
5758

58-
std::optional<size_t>
59+
DEMANGLE_ABI std::optional<size_t>
5960
getArm64ECInsertionPointInMangledName(std::string_view MangledName);
6061

6162
// Demangles a Rust v0 mangled symbol.
62-
char *rustDemangle(std::string_view MangledName);
63+
DEMANGLE_ABI char *rustDemangle(std::string_view MangledName);
6364

6465
// Demangles a D mangled symbol.
65-
char *dlangDemangle(std::string_view MangledName);
66+
DEMANGLE_ABI char *dlangDemangle(std::string_view MangledName);
6667

6768
/// Attempt to demangle a string using different demangling schemes.
6869
/// The function uses heuristics to determine which demangling scheme to use.
6970
/// \param MangledName - reference to string to demangle.
7071
/// \returns - the demangled string, or a copy of the input string if no
7172
/// demangling occurred.
72-
std::string demangle(std::string_view MangledName);
73+
DEMANGLE_ABI std::string demangle(std::string_view MangledName);
7374

74-
bool nonMicrosoftDemangle(std::string_view MangledName, std::string &Result,
75+
DEMANGLE_ABI bool nonMicrosoftDemangle(std::string_view MangledName, std::string &Result,
7576
bool CanHaveLeadingDot = true,
7677
bool ParseParams = true);
7778

7879
/// "Partial" demangler. This supports demangling a string into an AST
7980
/// (typically an intermediate stage in itaniumDemangle) and querying certain
8081
/// properties or partially printing the demangled name.
8182
struct ItaniumPartialDemangler {
82-
ItaniumPartialDemangler();
83+
DEMANGLE_ABI ItaniumPartialDemangler();
8384

84-
ItaniumPartialDemangler(ItaniumPartialDemangler &&Other);
85-
ItaniumPartialDemangler &operator=(ItaniumPartialDemangler &&Other);
85+
DEMANGLE_ABI ItaniumPartialDemangler(ItaniumPartialDemangler &&Other);
86+
DEMANGLE_ABI ItaniumPartialDemangler &operator=(ItaniumPartialDemangler &&Other);
8687

8788
/// Demangle into an AST. Subsequent calls to the rest of the member functions
8889
/// implicitly operate on the AST this produces.
8990
/// \return true on error, false otherwise
90-
bool partialDemangle(const char *MangledName);
91+
DEMANGLE_ABI bool partialDemangle(const char *MangledName);
9192

9293
/// Just print the entire mangled name into Buf. Buf and N behave like the
9394
/// second and third parameters to __cxa_demangle.
94-
char *finishDemangle(char *Buf, size_t *N) const;
95+
DEMANGLE_ABI char *finishDemangle(char *Buf, size_t *N) const;
9596

9697
/// See \ref finishDemangle
9798
///
9899
/// \param[in] OB A llvm::itanium_demangle::OutputBuffer that the demangled
99100
/// name will be printed into.
100101
///
101-
char *finishDemangle(void *OB) const;
102+
DEMANGLE_ABI char *finishDemangle(void *OB) const;
102103

103104
/// Get the base name of a function. This doesn't include trailing template
104105
/// arguments, ie for "a::b<int>" this function returns "b".
105-
char *getFunctionBaseName(char *Buf, size_t *N) const;
106+
DEMANGLE_ABI char *getFunctionBaseName(char *Buf, size_t *N) const;
106107

107108
/// Get the context name for a function. For "a::b::c", this function returns
108109
/// "a::b".
109-
char *getFunctionDeclContextName(char *Buf, size_t *N) const;
110+
DEMANGLE_ABI char *getFunctionDeclContextName(char *Buf, size_t *N) const;
110111

111112
/// Get the entire name of this function.
112-
char *getFunctionName(char *Buf, size_t *N) const;
113+
DEMANGLE_ABI char *getFunctionName(char *Buf, size_t *N) const;
113114

114115
/// Get the parameters for this function.
115-
char *getFunctionParameters(char *Buf, size_t *N) const;
116-
char *getFunctionReturnType(char *Buf, size_t *N) const;
116+
DEMANGLE_ABI char *getFunctionParameters(char *Buf, size_t *N) const;
117+
DEMANGLE_ABI char *getFunctionReturnType(char *Buf, size_t *N) const;
117118

118119
/// If this function has any cv or reference qualifiers. These imply that
119120
/// the function is a non-static member function.
120-
bool hasFunctionQualifiers() const;
121+
DEMANGLE_ABI bool hasFunctionQualifiers() const;
121122

122123
/// If this symbol describes a constructor or destructor.
123-
bool isCtorOrDtor() const;
124+
DEMANGLE_ABI bool isCtorOrDtor() const;
124125

125126
/// If this symbol describes a function.
126-
bool isFunction() const;
127+
DEMANGLE_ABI bool isFunction() const;
127128

128129
/// If this symbol describes a variable.
129-
bool isData() const;
130+
DEMANGLE_ABI bool isData() const;
130131

131132
/// If this symbol is a <special-name>. These are generally implicitly
132133
/// generated by the implementation, such as vtables and typeinfo names.
133-
bool isSpecialName() const;
134+
DEMANGLE_ABI bool isSpecialName() const;
134135

135-
~ItaniumPartialDemangler();
136+
DEMANGLE_ABI ~ItaniumPartialDemangler();
136137

137138
private:
138139
void *RootNode;

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef DEMANGLE_ITANIUMDEMANGLE_H
1717
#define DEMANGLE_ITANIUMDEMANGLE_H
1818

19+
#include "llvm/Demangle/Visibility.h"
1920
#include "DemangleConfig.h"
2021
#include "StringViewExtras.h"
2122
#include "Utility.h"
@@ -3049,7 +3050,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
30493050
Node *parse(bool ParseParams = true);
30503051
};
30513052

3052-
const char* parse_discriminator(const char* first, const char* last);
3053+
DEMANGLE_ABI const char* parse_discriminator(const char* first, const char* last);
30533054

30543055
// <name> ::= <nested-name> // N
30553056
// ::= <local-name> # See Scope Encoding below // Z

llvm/include/llvm/Demangle/MicrosoftDemangle.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
1010
#define LLVM_DEMANGLE_MICROSOFTDEMANGLE_H
1111

12+
#include "llvm/Demangle/Visibility.h"
1213
#include "llvm/Demangle/Demangle.h"
1314
#include "llvm/Demangle/MicrosoftDemangleNodes.h"
1415

@@ -151,14 +152,14 @@ class Demangler {
151152

152153
// You are supposed to call parse() first and then check if error is true. If
153154
// it is false, call output() to write the formatted name to the given stream.
154-
SymbolNode *parse(std::string_view &MangledName);
155+
DEMANGLE_ABI SymbolNode *parse(std::string_view &MangledName);
155156

156-
TagTypeNode *parseTagUniqueName(std::string_view &MangledName);
157+
DEMANGLE_ABI TagTypeNode *parseTagUniqueName(std::string_view &MangledName);
157158

158159
// True if an error occurred.
159160
bool Error = false;
160161

161-
void dumpBackReferences();
162+
DEMANGLE_ABI void dumpBackReferences();
162163

163164
private:
164165
SymbolNode *demangleEncodedSymbol(std::string_view &MangledName,

0 commit comments

Comments
 (0)