[llvm] [llvm] annotate remaining Support and ADT library interfaces for DLL export (PR #145354)

Andrew Rogers via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 24 10:02:03 PDT 2025


https://github.com/andrurogerz updated https://github.com/llvm/llvm-project/pull/145354

>From 0982dc3227d345de4beb9b00df5aca7af3141f67 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 08:56:52 -0700
Subject: [PATCH 1/3] [llvm] annotate remaining Support library interfaces for
 DLL export

---
 llvm/include/llvm/Support/ConvertUTF.h   |  6 +++---
 llvm/include/llvm/Support/KnownFPClass.h | 11 ++++++-----
 llvm/include/llvm/Support/ProgramStack.h |  7 ++++---
 llvm/include/llvm/Support/TextEncoding.h |  5 +++--
 4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h
index 3bb238e7df2ed..bb1723518a490 100644
--- a/llvm/include/llvm/Support/ConvertUTF.h
+++ b/llvm/include/llvm/Support/ConvertUTF.h
@@ -346,9 +346,9 @@ LLVM_ABI bool convertUTF32ToUTF8String(ArrayRef<UTF32> Src, std::string &Out);
 LLVM_ABI bool convertUTF8ToUTF16String(StringRef SrcUTF8,
                                        SmallVectorImpl<UTF16> &DstUTF16);
 
-bool IsSingleCodeUnitUTF8Codepoint(unsigned);
-bool IsSingleCodeUnitUTF16Codepoint(unsigned);
-bool IsSingleCodeUnitUTF32Codepoint(unsigned);
+LLVM_ABI bool IsSingleCodeUnitUTF8Codepoint(unsigned);
+LLVM_ABI bool IsSingleCodeUnitUTF16Codepoint(unsigned);
+LLVM_ABI bool IsSingleCodeUnitUTF32Codepoint(unsigned);
 
 #if defined(_WIN32)
 namespace sys {
diff --git a/llvm/include/llvm/Support/KnownFPClass.h b/llvm/include/llvm/Support/KnownFPClass.h
index 9ebdf260e0ec7..f2b58de4b867a 100644
--- a/llvm/include/llvm/Support/KnownFPClass.h
+++ b/llvm/include/llvm/Support/KnownFPClass.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_SUPPORT_KNOWNFPCLASS_H
 #define LLVM_SUPPORT_KNOWNFPCLASS_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include <optional>
 
@@ -78,13 +79,13 @@ struct KnownFPClass {
   /// Return true if it's know this can never be interpreted as a zero. This
   /// extends isKnownNeverZero to cover the case where the assumed
   /// floating-point mode for the function interprets denormals as zero.
-  bool isKnownNeverLogicalZero(DenormalMode Mode) const;
+  LLVM_ABI bool isKnownNeverLogicalZero(DenormalMode Mode) const;
 
   /// Return true if it's know this can never be interpreted as a negative zero.
-  bool isKnownNeverLogicalNegZero(DenormalMode Mode) const;
+  LLVM_ABI bool isKnownNeverLogicalNegZero(DenormalMode Mode) const;
 
   /// Return true if it's know this can never be interpreted as a positive zero.
-  bool isKnownNeverLogicalPosZero(DenormalMode Mode) const;
+  LLVM_ABI bool isKnownNeverLogicalPosZero(DenormalMode Mode) const;
 
   static constexpr FPClassTest OrderedLessThanZeroMask =
       fcNegSubnormal | fcNegNormal | fcNegInf;
@@ -209,7 +210,7 @@ struct KnownFPClass {
   ///
   /// This assumes a copy-like operation and will replace any currently known
   /// information.
-  void propagateDenormal(const KnownFPClass &Src, DenormalMode Mode);
+  LLVM_ABI void propagateDenormal(const KnownFPClass &Src, DenormalMode Mode);
 
   /// Report known classes if \p Src is evaluated through a potentially
   /// canonicalizing operation. We can assume signaling nans will not be
@@ -217,7 +218,7 @@ struct KnownFPClass {
   ///
   /// This assumes a copy-like operation and will replace any currently known
   /// information.
-  void propagateCanonicalizingSrc(const KnownFPClass &Src, DenormalMode Mode);
+  LLVM_ABI void propagateCanonicalizingSrc(const KnownFPClass &Src, DenormalMode Mode);
 
   void resetAll() { *this = KnownFPClass(); }
 };
diff --git a/llvm/include/llvm/Support/ProgramStack.h b/llvm/include/llvm/Support/ProgramStack.h
index 55964c9779209..030583ca5b2d3 100644
--- a/llvm/include/llvm/Support/ProgramStack.h
+++ b/llvm/include/llvm/Support/ProgramStack.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_SUPPORT_PROGRAMSTACK_H
 #define LLVM_SUPPORT_PROGRAMSTACK_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
 
 // LLVM_HAS_SPLIT_STACKS is exposed in the header because CrashRecoveryContext
@@ -28,12 +29,12 @@ namespace llvm {
 ///
 /// The value is not guaranteed to point to anything specific. It can be used to
 /// estimate how much stack space has been used since the previous call.
-uintptr_t getStackPointer();
+LLVM_ABI uintptr_t getStackPointer();
 
 /// \returns the default stack size for this platform.
 ///
 /// Based on \p RLIMIT_STACK or the equivalent.
-unsigned getDefaultStackSize();
+LLVM_ABI unsigned getDefaultStackSize();
 
 /// Runs Fn on a new stack of at least the given size.
 ///
@@ -42,7 +43,7 @@ unsigned getDefaultStackSize();
 ///
 /// The preferred implementation is split stacks on platforms that have a good
 /// debugging experience for them. On other platforms a new thread is used.
-void runOnNewStack(unsigned StackSize, function_ref<void()> Fn);
+LLVM_ABI void runOnNewStack(unsigned StackSize, function_ref<void()> Fn);
 
 template <typename R, typename... Ts>
 std::enable_if_t<!std::is_same_v<R, void>, R>
diff --git a/llvm/include/llvm/Support/TextEncoding.h b/llvm/include/llvm/Support/TextEncoding.h
index e204b95dd2dd7..5a6ddceb48417 100644
--- a/llvm/include/llvm/Support/TextEncoding.h
+++ b/llvm/include/llvm/Support/TextEncoding.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_SUPPORT_TEXT_ENCODING_H
 #define LLVM_SUPPORT_TEXT_ENCODING_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/config.h"
@@ -92,7 +93,7 @@ class TextEncodingConverter {
   /// \param[in] From the source character encoding
   /// \param[in] To the target character encoding
   /// \return a TextEncodingConverter instance or an error code
-  static ErrorOr<TextEncodingConverter> create(TextEncoding From,
+  LLVM_ABI static ErrorOr<TextEncodingConverter> create(TextEncoding From,
                                                TextEncoding To);
 
   /// Creates a TextEncodingConverter instance.
@@ -101,7 +102,7 @@ class TextEncodingConverter {
   /// \param[in] From name of the source character encoding
   /// \param[in] To name of the target character encoding
   /// \return a TextEncodingConverter instance or an error code
-  static ErrorOr<TextEncodingConverter> create(StringRef From, StringRef To);
+  LLVM_ABI static ErrorOr<TextEncodingConverter> create(StringRef From, StringRef To);
 
   TextEncodingConverter(const TextEncodingConverter &) = delete;
   TextEncodingConverter &operator=(const TextEncodingConverter &) = delete;

>From 1fb42db2ab2815686457938f6c968f1d4dfc5597 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 08:58:41 -0700
Subject: [PATCH 2/3] [llvm] manual fix-ups to IDS codemod of remaining Support
 and ADT lib interfaces

---
 llvm/include/llvm/ADT/APFloat.h      | 3 ++-
 llvm/include/llvm/ADT/APInt.h        | 2 +-
 llvm/include/llvm/ADT/DynamicAPInt.h | 2 +-
 llvm/include/llvm/Support/Timer.h    | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index 300f83dcf9ef6..6aa62301580b5 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -672,7 +672,8 @@ class IEEEFloat final {
 
   integerPart addSignificand(const IEEEFloat &);
   integerPart subtractSignificand(const IEEEFloat &, integerPart);
-  lostFraction addOrSubtractSignificand(const IEEEFloat &, bool subtract);
+  // Exported for IEEEFloatUnitTestHelper.
+  LLVM_ABI lostFraction addOrSubtractSignificand(const IEEEFloat &, bool subtract);
   lostFraction multiplySignificand(const IEEEFloat &, IEEEFloat,
                                    bool ignoreAddend = false);
   lostFraction multiplySignificand(const IEEEFloat&);
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index fe48c60466e96..295506393a1c4 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -561,7 +561,7 @@ class [[nodiscard]] APInt {
   }
 
   /// Overload to compute a hash_code for an APInt value.
-  friend hash_code hash_value(const APInt &Arg);
+  LLVM_ABI friend hash_code hash_value(const APInt &Arg);
 
   /// This function returns a pointer to the internal storage of the APInt.
   /// This is useful for writing out the APInt in binary form without any
diff --git a/llvm/include/llvm/ADT/DynamicAPInt.h b/llvm/include/llvm/ADT/DynamicAPInt.h
index 48c5c6eac9013..ca010f836de6f 100644
--- a/llvm/include/llvm/ADT/DynamicAPInt.h
+++ b/llvm/include/llvm/ADT/DynamicAPInt.h
@@ -212,7 +212,7 @@ class DynamicAPInt {
   friend DynamicAPInt operator/(int64_t A, const DynamicAPInt &B);
   friend DynamicAPInt operator%(int64_t A, const DynamicAPInt &B);
 
-  friend hash_code hash_value(const DynamicAPInt &x); // NOLINT
+  LLVM_ABI friend hash_code hash_value(const DynamicAPInt &x); // NOLINT
 
   LLVM_ABI void static_assert_layout(); // NOLINT
 
diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h
index 36890c75a65e3..40709d49db011 100644
--- a/llvm/include/llvm/Support/Timer.h
+++ b/llvm/include/llvm/Support/Timer.h
@@ -258,7 +258,7 @@ class TimerGroup {
 
 private:
   friend class Timer;
-  friend void PrintStatisticsJSON(raw_ostream &OS);
+  LLVM_ABI friend void PrintStatisticsJSON(raw_ostream &OS);
   void addTimer(Timer &T);
   void removeTimer(Timer &T);
   void prepareToPrintList(bool reset_time = false);

>From 06378816edc9205f1bed1f4acc2db99908d35116 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 09:03:06 -0700
Subject: [PATCH 3/3]  [llvm] clang-format changes

---
 llvm/include/llvm/ADT/APFloat.h          | 3 ++-
 llvm/include/llvm/Support/KnownFPClass.h | 5 +++--
 llvm/include/llvm/Support/ProgramStack.h | 2 +-
 llvm/include/llvm/Support/TextEncoding.h | 7 ++++---
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index 6aa62301580b5..e1589544787cf 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -673,7 +673,8 @@ class IEEEFloat final {
   integerPart addSignificand(const IEEEFloat &);
   integerPart subtractSignificand(const IEEEFloat &, integerPart);
   // Exported for IEEEFloatUnitTestHelper.
-  LLVM_ABI lostFraction addOrSubtractSignificand(const IEEEFloat &, bool subtract);
+  LLVM_ABI lostFraction addOrSubtractSignificand(const IEEEFloat &,
+                                                 bool subtract);
   lostFraction multiplySignificand(const IEEEFloat &, IEEEFloat,
                                    bool ignoreAddend = false);
   lostFraction multiplySignificand(const IEEEFloat&);
diff --git a/llvm/include/llvm/Support/KnownFPClass.h b/llvm/include/llvm/Support/KnownFPClass.h
index f2b58de4b867a..b3c18bcf6b34b 100644
--- a/llvm/include/llvm/Support/KnownFPClass.h
+++ b/llvm/include/llvm/Support/KnownFPClass.h
@@ -14,8 +14,8 @@
 #ifndef LLVM_SUPPORT_KNOWNFPCLASS_H
 #define LLVM_SUPPORT_KNOWNFPCLASS_H
 
-#include "llvm/Support/Compiler.h"
 #include "llvm/ADT/FloatingPointMode.h"
+#include "llvm/Support/Compiler.h"
 #include <optional>
 
 namespace llvm {
@@ -218,7 +218,8 @@ struct KnownFPClass {
   ///
   /// This assumes a copy-like operation and will replace any currently known
   /// information.
-  LLVM_ABI void propagateCanonicalizingSrc(const KnownFPClass &Src, DenormalMode Mode);
+  LLVM_ABI void propagateCanonicalizingSrc(const KnownFPClass &Src,
+                                           DenormalMode Mode);
 
   void resetAll() { *this = KnownFPClass(); }
 };
diff --git a/llvm/include/llvm/Support/ProgramStack.h b/llvm/include/llvm/Support/ProgramStack.h
index 030583ca5b2d3..0dd8235b90c06 100644
--- a/llvm/include/llvm/Support/ProgramStack.h
+++ b/llvm/include/llvm/Support/ProgramStack.h
@@ -9,8 +9,8 @@
 #ifndef LLVM_SUPPORT_PROGRAMSTACK_H
 #define LLVM_SUPPORT_PROGRAMSTACK_H
 
-#include "llvm/Support/Compiler.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/Support/Compiler.h"
 
 // LLVM_HAS_SPLIT_STACKS is exposed in the header because CrashRecoveryContext
 // needs to know if it's running on another thread or not.
diff --git a/llvm/include/llvm/Support/TextEncoding.h b/llvm/include/llvm/Support/TextEncoding.h
index 5a6ddceb48417..8a304910aa5dd 100644
--- a/llvm/include/llvm/Support/TextEncoding.h
+++ b/llvm/include/llvm/Support/TextEncoding.h
@@ -15,10 +15,10 @@
 #ifndef LLVM_SUPPORT_TEXT_ENCODING_H
 #define LLVM_SUPPORT_TEXT_ENCODING_H
 
-#include "llvm/Support/Compiler.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/config.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorOr.h"
 
 #include <string>
@@ -94,7 +94,7 @@ class TextEncodingConverter {
   /// \param[in] To the target character encoding
   /// \return a TextEncodingConverter instance or an error code
   LLVM_ABI static ErrorOr<TextEncodingConverter> create(TextEncoding From,
-                                               TextEncoding To);
+                                                        TextEncoding To);
 
   /// Creates a TextEncodingConverter instance.
   /// Returns std::errc::invalid_argument in case the requested conversion is
@@ -102,7 +102,8 @@ class TextEncodingConverter {
   /// \param[in] From name of the source character encoding
   /// \param[in] To name of the target character encoding
   /// \return a TextEncodingConverter instance or an error code
-  LLVM_ABI static ErrorOr<TextEncodingConverter> create(StringRef From, StringRef To);
+  LLVM_ABI static ErrorOr<TextEncodingConverter> create(StringRef From,
+                                                        StringRef To);
 
   TextEncodingConverter(const TextEncodingConverter &) = delete;
   TextEncodingConverter &operator=(const TextEncodingConverter &) = delete;



More information about the llvm-commits mailing list