From 8210a58044d1e6d86473fdf810396d285c86ff36 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Thu, 11 Jun 2026 09:48:04 +0000 Subject: [PATCH] [Demangle] Guard DEMANGLE_ABI and add missing annotation (#202920) This updates the DEMANGLE_ABI annotation to only be defined if it is not already defined. This is required to parse the Demangle headers with the ids-check script. In addition, this adds one missing DEMANGLE_ABI annotation. This effort is tracked in #109483. --- libcxxabi/src/demangle/Utility.h | 2 +- llvm/include/llvm/Demangle/DemangleConfig.h | 39 ++++++++++++--------- llvm/include/llvm/Demangle/Utility.h | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/libcxxabi/src/demangle/Utility.h b/libcxxabi/src/demangle/Utility.h index df5b54dca492..ca420bce66d9 100644 --- a/libcxxabi/src/demangle/Utility.h +++ b/libcxxabi/src/demangle/Utility.h @@ -31,7 +31,7 @@ class Node; // Stream that AST nodes write their string representation into after the AST // has been parsed. -class OutputBuffer { +class DEMANGLE_ABI OutputBuffer { char *Buffer = nullptr; size_t CurrentPosition = 0; size_t BufferCapacity = 0; diff --git a/llvm/include/llvm/Demangle/DemangleConfig.h b/llvm/include/llvm/Demangle/DemangleConfig.h index 5c48ae1972be..9cd85efbbd23 100644 --- a/llvm/include/llvm/Demangle/DemangleConfig.h +++ b/llvm/include/llvm/Demangle/DemangleConfig.h @@ -97,24 +97,29 @@ #define DEMANGLE_NAMESPACE_BEGIN namespace llvm { namespace itanium_demangle { #define DEMANGLE_NAMESPACE_END } } -/// DEMANGLE_ABI is the export/visibility macro used to mark symbols delcared in +/// DEMANGLE_ABI is the export/visibility macro used to mark symbols declared in /// llvm/Demangle as exported when built as a shared library. -#if defined(LLVM_BUILD_STATIC) || !defined(LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS) -#define DEMANGLE_ABI -#else -#if defined(_WIN32) && !defined(__MINGW32__) -#if defined(LLVM_EXPORTS) -#define DEMANGLE_ABI __declspec(dllexport) -#else -#define DEMANGLE_ABI __declspec(dllimport) -#endif -#else -#if __has_attribute(visibility) -#define DEMANGLE_ABI __attribute__((__visibility__("default"))) -#else -#define DEMANGLE_ABI -#endif -#endif +// clang-format off +// Autoformatting removes indentation, making this harder to read. +#if !defined(DEMANGLE_ABI) +# if defined(LLVM_BUILD_STATIC) || !defined(LLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS) +# define DEMANGLE_ABI +# else +# if defined(_WIN32) && !defined(__MINGW32__) +# if defined(LLVM_EXPORTS) +# define DEMANGLE_ABI __declspec(dllexport) +# else +# define DEMANGLE_ABI __declspec(dllimport) +# endif +# else +# if __has_attribute(visibility) +# define DEMANGLE_ABI __attribute__((__visibility__("default"))) +# else +# define DEMANGLE_ABI +# endif +# endif +# endif #endif +// clang-format on #endif diff --git a/llvm/include/llvm/Demangle/Utility.h b/llvm/include/llvm/Demangle/Utility.h index afdc1a397ca6..56c052e6a2cf 100644 --- a/llvm/include/llvm/Demangle/Utility.h +++ b/llvm/include/llvm/Demangle/Utility.h @@ -31,7 +31,7 @@ class Node; // Stream that AST nodes write their string representation into after the AST // has been parsed. -class OutputBuffer { +class DEMANGLE_ABI OutputBuffer { char *Buffer = nullptr; size_t CurrentPosition = 0; size_t BufferCapacity = 0;