-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[llvm] annotate interfaces in Demangle for DLL export #147564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
0368535
to
4fd6d52
Compare
#if !defined(DEMANGLE_ABI) | ||
#define DEMANGLE_ABI | ||
#endif | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For LLVM's use, wouldn't it be fine to define DEMANGLE_ABI as LLVM_ABI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikic it would be simpler if OK. But if that's safe, can I just use LLVM_ABI
instead of a new DEMANGLE_ABI
and no-op LLVM_ABI
in libcxxabi/src/demangle/DemangleConfig.h
for the libcxxabi
copy? That would be even simpler.
Eh, never mind, I probably should not take the dependency on llvm/Support/Compiler.h
from ItaniumDemangle.h
. I do think it is probably fine to include the header from the new Visibility.h
file and #define DEMANGLE_ABI LLVM_ABI
there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@compnerd in case you have other input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, people wanted to be able to use libDemangle as a standalone library, which requires having its own definition. I don't think that we can simply alias it away. LLVM can build demangle statically and statically link it - that is the point of the annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@compnerd that is what I assumed too, but @nikic's comment here and the copy of ItaniumDemangle.h
under libcxxabi
made me think that the real reason we can't have Demangle
depend on Support
was because of the libcxxabi
duplication. Do either of you know who could confirm? I have both changes prepared and tested locally. I would just have to drop the top commit from this PR to go back to the independent DEMANGLE_ABI
version. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that @ldionne might be the person who can verify.
4fd6d52
to
b8ab5f5
Compare
b8ab5f5
to
84cd131
Compare
@llvm/pr-subscribers-libcxxabi Author: Andrew Rogers (andrurogerz) ChangesPurposeThis patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the Overview
BackgroundThis PR follows the pattern established with the This effort is tracked in #109483. Additional context is provided in this discourse, and documentation for ValidationLocal builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:
Patch is 22.25 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/147564.diff 8 Files Affected:
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index b306b2013445c..ed73b1aaf4363 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -19,6 +19,7 @@
#include "DemangleConfig.h"
#include "StringViewExtras.h"
#include "Utility.h"
+#include "Visibility.h"
#include <algorithm>
#include <cctype>
#include <cstdint>
@@ -3049,7 +3050,8 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
Node *parse(bool ParseParams = true);
};
-const char* parse_discriminator(const char* first, const char* last);
+DEMANGLE_ABI const char *parse_discriminator(const char *first,
+ const char *last);
// <name> ::= <nested-name> // N
// ::= <local-name> # See Scope Encoding below // Z
diff --git a/libcxxabi/src/demangle/Visibility.h b/libcxxabi/src/demangle/Visibility.h
new file mode 100644
index 0000000000000..90ca0e5e87335
--- /dev/null
+++ b/libcxxabi/src/demangle/Visibility.h
@@ -0,0 +1,18 @@
+//===--- Visibility.h -------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+// This file is contains noop definitions of the DEMANGLE_ABI macro defined in
+// llvm/include/llvm/Demangle/Visibility.h.
+//===----------------------------------------------------------------------===//
+
+#ifndef LIBCXXABI_DEMANGLE_VISIBILITY_H
+#define LIBCXXABI_DEMANGLE_VISIBILITY_H
+
+// The DEMANGLE_ABI macro resovles to nothing when building libcxxabi. Only
+// the llvm copy defines DEMANGLE_ABI as a visibility attribute.
+#define DEMANGLE_ABI
+
+#endif
diff --git a/libcxxabi/src/demangle/cp-to-llvm.sh b/libcxxabi/src/demangle/cp-to-llvm.sh
index f773dff9f0a8b..30bcd42191175 100755
--- a/libcxxabi/src/demangle/cp-to-llvm.sh
+++ b/libcxxabi/src/demangle/cp-to-llvm.sh
@@ -1,7 +1,8 @@
#!/bin/bash
-# Copies the 'demangle' library, excluding 'DemangleConfig.h', to llvm. If no
-# llvm directory is specified, then assume a monorepo layout.
+# Copies the 'demangle' library, excluding 'DemangleConfig.h' and
+# 'Visibility.h', to llvm. If no llvm directory is specified, then assume a
+# monorepo layout.
set -e
diff --git a/llvm/include/llvm/Demangle/Demangle.h b/llvm/include/llvm/Demangle/Demangle.h
index 21e7457b6336f..24fd9ba8b2fe4 100644
--- a/llvm/include/llvm/Demangle/Demangle.h
+++ b/llvm/include/llvm/Demangle/Demangle.h
@@ -9,6 +9,7 @@
#ifndef LLVM_DEMANGLE_DEMANGLE_H
#define LLVM_DEMANGLE_DEMANGLE_H
+#include "Visibility.h"
#include <cstddef>
#include <optional>
#include <string>
@@ -33,7 +34,8 @@ enum : int {
/// Returns a non-NULL pointer to a NUL-terminated C style string
/// that should be explicitly freed, if successful. Otherwise, may return
/// nullptr if mangled_name is not a valid mangling or is nullptr.
-char *itaniumDemangle(std::string_view mangled_name, bool ParseParams = true);
+DEMANGLE_ABI char *itaniumDemangle(std::string_view mangled_name,
+ bool ParseParams = true);
enum MSDemangleFlags {
MSDF_None = 0,
@@ -52,87 +54,90 @@ enum MSDemangleFlags {
/// bytes of the input string were consumed.
/// status receives one of the demangle_ enum entries above if it's not nullptr.
/// Flags controls various details of the demangled representation.
-char *microsoftDemangle(std::string_view mangled_name, size_t *n_read,
- int *status, MSDemangleFlags Flags = MSDF_None);
+DEMANGLE_ABI char *microsoftDemangle(std::string_view mangled_name,
+ size_t *n_read, int *status,
+ MSDemangleFlags Flags = MSDF_None);
-std::optional<size_t>
+DEMANGLE_ABI std::optional<size_t>
getArm64ECInsertionPointInMangledName(std::string_view MangledName);
// Demangles a Rust v0 mangled symbol.
-char *rustDemangle(std::string_view MangledName);
+DEMANGLE_ABI char *rustDemangle(std::string_view MangledName);
// Demangles a D mangled symbol.
-char *dlangDemangle(std::string_view MangledName);
+DEMANGLE_ABI char *dlangDemangle(std::string_view MangledName);
/// Attempt to demangle a string using different demangling schemes.
/// The function uses heuristics to determine which demangling scheme to use.
/// \param MangledName - reference to string to demangle.
/// \returns - the demangled string, or a copy of the input string if no
/// demangling occurred.
-std::string demangle(std::string_view MangledName);
+DEMANGLE_ABI std::string demangle(std::string_view MangledName);
-bool nonMicrosoftDemangle(std::string_view MangledName, std::string &Result,
- bool CanHaveLeadingDot = true,
- bool ParseParams = true);
+DEMANGLE_ABI bool nonMicrosoftDemangle(std::string_view MangledName,
+ std::string &Result,
+ bool CanHaveLeadingDot = true,
+ bool ParseParams = true);
/// "Partial" demangler. This supports demangling a string into an AST
/// (typically an intermediate stage in itaniumDemangle) and querying certain
/// properties or partially printing the demangled name.
struct ItaniumPartialDemangler {
- ItaniumPartialDemangler();
+ DEMANGLE_ABI ItaniumPartialDemangler();
- ItaniumPartialDemangler(ItaniumPartialDemangler &&Other);
- ItaniumPartialDemangler &operator=(ItaniumPartialDemangler &&Other);
+ DEMANGLE_ABI ItaniumPartialDemangler(ItaniumPartialDemangler &&Other);
+ DEMANGLE_ABI ItaniumPartialDemangler &
+ operator=(ItaniumPartialDemangler &&Other);
/// Demangle into an AST. Subsequent calls to the rest of the member functions
/// implicitly operate on the AST this produces.
/// \return true on error, false otherwise
- bool partialDemangle(const char *MangledName);
+ DEMANGLE_ABI bool partialDemangle(const char *MangledName);
/// Just print the entire mangled name into Buf. Buf and N behave like the
/// second and third parameters to __cxa_demangle.
- char *finishDemangle(char *Buf, size_t *N) const;
+ DEMANGLE_ABI char *finishDemangle(char *Buf, size_t *N) const;
/// See \ref finishDemangle
///
/// \param[in] OB A llvm::itanium_demangle::OutputBuffer that the demangled
/// name will be printed into.
///
- char *finishDemangle(void *OB) const;
+ DEMANGLE_ABI char *finishDemangle(void *OB) const;
/// Get the base name of a function. This doesn't include trailing template
/// arguments, ie for "a::b<int>" this function returns "b".
- char *getFunctionBaseName(char *Buf, size_t *N) const;
+ DEMANGLE_ABI char *getFunctionBaseName(char *Buf, size_t *N) const;
/// Get the context name for a function. For "a::b::c", this function returns
/// "a::b".
- char *getFunctionDeclContextName(char *Buf, size_t *N) const;
+ DEMANGLE_ABI char *getFunctionDeclContextName(char *Buf, size_t *N) const;
/// Get the entire name of this function.
- char *getFunctionName(char *Buf, size_t *N) const;
+ DEMANGLE_ABI char *getFunctionName(char *Buf, size_t *N) const;
/// Get the parameters for this function.
- char *getFunctionParameters(char *Buf, size_t *N) const;
- char *getFunctionReturnType(char *Buf, size_t *N) const;
+ DEMANGLE_ABI char *getFunctionParameters(char *Buf, size_t *N) const;
+ DEMANGLE_ABI char *getFunctionReturnType(char *Buf, size_t *N) const;
/// If this function has any cv or reference qualifiers. These imply that
/// the function is a non-static member function.
- bool hasFunctionQualifiers() const;
+ DEMANGLE_ABI bool hasFunctionQualifiers() const;
/// If this symbol describes a constructor or destructor.
- bool isCtorOrDtor() const;
+ DEMANGLE_ABI bool isCtorOrDtor() const;
/// If this symbol describes a function.
- bool isFunction() const;
+ DEMANGLE_ABI bool isFunction() const;
/// If this symbol describes a variable.
- bool isData() const;
+ DEMANGLE_ABI bool isData() const;
/// If this symbol is a <special-name>. These are generally implicitly
/// generated by the implementation, such as vtables and typeinfo names.
- bool isSpecialName() const;
+ DEMANGLE_ABI bool isSpecialName() const;
- ~ItaniumPartialDemangler();
+ DEMANGLE_ABI ~ItaniumPartialDemangler();
private:
void *RootNode;
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 5533652736dc8..802802a978a4a 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -19,6 +19,7 @@
#include "DemangleConfig.h"
#include "StringViewExtras.h"
#include "Utility.h"
+#include "Visibility.h"
#include <algorithm>
#include <cctype>
#include <cstdint>
@@ -3049,7 +3050,8 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
Node *parse(bool ParseParams = true);
};
-const char* parse_discriminator(const char* first, const char* last);
+DEMANGLE_ABI const char *parse_discriminator(const char *first,
+ const char *last);
// <name> ::= <nested-name> // N
// ::= <local-name> # See Scope Encoding below // Z
diff --git a/llvm/include/llvm/Demangle/MicrosoftDemangle.h b/llvm/include/llvm/Demangle/MicrosoftDemangle.h
index b9a25e361eec0..4e1baf05dd886 100644
--- a/llvm/include/llvm/Demangle/MicrosoftDemangle.h
+++ b/llvm/include/llvm/Demangle/MicrosoftDemangle.h
@@ -11,6 +11,7 @@
#include "llvm/Demangle/Demangle.h"
#include "llvm/Demangle/MicrosoftDemangleNodes.h"
+#include "llvm/Demangle/Visibility.h"
#include <cassert>
#include <string_view>
@@ -151,14 +152,14 @@ class Demangler {
// You are supposed to call parse() first and then check if error is true. If
// it is false, call output() to write the formatted name to the given stream.
- SymbolNode *parse(std::string_view &MangledName);
+ DEMANGLE_ABI SymbolNode *parse(std::string_view &MangledName);
- TagTypeNode *parseTagUniqueName(std::string_view &MangledName);
+ DEMANGLE_ABI TagTypeNode *parseTagUniqueName(std::string_view &MangledName);
// True if an error occurred.
bool Error = false;
- void dumpBackReferences();
+ DEMANGLE_ABI void dumpBackReferences();
private:
SymbolNode *demangleEncodedSymbol(std::string_view &MangledName,
diff --git a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
index a9cfe726a73d3..611fcdf7999b2 100644
--- a/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
+++ b/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
@@ -13,6 +13,7 @@
#ifndef LLVM_DEMANGLE_MICROSOFTDEMANGLENODES_H
#define LLVM_DEMANGLE_MICROSOFTDEMANGLENODES_H
+#include "Visibility.h"
#include <array>
#include <cstdint>
#include <string>
@@ -281,7 +282,7 @@ struct Node {
virtual void output(OutputBuffer &OB, OutputFlags Flags) const = 0;
- std::string toString(OutputFlags Flags = OF_Default) const;
+ DEMANGLE_ABI std::string toString(OutputFlags Flags = OF_Default) const;
private:
NodeKind Kind;
@@ -332,7 +333,7 @@ struct TypeNode : public Node {
Qualifiers Quals = Q_None;
};
-struct PrimitiveTypeNode : public TypeNode {
+struct DEMANGLE_ABI PrimitiveTypeNode : public TypeNode {
explicit PrimitiveTypeNode(PrimitiveKind K)
: TypeNode(NodeKind::PrimitiveType), PrimKind(K) {}
@@ -346,7 +347,7 @@ struct PrimitiveTypeNode : public TypeNode {
PrimitiveKind PrimKind;
};
-struct FunctionSignatureNode : public TypeNode {
+struct DEMANGLE_ABI FunctionSignatureNode : public TypeNode {
explicit FunctionSignatureNode(NodeKind K) : TypeNode(K) {}
FunctionSignatureNode() : TypeNode(NodeKind::FunctionSignature) {}
@@ -394,10 +395,11 @@ struct IdentifierNode : public Node {
NodeArrayNode *TemplateParams = nullptr;
protected:
- void outputTemplateParameters(OutputBuffer &OB, OutputFlags Flags) const;
+ DEMANGLE_ABI void outputTemplateParameters(OutputBuffer &OB,
+ OutputFlags Flags) const;
};
-struct VcallThunkIdentifierNode : public IdentifierNode {
+struct DEMANGLE_ABI VcallThunkIdentifierNode : public IdentifierNode {
VcallThunkIdentifierNode() : IdentifierNode(NodeKind::VcallThunkIdentifier) {}
void output(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -409,7 +411,7 @@ struct VcallThunkIdentifierNode : public IdentifierNode {
uint64_t OffsetInVTable = 0;
};
-struct DynamicStructorIdentifierNode : public IdentifierNode {
+struct DEMANGLE_ABI DynamicStructorIdentifierNode : public IdentifierNode {
DynamicStructorIdentifierNode()
: IdentifierNode(NodeKind::DynamicStructorIdentifier) {}
@@ -424,7 +426,7 @@ struct DynamicStructorIdentifierNode : public IdentifierNode {
bool IsDestructor = false;
};
-struct NamedIdentifierNode : public IdentifierNode {
+struct DEMANGLE_ABI NamedIdentifierNode : public IdentifierNode {
NamedIdentifierNode() : IdentifierNode(NodeKind::NamedIdentifier) {}
void output(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -436,7 +438,7 @@ struct NamedIdentifierNode : public IdentifierNode {
std::string_view Name;
};
-struct IntrinsicFunctionIdentifierNode : public IdentifierNode {
+struct DEMANGLE_ABI IntrinsicFunctionIdentifierNode : public IdentifierNode {
explicit IntrinsicFunctionIdentifierNode(IntrinsicFunctionKind Operator)
: IdentifierNode(NodeKind::IntrinsicFunctionIdentifier),
Operator(Operator) {}
@@ -450,7 +452,7 @@ struct IntrinsicFunctionIdentifierNode : public IdentifierNode {
IntrinsicFunctionKind Operator;
};
-struct LiteralOperatorIdentifierNode : public IdentifierNode {
+struct DEMANGLE_ABI LiteralOperatorIdentifierNode : public IdentifierNode {
LiteralOperatorIdentifierNode()
: IdentifierNode(NodeKind::LiteralOperatorIdentifier) {}
@@ -463,7 +465,7 @@ struct LiteralOperatorIdentifierNode : public IdentifierNode {
std::string_view Name;
};
-struct LocalStaticGuardIdentifierNode : public IdentifierNode {
+struct DEMANGLE_ABI LocalStaticGuardIdentifierNode : public IdentifierNode {
LocalStaticGuardIdentifierNode()
: IdentifierNode(NodeKind::LocalStaticGuardIdentifier) {}
@@ -477,7 +479,7 @@ struct LocalStaticGuardIdentifierNode : public IdentifierNode {
uint32_t ScopeIndex = 0;
};
-struct ConversionOperatorIdentifierNode : public IdentifierNode {
+struct DEMANGLE_ABI ConversionOperatorIdentifierNode : public IdentifierNode {
ConversionOperatorIdentifierNode()
: IdentifierNode(NodeKind::ConversionOperatorIdentifier) {}
@@ -491,7 +493,7 @@ struct ConversionOperatorIdentifierNode : public IdentifierNode {
TypeNode *TargetType = nullptr;
};
-struct StructorIdentifierNode : public IdentifierNode {
+struct DEMANGLE_ABI StructorIdentifierNode : public IdentifierNode {
StructorIdentifierNode() : IdentifierNode(NodeKind::StructorIdentifier) {}
explicit StructorIdentifierNode(bool IsDestructor)
: IdentifierNode(NodeKind::StructorIdentifier),
@@ -508,7 +510,7 @@ struct StructorIdentifierNode : public IdentifierNode {
bool IsDestructor = false;
};
-struct ThunkSignatureNode : public FunctionSignatureNode {
+struct DEMANGLE_ABI ThunkSignatureNode : public FunctionSignatureNode {
ThunkSignatureNode() : FunctionSignatureNode(NodeKind::ThunkSignature) {}
void outputPre(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -528,7 +530,7 @@ struct ThunkSignatureNode : public FunctionSignatureNode {
ThisAdjustor ThisAdjust;
};
-struct PointerTypeNode : public TypeNode {
+struct DEMANGLE_ABI PointerTypeNode : public TypeNode {
PointerTypeNode() : TypeNode(NodeKind::PointerType) {}
void outputPre(OutputBuffer &OB, OutputFlags Flags) const override;
void outputPost(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -550,7 +552,7 @@ struct PointerTypeNode : public TypeNode {
TypeNode *Pointee = nullptr;
};
-struct TagTypeNode : public TypeNode {
+struct DEMANGLE_ABI TagTypeNode : public TypeNode {
explicit TagTypeNode(TagKind Tag) : TypeNode(NodeKind::TagType), Tag(Tag) {}
void outputPre(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -562,7 +564,7 @@ struct TagTypeNode : public TypeNode {
TagKind Tag;
};
-struct ArrayTypeNode : public TypeNode {
+struct DEMANGLE_ABI ArrayTypeNode : public TypeNode {
ArrayTypeNode() : TypeNode(NodeKind::ArrayType) {}
void outputPre(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -591,7 +593,7 @@ struct IntrinsicNode : public TypeNode {
}
};
-struct CustomTypeNode : public TypeNode {
+struct DEMANGLE_ABI CustomTypeNode : public TypeNode {
CustomTypeNode() : TypeNode(NodeKind::Custom) {}
void outputPre(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -602,7 +604,7 @@ struct CustomTypeNode : public TypeNode {
IdentifierNode *Identifier = nullptr;
};
-struct NodeArrayNode : public Node {
+struct DEMANGLE_ABI NodeArrayNode : public Node {
NodeArrayNode() : Node(NodeKind::NodeArray) {}
void output(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -618,7 +620,7 @@ struct NodeArrayNode : public Node {
size_t Count = 0;
};
-struct QualifiedNameNode : public Node {
+struct DEMANGLE_ABI QualifiedNameNode : public Node {
QualifiedNameNode() : Node(NodeKind::QualifiedName) {}
void output(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -635,7 +637,7 @@ struct QualifiedNameNode : public Node {
}
};
-struct TemplateParameterReferenceNode : public Node {
+struct DEMANGLE_ABI TemplateParameterReferenceNode : public Node {
TemplateParameterReferenceNode()
: Node(NodeKind::TemplateParameterReference) {}
@@ -653,7 +655,7 @@ struct TemplateParameterReferenceNode : public Node {
bool IsMemberPointer = false;
};
-struct IntegerLiteralNode : public Node {
+struct DEMANGLE_ABI IntegerLiteralNode : public Node {
IntegerLiteralNode() : Node(NodeKind::IntegerLiteral) {}
IntegerLiteralNode(uint64_t Value, bool IsNegative)
: Node(NodeKind::IntegerLiteral), Value(Value), IsNegative(IsNegative) {}
@@ -668,7 +670,7 @@ struct IntegerLiteralNode : public Node {
bool IsNegative = false;
};
-struct RttiBaseClassDescriptorNode : public IdentifierNode {
+struct DEMANGLE_ABI RttiBaseClassDescriptorNode : public IdentifierNode {
RttiBaseClassDescriptorNode()
: IdentifierNode(NodeKind::RttiBaseClassDescriptor) {}
@@ -684,7 +686,7 @@ struct RttiBaseClassDescriptorNode : public IdentifierNode {
uint32_t Flags = 0;
};
-struct SymbolNode : public Node {
+struct DEMANGLE_ABI SymbolNode : public Node {
explicit SymbolNode(NodeKind K) : Node(K) {}
void output(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -696,7 +698,7 @@ struct SymbolNode : public Node {
QualifiedNameNode *Name = nullptr;
};
-struct SpecialTableSymbolNode : public SymbolNode {
+struct DEMANGLE_ABI SpecialTableSymbolNode : public SymbolNode {
explicit SpecialTableSymbolNode()
: SymbolNode(NodeKind::SpecialTableSymbol) {}
@@ -710,7 +712,7 @@ struct SpecialTableSymbolNode : public SymbolNode {
Qualifiers Quals = Qualifiers::Q_None;
};
-struct LocalStaticGuardVariableNode : public SymbolNode {
+struct DEMANGLE_ABI LocalStaticGuardVariableNode : public SymbolNode {
LocalStaticGuardVariableNode()
: SymbolNode(NodeKind::LocalStaticGuardVariable) {}
@@ -723,7 +725,7 @@ struct LocalStaticGuardVariableNode : public SymbolNode {
bool IsVisible = false;
};
-struct EncodedStringLiteralNode : public SymbolNode {
+struct DEMANGLE_ABI EncodedStringLiteralNode : public SymbolNode {
EncodedStringLiteralNode() : SymbolNode(NodeKind::EncodedStringLiteral) {}
void output(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -737,7 +739,7 @@ struct EncodedStringLiteralNode : public SymbolNode {
CharKind Char = CharKind::Char;
};
-struct VariableSymbolNode : public SymbolNode {
+struct DEMANGLE_ABI VariableSymbolNode : public SymbolNode {
VariableSymbolNode() : SymbolNode(NodeKind::VariableSymbol) {}
void output(OutputBuffer &OB, OutputFlags Flags) const override;
@@ -750,7 +752,7 @@ struct VariableSymbolNode : public SymbolNode {
Ty...
[truncated]
|
Android NDK failures appear to be unrelated-- these tests are failing elsewhere. |
Purpose
This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the
Demangle
interface with a newDEMANGLE_ABI
annotation, which behaves like theLLVM_ABI
. This annotation currently has no meaningful impact on the LLVM build; however, it is a prerequisite to support an LLVM Windows DLL (shared library) build.Overview
Demangle/Visibility.h
header file that defines a newDEMANGLE_ABI
macro. The macro resolves to the proper DLL export/import annotation on Windows and a "default" visibility annotation elsewhere.LLVM_ENABLE_DEMANGLE_EXPORT_ANNOTATIONS
#cmakedefine
that is used to gate the definition ofDEMANGLE_ABI
.Demangle
interface using the Interface Definition Scanner (IDS) tool.#include
statements for consistency.clang-format
.Visibility.h
underlibcxxabi/src/demangle
that always definesDEMANGLE_ABI
to nothing.libcxxabi/src/demangle/ItaniumDemangle.h
instead of the llvm copy, and runcp-to-llvm.sh
to ensure the llvm copy matches. NOTE: we rely onccp-to-llvm.sh
not copyingVisibillity.h
as is already the case forDemangleConfig.h
.Background
This PR follows the pattern established with the
llvm-c
changes made in #141701.This effort is tracked in #109483. Additional context is provided in this discourse, and documentation for
LLVM_ABI
and related annotations is found in the LLVM repo here.Validation
Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: