[llvm] 1c8206b - [llvm] annotate interfaces in llvm/Option and llvm/Remarks for DLL export (#142856)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 07:58:28 PDT 2025


Author: Andrew Rogers
Date: 2025-06-10T07:58:24-07:00
New Revision: 1c8206bd2a12c478128b84799f9fa4fb44cd3d8a

URL: https://github.com/llvm/llvm-project/commit/1c8206bd2a12c478128b84799f9fa4fb44cd3d8a
DIFF: https://github.com/llvm/llvm-project/commit/1c8206bd2a12c478128b84799f9fa4fb44cd3d8a.diff

LOG: [llvm] annotate interfaces in llvm/Option and llvm/Remarks for DLL export (#142856)

## Purpose

This patch is one in a series of code-mods that annotate LLVM’s public
interface for export. This patch annotates the `llvm/Options` and
`llvm/Remarks` libraries. These annotations currently have no meaningful
impact on the LLVM build; however, they are a prerequisite to support an
LLVM Windows DLL (shared library) build.

## Background

This effort is tracked in #109483. Additional context is provided in
[this
discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307),
and documentation for `LLVM_ABI` and related annotations is found in the
LLVM repo
[here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst).

These changes were generated automatically using the [Interface
Definition Scanner (IDS)](https://github.com/compnerd/ids) tool,
followed formatting with `git clang-format`. No manual fixups were
required.

## Validation

Local builds and tests to validate cross-platform compatibility. This
included llvm, clang, and lldb on the following configurations:

- Windows with MSVC
- Windows with Clang
- Linux with GCC
- Linux with Clang
- Darwin with Clang

Added: 
    

Modified: 
    llvm/include/llvm/Option/Arg.h
    llvm/include/llvm/Option/ArgList.h
    llvm/include/llvm/Option/OptSpecifier.h
    llvm/include/llvm/Option/OptTable.h
    llvm/include/llvm/Option/Option.h
    llvm/include/llvm/Remarks/Remark.h
    llvm/include/llvm/Remarks/RemarkFormat.h
    llvm/include/llvm/Remarks/RemarkLinker.h
    llvm/include/llvm/Remarks/RemarkParser.h
    llvm/include/llvm/Remarks/RemarkSerializer.h
    llvm/include/llvm/Remarks/RemarkStringTable.h
    llvm/include/llvm/Remarks/YAMLRemarkSerializer.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Option/Arg.h b/llvm/include/llvm/Option/Arg.h
index 5a718438bf4a3..b1e56b58da684 100644
--- a/llvm/include/llvm/Option/Arg.h
+++ b/llvm/include/llvm/Option/Arg.h
@@ -17,6 +17,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/Compiler.h"
 #include <string>
 
 namespace llvm {
@@ -70,15 +71,16 @@ class Arg {
   std::unique_ptr<Arg> Alias;
 
 public:
-  Arg(const Option Opt, StringRef Spelling, unsigned Index,
-      const Arg *BaseArg = nullptr);
-  Arg(const Option Opt, StringRef Spelling, unsigned Index,
-      const char *Value0, const Arg *BaseArg = nullptr);
-  Arg(const Option Opt, StringRef Spelling, unsigned Index,
-      const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
+  LLVM_ABI Arg(const Option Opt, StringRef Spelling, unsigned Index,
+               const Arg *BaseArg = nullptr);
+  LLVM_ABI Arg(const Option Opt, StringRef Spelling, unsigned Index,
+               const char *Value0, const Arg *BaseArg = nullptr);
+  LLVM_ABI Arg(const Option Opt, StringRef Spelling, unsigned Index,
+               const char *Value0, const char *Value1,
+               const Arg *BaseArg = nullptr);
   Arg(const Arg &) = delete;
   Arg &operator=(const Arg &) = delete;
-  ~Arg();
+  LLVM_ABI ~Arg();
 
   const Option &getOption() const { return Opt; }
 
@@ -134,23 +136,23 @@ class Arg {
   }
 
   /// Append the argument onto the given array as strings.
-  void render(const ArgList &Args, ArgStringList &Output) const;
+  LLVM_ABI void render(const ArgList &Args, ArgStringList &Output) const;
 
   /// Append the argument, render as an input, onto the given
   /// array as strings.
   ///
   /// The distinction is that some options only render their values
   /// when rendered as a input (e.g., Xlinker).
-  void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
+  LLVM_ABI void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
 
-  void print(raw_ostream &O) const;
-  void dump() const;
+  LLVM_ABI void print(raw_ostream &O) const;
+  LLVM_ABI void dump() const;
 
   /// Return a formatted version of the argument and its values, for
   /// diagnostics. Since this is for diagnostics, if this Arg was produced
   /// through an alias, this returns the string representation of the alias
   /// that the user wrote.
-  std::string getAsString(const ArgList &Args) const;
+  LLVM_ABI std::string getAsString(const ArgList &Args) const;
 };
 
 } // end namespace opt

diff  --git a/llvm/include/llvm/Option/ArgList.h b/llvm/include/llvm/Option/ArgList.h
index 09812f976d016..313164bc29689 100644
--- a/llvm/include/llvm/Option/ArgList.h
+++ b/llvm/include/llvm/Option/ArgList.h
@@ -11,14 +11,15 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/iterator_range.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/OptSpecifier.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/Compiler.h"
 #include <algorithm>
 #include <cstddef>
 #include <initializer_list>
@@ -139,7 +140,7 @@ class ArgList {
 
   /// Get the range of indexes in which options with the specified IDs might
   /// reside, or (0, 0) if there are no such options.
-  OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;
+  LLVM_ABI OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;
 
 protected:
   // Make the default special members protected so they won't be used to slice
@@ -178,7 +179,7 @@ class ArgList {
   /// @{
 
   /// append - Append \p A to the arg list.
-  void append(Arg *A);
+  LLVM_ABI void append(Arg *A);
 
   const arglist_type &getArgs() const { return Args; }
 
@@ -227,7 +228,7 @@ class ArgList {
   /// @{
 
   /// eraseArg - Remove any option matching \p Id.
-  void eraseArg(OptSpecifier Id);
+  LLVM_ABI void eraseArg(OptSpecifier Id);
 
   /// @}
   /// @name Arg Access
@@ -284,11 +285,12 @@ class ArgList {
   /// @{
 
   /// getLastArgValue - Return the value of the last argument, or a default.
-  StringRef getLastArgValue(OptSpecifier Id, StringRef Default = "") const;
+  LLVM_ABI StringRef getLastArgValue(OptSpecifier Id,
+                                     StringRef Default = "") const;
 
   /// getAllArgValues - Get the values of all instances of the given argument
   /// as strings.
-  std::vector<std::string> getAllArgValues(OptSpecifier Id) const;
+  LLVM_ABI std::vector<std::string> getAllArgValues(OptSpecifier Id) const;
 
   /// @}
   /// @name Translation Utilities
@@ -298,20 +300,21 @@ class ArgList {
   /// true if the option is present, false if the negation is present, and
   /// \p Default if neither option is given. If both the option and its
   /// negation are present, the last one wins.
-  bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
-  bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
+  LLVM_ABI bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
+  LLVM_ABI bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg,
+                               bool Default) const;
 
   /// hasFlag - Given an option \p Pos, an alias \p PosAlias and its negative
   /// form \p Neg, return true if the option or its alias is present, false if
   /// the negation is present, and \p Default if none of the options are
   /// given. If multiple options are present, the last one wins.
-  bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
-               bool Default) const;
+  LLVM_ABI bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias,
+                        OptSpecifier Neg, bool Default) const;
 
   /// Given an option Pos and its negative form Neg, render the option if Pos is
   /// present.
-  void addOptInFlag(ArgStringList &Output, OptSpecifier Pos,
-                    OptSpecifier Neg) const;
+  LLVM_ABI void addOptInFlag(ArgStringList &Output, OptSpecifier Pos,
+                             OptSpecifier Neg) const;
   /// Render the option if Neg is present.
   void addOptOutFlag(ArgStringList &Output, OptSpecifier Pos,
                      OptSpecifier Neg) const {
@@ -331,18 +334,21 @@ class ArgList {
 
   /// AddAllArgsExcept - Render all arguments matching any of the given ids
   /// and not matching any of the excluded ids.
-  void AddAllArgsExcept(ArgStringList &Output, ArrayRef<OptSpecifier> Ids,
-                        ArrayRef<OptSpecifier> ExcludeIds) const;
+  LLVM_ABI void AddAllArgsExcept(ArgStringList &Output,
+                                 ArrayRef<OptSpecifier> Ids,
+                                 ArrayRef<OptSpecifier> ExcludeIds) const;
   /// Render all arguments matching any of the given ids.
-  void addAllArgs(ArgStringList &Output, ArrayRef<OptSpecifier> Ids) const;
+  LLVM_ABI void addAllArgs(ArgStringList &Output,
+                           ArrayRef<OptSpecifier> Ids) const;
 
   /// AddAllArgs - Render all arguments matching the given ids.
-  void AddAllArgs(ArgStringList &Output, OptSpecifier Id0) const;
+  LLVM_ABI void AddAllArgs(ArgStringList &Output, OptSpecifier Id0) const;
 
   /// AddAllArgValues - Render the argument values of all arguments
   /// matching the given ids.
-  void AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
-                       OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;
+  LLVM_ABI void AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
+                                OptSpecifier Id1 = 0U,
+                                OptSpecifier Id2 = 0U) const;
 
   /// AddAllArgsTranslated - Render all the arguments matching the
   /// given ids, but forced to separate args and using the provided
@@ -350,13 +356,13 @@ class ArgList {
   ///
   /// \param Joined - If true, render the argument as joined with
   /// the option specifier.
-  void AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
-                            const char *Translation,
-                            bool Joined = false) const;
+  LLVM_ABI void AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
+                                     const char *Translation,
+                                     bool Joined = false) const;
 
   /// ClaimAllArgs - Claim all arguments which match the given
   /// option id.
-  void ClaimAllArgs(OptSpecifier Id0) const;
+  LLVM_ABI void ClaimAllArgs(OptSpecifier Id0) const;
 
   template <typename... OptSpecifiers>
   void claimAllArgs(OptSpecifiers... Ids) const {
@@ -366,7 +372,7 @@ class ArgList {
 
   /// ClaimAllArgs - Claim all arguments.
   ///
-  void ClaimAllArgs() const;
+  LLVM_ABI void ClaimAllArgs() const;
   /// @}
   /// @name Arg Synthesis
   /// @{
@@ -381,16 +387,16 @@ class ArgList {
 
   /// Create an arg string for (\p LHS + \p RHS), reusing the
   /// string at \p Index if possible.
-  const char *GetOrMakeJoinedArgString(unsigned Index, StringRef LHS,
-                                        StringRef RHS) const;
+  LLVM_ABI const char *GetOrMakeJoinedArgString(unsigned Index, StringRef LHS,
+                                                StringRef RHS) const;
 
-  void print(raw_ostream &O) const;
-  void dump() const;
+  LLVM_ABI void print(raw_ostream &O) const;
+  LLVM_ABI void dump() const;
 
   /// @}
 };
 
-class InputArgList final : public ArgList {
+class LLVM_ABI InputArgList final : public ArgList {
 private:
   /// List of argument strings used by the contained Args.
   ///
@@ -463,7 +469,7 @@ class InputArgList final : public ArgList {
 
 /// DerivedArgList - An ordered collection of driver arguments,
 /// whose storage may be in another argument list.
-class DerivedArgList final : public ArgList {
+class LLVM_ABI DerivedArgList final : public ArgList {
   const InputArgList &BaseArgs;
 
   /// The list of arguments we synthesized.

diff  --git a/llvm/include/llvm/Option/OptSpecifier.h b/llvm/include/llvm/Option/OptSpecifier.h
index 7a5fcfb18b388..dc6acae7fc002 100644
--- a/llvm/include/llvm/Option/OptSpecifier.h
+++ b/llvm/include/llvm/Option/OptSpecifier.h
@@ -22,7 +22,7 @@ class OptSpecifier {
   OptSpecifier() = default;
   explicit OptSpecifier(bool) = delete;
   /*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
-  /*implicit*/ OptSpecifier(const Option *Opt);
+  /*implicit*/ LLVM_ABI OptSpecifier(const Option *Opt);
 
   bool isValid() const { return ID != 0; }
 

diff  --git a/llvm/include/llvm/Option/OptTable.h b/llvm/include/llvm/Option/OptTable.h
index 61a58aa304ecb..df42ee341ee58 100644
--- a/llvm/include/llvm/Option/OptTable.h
+++ b/llvm/include/llvm/Option/OptTable.h
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringTable.h"
 #include "llvm/Option/OptSpecifier.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/StringSaver.h"
 #include <cassert>
 #include <string>
@@ -50,7 +51,7 @@ class Visibility {
 /// be needed at runtime; the OptTable class maintains enough information to
 /// parse command lines without instantiating Options, while letting other
 /// parts of the driver still use Option instances where convenient.
-class OptTable {
+class LLVM_ABI OptTable {
 public:
   /// Entry for a single option instance in the option data table.
   struct Info {
@@ -425,9 +426,9 @@ class OptTable {
 /// Specialization of OptTable
 class GenericOptTable : public OptTable {
 protected:
-  GenericOptTable(const StringTable &StrTable,
-                  ArrayRef<StringTable::Offset> PrefixesTable,
-                  ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
+  LLVM_ABI GenericOptTable(const StringTable &StrTable,
+                           ArrayRef<StringTable::Offset> PrefixesTable,
+                           ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
 };
 
 class PrecomputedOptTable : public OptTable {

diff  --git a/llvm/include/llvm/Option/Option.h b/llvm/include/llvm/Option/Option.h
index a0563da15c8ed..51c330a90813c 100644
--- a/llvm/include/llvm/Option/Option.h
+++ b/llvm/include/llvm/Option/Option.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/OptSpecifier.h"
 #include "llvm/Option/OptTable.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <cassert>
 
@@ -81,7 +82,7 @@ class Option {
   const OptTable *Owner;
 
 public:
-  Option(const OptTable::Info *Info, const OptTable *Owner);
+  LLVM_ABI Option(const OptTable::Info *Info, const OptTable *Owner);
 
   bool isValid() const {
     return Info != nullptr;
@@ -213,7 +214,7 @@ class Option {
   /// Note that matches against options which are an alias should never be
   /// done -- aliases do not participate in matching and so such a query will
   /// always be false.
-  bool matches(OptSpecifier ID) const;
+  LLVM_ABI bool matches(OptSpecifier ID) const;
 
   /// Potentially accept the current argument, returning a new Arg instance,
   /// or 0 if the option does not accept this argument (or the argument is
@@ -227,16 +228,17 @@ class Option {
   /// underlying storage to represent a Joined argument.
   /// \p GroupedShortOption If true, we are handling the fallback case of
   /// parsing a prefix of the current argument as a short option.
-  std::unique_ptr<Arg> accept(const ArgList &Args, StringRef CurArg,
-                              bool GroupedShortOption, unsigned &Index) const;
+  LLVM_ABI std::unique_ptr<Arg> accept(const ArgList &Args, StringRef CurArg,
+                                       bool GroupedShortOption,
+                                       unsigned &Index) const;
 
 private:
   std::unique_ptr<Arg> acceptInternal(const ArgList &Args, StringRef CurArg,
                                       unsigned &Index) const;
 
 public:
-  void print(raw_ostream &O, bool AddNewLine = true) const;
-  void dump() const;
+  LLVM_ABI void print(raw_ostream &O, bool AddNewLine = true) const;
+  LLVM_ABI void dump() const;
 };
 
 } // end namespace opt

diff  --git a/llvm/include/llvm/Remarks/Remark.h b/llvm/include/llvm/Remarks/Remark.h
index de81c5a992805..8c8ca769c7d16 100644
--- a/llvm/include/llvm/Remarks/Remark.h
+++ b/llvm/include/llvm/Remarks/Remark.h
@@ -17,6 +17,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CBindingWrapping.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include <optional>
 #include <string>
@@ -35,7 +36,7 @@ struct RemarkLocation {
   unsigned SourceColumn = 0;
 
   /// Implement operator<< on RemarkLocation.
-  void print(raw_ostream &OS) const;
+  LLVM_ABI void print(raw_ostream &OS) const;
 };
 
 // Create wrappers for C Binding types (see CBindingWrapping.h).
@@ -51,11 +52,11 @@ struct Argument {
   std::optional<RemarkLocation> Loc;
 
   /// Implement operator<< on Argument.
-  void print(raw_ostream &OS) const;
+  LLVM_ABI void print(raw_ostream &OS) const;
   /// Return the value of argument as int.
-  std::optional<int> getValAsInt() const;
+  LLVM_ABI std::optional<int> getValAsInt() const;
   /// Check if the argument value can be parsed as int.
-  bool isValInt() const;
+  LLVM_ABI bool isValInt() const;
 };
 
 // Create wrappers for C Binding types (see CBindingWrapping.h).
@@ -124,13 +125,13 @@ struct Remark {
   Remark &operator=(Remark &&) = default;
 
   /// Return a message composed from the arguments as a string.
-  std::string getArgsAsMsg() const;
+  LLVM_ABI std::string getArgsAsMsg() const;
 
   /// Clone this remark to explicitly ask for a copy.
   Remark clone() const { return *this; }
 
   /// Implement operator<< on Remark.
-  void print(raw_ostream &OS) const;
+  LLVM_ABI void print(raw_ostream &OS) const;
 
 private:
   /// In order to avoid unwanted copies, "delete" the copy constructor.

diff  --git a/llvm/include/llvm/Remarks/RemarkFormat.h b/llvm/include/llvm/Remarks/RemarkFormat.h
index 9c589eed44f39..64d08bcc9b8a1 100644
--- a/llvm/include/llvm/Remarks/RemarkFormat.h
+++ b/llvm/include/llvm/Remarks/RemarkFormat.h
@@ -14,6 +14,7 @@
 #define LLVM_REMARKS_REMARKFORMAT_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 
 namespace llvm {
@@ -25,10 +26,10 @@ constexpr StringLiteral Magic("REMARKS");
 enum class Format { Unknown, YAML, YAMLStrTab, Bitstream };
 
 /// Parse and validate a string for the remark format.
-Expected<Format> parseFormat(StringRef FormatStr);
+LLVM_ABI Expected<Format> parseFormat(StringRef FormatStr);
 
 /// Parse and validate a magic number to a remark format.
-Expected<Format> magicToFormat(StringRef Magic);
+LLVM_ABI Expected<Format> magicToFormat(StringRef Magic);
 
 } // end namespace remarks
 } // end namespace llvm

diff  --git a/llvm/include/llvm/Remarks/RemarkLinker.h b/llvm/include/llvm/Remarks/RemarkLinker.h
index f538718941c5d..5343c62144708 100644
--- a/llvm/include/llvm/Remarks/RemarkLinker.h
+++ b/llvm/include/llvm/Remarks/RemarkLinker.h
@@ -16,6 +16,7 @@
 #include "llvm/Remarks/Remark.h"
 #include "llvm/Remarks/RemarkFormat.h"
 #include "llvm/Remarks/RemarkStringTable.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include <memory>
 #include <optional>
@@ -69,7 +70,7 @@ struct RemarkLinker {
 
 public:
   /// Set a path to prepend to the external file path.
-  void setExternalFilePrependPath(StringRef PrependPath);
+  LLVM_ABI void setExternalFilePrependPath(StringRef PrependPath);
 
   /// Set KeepAllRemarks to \p B.
   void setKeepAllRemarks(bool B) { KeepAllRemarks = B; }
@@ -79,19 +80,19 @@ struct RemarkLinker {
   /// \p Buffer.
   /// \p Buffer can be either a standalone remark container or just
   /// metadata. This takes care of uniquing and merging the remarks.
-  Error link(StringRef Buffer,
-             std::optional<Format> RemarkFormat = std::nullopt);
+  LLVM_ABI Error link(StringRef Buffer,
+                      std::optional<Format> RemarkFormat = std::nullopt);
 
   /// Link the remarks found in \p Obj by looking for the right section and
   /// calling the method above.
-  Error link(const object::ObjectFile &Obj,
-             std::optional<Format> RemarkFormat = std::nullopt);
+  LLVM_ABI Error link(const object::ObjectFile &Obj,
+                      std::optional<Format> RemarkFormat = std::nullopt);
 
   /// Serialize the linked remarks to the stream \p OS, using the format \p
   /// RemarkFormat.
   /// This clears internal state such as the string table.
   /// Note: this implies that the serialization mode is standalone.
-  Error serialize(raw_ostream &OS, Format RemarksFormat) const;
+  LLVM_ABI Error serialize(raw_ostream &OS, Format RemarksFormat) const;
 
   /// Check whether there are any remarks linked.
   bool empty() const { return Remarks.empty(); }
@@ -109,7 +110,7 @@ struct RemarkLinker {
 /// Returns a buffer with the contents of the remarks section depending on the
 /// format of the file. If the section doesn't exist, this returns an empty
 /// optional.
-Expected<std::optional<StringRef>>
+LLVM_ABI Expected<std::optional<StringRef>>
 getRemarksSectionContents(const object::ObjectFile &Obj);
 
 } // end namespace remarks

diff  --git a/llvm/include/llvm/Remarks/RemarkParser.h b/llvm/include/llvm/Remarks/RemarkParser.h
index 1333c582eba4f..abb1fb86a87e9 100644
--- a/llvm/include/llvm/Remarks/RemarkParser.h
+++ b/llvm/include/llvm/Remarks/RemarkParser.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Remarks/RemarkFormat.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include <memory>
 #include <optional>
@@ -26,7 +27,7 @@ struct Remark;
 
 class EndOfFileError : public ErrorInfo<EndOfFileError> {
 public:
-  static char ID;
+  LLVM_ABI static char ID;
 
   EndOfFileError() = default;
 
@@ -64,7 +65,7 @@ struct ParsedStringTable {
   /// SmallVector for once.
   std::vector<size_t> Offsets;
 
-  ParsedStringTable(StringRef Buffer);
+  LLVM_ABI ParsedStringTable(StringRef Buffer);
   /// Disable copy.
   ParsedStringTable(const ParsedStringTable &) = delete;
   ParsedStringTable &operator=(const ParsedStringTable &) = delete;
@@ -73,17 +74,17 @@ struct ParsedStringTable {
   ParsedStringTable &operator=(ParsedStringTable &&) = default;
 
   size_t size() const { return Offsets.size(); }
-  Expected<StringRef> operator[](size_t Index) const;
+  LLVM_ABI Expected<StringRef> operator[](size_t Index) const;
 };
 
-Expected<std::unique_ptr<RemarkParser>> createRemarkParser(Format ParserFormat,
-                                                           StringRef Buf);
+LLVM_ABI Expected<std::unique_ptr<RemarkParser>>
+createRemarkParser(Format ParserFormat, StringRef Buf);
 
-Expected<std::unique_ptr<RemarkParser>>
+LLVM_ABI Expected<std::unique_ptr<RemarkParser>>
 createRemarkParser(Format ParserFormat, StringRef Buf,
                    ParsedStringTable StrTab);
 
-Expected<std::unique_ptr<RemarkParser>> createRemarkParserFromMeta(
+LLVM_ABI Expected<std::unique_ptr<RemarkParser>> createRemarkParserFromMeta(
     Format ParserFormat, StringRef Buf,
     std::optional<ParsedStringTable> StrTab = std::nullopt,
     std::optional<StringRef> ExternalFilePrependPath = std::nullopt);

diff  --git a/llvm/include/llvm/Remarks/RemarkSerializer.h b/llvm/include/llvm/Remarks/RemarkSerializer.h
index f73135f4fbd38..05ef14ae5566b 100644
--- a/llvm/include/llvm/Remarks/RemarkSerializer.h
+++ b/llvm/include/llvm/Remarks/RemarkSerializer.h
@@ -15,6 +15,7 @@
 
 #include "llvm/Remarks/RemarkFormat.h"
 #include "llvm/Remarks/RemarkStringTable.h"
+#include "llvm/Support/Compiler.h"
 #include <optional>
 
 namespace llvm {
@@ -77,12 +78,12 @@ struct MetaSerializer {
 };
 
 /// Create a remark serializer.
-Expected<std::unique_ptr<RemarkSerializer>>
+LLVM_ABI Expected<std::unique_ptr<RemarkSerializer>>
 createRemarkSerializer(Format RemarksFormat, SerializerMode Mode,
                        raw_ostream &OS);
 
 /// Create a remark serializer that uses a pre-filled string table.
-Expected<std::unique_ptr<RemarkSerializer>>
+LLVM_ABI Expected<std::unique_ptr<RemarkSerializer>>
 createRemarkSerializer(Format RemarksFormat, SerializerMode Mode,
                        raw_ostream &OS, remarks::StringTable StrTab);
 

diff  --git a/llvm/include/llvm/Remarks/RemarkStringTable.h b/llvm/include/llvm/Remarks/RemarkStringTable.h
index fe302c64d17f0..fd88361e3d589 100644
--- a/llvm/include/llvm/Remarks/RemarkStringTable.h
+++ b/llvm/include/llvm/Remarks/RemarkStringTable.h
@@ -18,6 +18,7 @@
 
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/Compiler.h"
 #include <vector>
 
 namespace llvm {
@@ -50,22 +51,22 @@ struct StringTable {
   StringTable &operator=(StringTable &&) = default;
 
   /// Construct a string table from a ParsedStringTable.
-  StringTable(const ParsedStringTable &Other);
+  LLVM_ABI StringTable(const ParsedStringTable &Other);
 
   /// Add a string to the table. It returns an unique ID of the string.
-  std::pair<unsigned, StringRef> add(StringRef Str);
+  LLVM_ABI std::pair<unsigned, StringRef> add(StringRef Str);
   /// Modify \p R to use strings from this string table. If the string table
   /// does not contain the strings, it adds them.
-  void internalize(Remark &R);
+  LLVM_ABI void internalize(Remark &R);
   /// Serialize the string table to a stream. It is serialized as a little
   /// endian uint64 (the size of the table in bytes) followed by a sequence of
   /// NULL-terminated strings, where the N-th string is the string with the ID N
   /// in the StrTab map.
-  void serialize(raw_ostream &OS) const;
+  LLVM_ABI void serialize(raw_ostream &OS) const;
   /// Serialize the string table to a vector. This allows users to do the actual
   /// writing to file/memory/other.
   /// The string with the ID == N should be the N-th element in the vector.
-  std::vector<StringRef> serialize() const;
+  LLVM_ABI std::vector<StringRef> serialize() const;
 };
 
 } // end namespace remarks

diff  --git a/llvm/include/llvm/Remarks/YAMLRemarkSerializer.h b/llvm/include/llvm/Remarks/YAMLRemarkSerializer.h
index d2a1db5791ae0..a2214c349e1cf 100644
--- a/llvm/include/llvm/Remarks/YAMLRemarkSerializer.h
+++ b/llvm/include/llvm/Remarks/YAMLRemarkSerializer.h
@@ -14,6 +14,7 @@
 #define LLVM_REMARKS_YAMLREMARKSERIALIZER_H
 
 #include "llvm/Remarks/RemarkSerializer.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/YAMLTraits.h"
 #include <optional>
 
@@ -31,7 +32,7 @@ namespace remarks {
 ///   - <KEY>: <VALUE>
 ///     DebugLoc:        { File: <FILE>, Line: <LINE>, Column: <COL> }
 /// ...
-struct YAMLRemarkSerializer : public RemarkSerializer {
+struct LLVM_ABI YAMLRemarkSerializer : public RemarkSerializer {
   /// The YAML streamer.
   yaml::Output YAMLOutput;
 
@@ -53,7 +54,7 @@ struct YAMLRemarkSerializer : public RemarkSerializer {
                        std::optional<StringTable> StrTab = std::nullopt);
 };
 
-struct YAMLMetaSerializer : public MetaSerializer {
+struct LLVM_ABI YAMLMetaSerializer : public MetaSerializer {
   std::optional<StringRef> ExternalFilename;
 
   YAMLMetaSerializer(raw_ostream &OS, std::optional<StringRef> ExternalFilename)
@@ -65,7 +66,7 @@ struct YAMLMetaSerializer : public MetaSerializer {
 /// Serialize the remarks to YAML using a string table. An remark entry looks
 /// like the regular YAML remark but instead of string entries it's using
 /// numbers that map to an index in the string table.
-struct YAMLStrTabRemarkSerializer : public YAMLRemarkSerializer {
+struct LLVM_ABI YAMLStrTabRemarkSerializer : public YAMLRemarkSerializer {
   /// Wether we already emitted the metadata in standalone mode.
   /// This should be set to true after the first invocation of `emit`.
   bool DidEmitMeta = false;
@@ -91,7 +92,7 @@ struct YAMLStrTabRemarkSerializer : public YAMLRemarkSerializer {
   }
 };
 
-struct YAMLStrTabMetaSerializer : public YAMLMetaSerializer {
+struct LLVM_ABI YAMLStrTabMetaSerializer : public YAMLMetaSerializer {
   /// The string table is part of the metadata.
   const StringTable &StrTab;
 


        


More information about the llvm-commits mailing list