Skip to content

Commit c6ff512

Browse files
committed
[llvm] annotate interfaces in Option and Remarks libraries for DLL export
1 parent da8271e commit c6ff512

File tree

12 files changed

+79
-68
lines changed

12 files changed

+79
-68
lines changed

llvm/include/llvm/Option/Arg.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_OPTION_ARG_H
1515
#define LLVM_OPTION_ARG_H
1616

17+
#include "llvm/Support/Compiler.h"
1718
#include "llvm/ADT/SmallVector.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/Option/Option.h"
@@ -70,15 +71,15 @@ class Arg {
7071
std::unique_ptr<Arg> Alias;
7172

7273
public:
73-
Arg(const Option Opt, StringRef Spelling, unsigned Index,
74+
LLVM_ABI Arg(const Option Opt, StringRef Spelling, unsigned Index,
7475
const Arg *BaseArg = nullptr);
75-
Arg(const Option Opt, StringRef Spelling, unsigned Index,
76+
LLVM_ABI Arg(const Option Opt, StringRef Spelling, unsigned Index,
7677
const char *Value0, const Arg *BaseArg = nullptr);
77-
Arg(const Option Opt, StringRef Spelling, unsigned Index,
78+
LLVM_ABI Arg(const Option Opt, StringRef Spelling, unsigned Index,
7879
const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
7980
Arg(const Arg &) = delete;
8081
Arg &operator=(const Arg &) = delete;
81-
~Arg();
82+
LLVM_ABI ~Arg();
8283

8384
const Option &getOption() const { return Opt; }
8485

@@ -134,23 +135,23 @@ class Arg {
134135
}
135136

136137
/// Append the argument onto the given array as strings.
137-
void render(const ArgList &Args, ArgStringList &Output) const;
138+
LLVM_ABI void render(const ArgList &Args, ArgStringList &Output) const;
138139

139140
/// Append the argument, render as an input, onto the given
140141
/// array as strings.
141142
///
142143
/// The distinction is that some options only render their values
143144
/// when rendered as a input (e.g., Xlinker).
144-
void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
145+
LLVM_ABI void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
145146

146-
void print(raw_ostream &O) const;
147-
void dump() const;
147+
LLVM_ABI void print(raw_ostream &O) const;
148+
LLVM_ABI void dump() const;
148149

149150
/// Return a formatted version of the argument and its values, for
150151
/// diagnostics. Since this is for diagnostics, if this Arg was produced
151152
/// through an alias, this returns the string representation of the alias
152153
/// that the user wrote.
153-
std::string getAsString(const ArgList &Args) const;
154+
LLVM_ABI std::string getAsString(const ArgList &Args) const;
154155
};
155156

156157
} // end namespace opt

llvm/include/llvm/Option/ArgList.h

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

12+
#include "llvm/Support/Compiler.h"
1213
#include "llvm/ADT/ArrayRef.h"
1314
#include "llvm/ADT/DenseMap.h"
1415
#include "llvm/ADT/iterator_range.h"
@@ -139,7 +140,7 @@ class ArgList {
139140

140141
/// Get the range of indexes in which options with the specified IDs might
141142
/// reside, or (0, 0) if there are no such options.
142-
OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;
143+
LLVM_ABI OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;
143144

144145
protected:
145146
// Make the default special members protected so they won't be used to slice
@@ -178,7 +179,7 @@ class ArgList {
178179
/// @{
179180

180181
/// append - Append \p A to the arg list.
181-
void append(Arg *A);
182+
LLVM_ABI void append(Arg *A);
182183

183184
const arglist_type &getArgs() const { return Args; }
184185

@@ -227,7 +228,7 @@ class ArgList {
227228
/// @{
228229

229230
/// eraseArg - Remove any option matching \p Id.
230-
void eraseArg(OptSpecifier Id);
231+
LLVM_ABI void eraseArg(OptSpecifier Id);
231232

232233
/// @}
233234
/// @name Arg Access
@@ -284,11 +285,11 @@ class ArgList {
284285
/// @{
285286

286287
/// getLastArgValue - Return the value of the last argument, or a default.
287-
StringRef getLastArgValue(OptSpecifier Id, StringRef Default = "") const;
288+
LLVM_ABI StringRef getLastArgValue(OptSpecifier Id, StringRef Default = "") const;
288289

289290
/// getAllArgValues - Get the values of all instances of the given argument
290291
/// as strings.
291-
std::vector<std::string> getAllArgValues(OptSpecifier Id) const;
292+
LLVM_ABI std::vector<std::string> getAllArgValues(OptSpecifier Id) const;
292293

293294
/// @}
294295
/// @name Translation Utilities
@@ -298,19 +299,19 @@ class ArgList {
298299
/// true if the option is present, false if the negation is present, and
299300
/// \p Default if neither option is given. If both the option and its
300301
/// negation are present, the last one wins.
301-
bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
302-
bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
302+
LLVM_ABI bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
303+
LLVM_ABI bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
303304

304305
/// hasFlag - Given an option \p Pos, an alias \p PosAlias and its negative
305306
/// form \p Neg, return true if the option or its alias is present, false if
306307
/// the negation is present, and \p Default if none of the options are
307308
/// given. If multiple options are present, the last one wins.
308-
bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
309+
LLVM_ABI bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
309310
bool Default) const;
310311

311312
/// Given an option Pos and its negative form Neg, render the option if Pos is
312313
/// present.
313-
void addOptInFlag(ArgStringList &Output, OptSpecifier Pos,
314+
LLVM_ABI void addOptInFlag(ArgStringList &Output, OptSpecifier Pos,
314315
OptSpecifier Neg) const;
315316
/// Render the option if Neg is present.
316317
void addOptOutFlag(ArgStringList &Output, OptSpecifier Pos,
@@ -331,17 +332,17 @@ class ArgList {
331332

332333
/// AddAllArgsExcept - Render all arguments matching any of the given ids
333334
/// and not matching any of the excluded ids.
334-
void AddAllArgsExcept(ArgStringList &Output, ArrayRef<OptSpecifier> Ids,
335+
LLVM_ABI void AddAllArgsExcept(ArgStringList &Output, ArrayRef<OptSpecifier> Ids,
335336
ArrayRef<OptSpecifier> ExcludeIds) const;
336337
/// Render all arguments matching any of the given ids.
337-
void addAllArgs(ArgStringList &Output, ArrayRef<OptSpecifier> Ids) const;
338+
LLVM_ABI void addAllArgs(ArgStringList &Output, ArrayRef<OptSpecifier> Ids) const;
338339

339340
/// AddAllArgs - Render all arguments matching the given ids.
340-
void AddAllArgs(ArgStringList &Output, OptSpecifier Id0) const;
341+
LLVM_ABI void AddAllArgs(ArgStringList &Output, OptSpecifier Id0) const;
341342

342343
/// AddAllArgValues - Render the argument values of all arguments
343344
/// matching the given ids.
344-
void AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
345+
LLVM_ABI void AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
345346
OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;
346347

347348
/// AddAllArgsTranslated - Render all the arguments matching the
@@ -350,13 +351,13 @@ class ArgList {
350351
///
351352
/// \param Joined - If true, render the argument as joined with
352353
/// the option specifier.
353-
void AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
354+
LLVM_ABI void AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
354355
const char *Translation,
355356
bool Joined = false) const;
356357

357358
/// ClaimAllArgs - Claim all arguments which match the given
358359
/// option id.
359-
void ClaimAllArgs(OptSpecifier Id0) const;
360+
LLVM_ABI void ClaimAllArgs(OptSpecifier Id0) const;
360361

361362
template <typename... OptSpecifiers>
362363
void claimAllArgs(OptSpecifiers... Ids) const {
@@ -366,7 +367,7 @@ class ArgList {
366367

367368
/// ClaimAllArgs - Claim all arguments.
368369
///
369-
void ClaimAllArgs() const;
370+
LLVM_ABI void ClaimAllArgs() const;
370371
/// @}
371372
/// @name Arg Synthesis
372373
/// @{
@@ -381,16 +382,16 @@ class ArgList {
381382

382383
/// Create an arg string for (\p LHS + \p RHS), reusing the
383384
/// string at \p Index if possible.
384-
const char *GetOrMakeJoinedArgString(unsigned Index, StringRef LHS,
385+
LLVM_ABI const char *GetOrMakeJoinedArgString(unsigned Index, StringRef LHS,
385386
StringRef RHS) const;
386387

387-
void print(raw_ostream &O) const;
388-
void dump() const;
388+
LLVM_ABI void print(raw_ostream &O) const;
389+
LLVM_ABI void dump() const;
389390

390391
/// @}
391392
};
392393

393-
class InputArgList final : public ArgList {
394+
class LLVM_ABI InputArgList final : public ArgList {
394395
private:
395396
/// List of argument strings used by the contained Args.
396397
///
@@ -463,7 +464,7 @@ class InputArgList final : public ArgList {
463464

464465
/// DerivedArgList - An ordered collection of driver arguments,
465466
/// whose storage may be in another argument list.
466-
class DerivedArgList final : public ArgList {
467+
class LLVM_ABI DerivedArgList final : public ArgList {
467468
const InputArgList &BaseArgs;
468469

469470
/// The list of arguments we synthesized.

llvm/include/llvm/Option/OptSpecifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class OptSpecifier {
2222
OptSpecifier() = default;
2323
explicit OptSpecifier(bool) = delete;
2424
/*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
25-
/*implicit*/ OptSpecifier(const Option *Opt);
25+
/*implicit*/ LLVM_ABI OptSpecifier(const Option *Opt);
2626

2727
bool isValid() const { return ID != 0; }
2828

llvm/include/llvm/Option/OptTable.h

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

12+
#include "llvm/Support/Compiler.h"
1213
#include "llvm/ADT/ArrayRef.h"
1314
#include "llvm/ADT/SmallString.h"
1415
#include "llvm/ADT/StringRef.h"
@@ -50,7 +51,7 @@ class Visibility {
5051
/// be needed at runtime; the OptTable class maintains enough information to
5152
/// parse command lines without instantiating Options, while letting other
5253
/// parts of the driver still use Option instances where convenient.
53-
class OptTable {
54+
class LLVM_ABI OptTable {
5455
public:
5556
/// Entry for a single option instance in the option data table.
5657
struct Info {
@@ -425,7 +426,7 @@ class OptTable {
425426
/// Specialization of OptTable
426427
class GenericOptTable : public OptTable {
427428
protected:
428-
GenericOptTable(const StringTable &StrTable,
429+
LLVM_ABI GenericOptTable(const StringTable &StrTable,
429430
ArrayRef<StringTable::Offset> PrefixesTable,
430431
ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
431432
};

llvm/include/llvm/Option/Option.h

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

12+
#include "llvm/Support/Compiler.h"
1213
#include "llvm/ADT/SmallVector.h"
1314
#include "llvm/ADT/StringRef.h"
1415
#include "llvm/Option/OptSpecifier.h"
@@ -81,7 +82,7 @@ class Option {
8182
const OptTable *Owner;
8283

8384
public:
84-
Option(const OptTable::Info *Info, const OptTable *Owner);
85+
LLVM_ABI Option(const OptTable::Info *Info, const OptTable *Owner);
8586

8687
bool isValid() const {
8788
return Info != nullptr;
@@ -213,7 +214,7 @@ class Option {
213214
/// Note that matches against options which are an alias should never be
214215
/// done -- aliases do not participate in matching and so such a query will
215216
/// always be false.
216-
bool matches(OptSpecifier ID) const;
217+
LLVM_ABI bool matches(OptSpecifier ID) const;
217218

218219
/// Potentially accept the current argument, returning a new Arg instance,
219220
/// or 0 if the option does not accept this argument (or the argument is
@@ -227,16 +228,16 @@ class Option {
227228
/// underlying storage to represent a Joined argument.
228229
/// \p GroupedShortOption If true, we are handling the fallback case of
229230
/// parsing a prefix of the current argument as a short option.
230-
std::unique_ptr<Arg> accept(const ArgList &Args, StringRef CurArg,
231+
LLVM_ABI std::unique_ptr<Arg> accept(const ArgList &Args, StringRef CurArg,
231232
bool GroupedShortOption, unsigned &Index) const;
232233

233234
private:
234235
std::unique_ptr<Arg> acceptInternal(const ArgList &Args, StringRef CurArg,
235236
unsigned &Index) const;
236237

237238
public:
238-
void print(raw_ostream &O, bool AddNewLine = true) const;
239-
void dump() const;
239+
LLVM_ABI void print(raw_ostream &O, bool AddNewLine = true) const;
240+
LLVM_ABI void dump() const;
240241
};
241242

242243
} // end namespace opt

llvm/include/llvm/Remarks/Remark.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_REMARKS_REMARK_H
1414
#define LLVM_REMARKS_REMARK_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm-c/Remarks.h"
1718
#include "llvm/ADT/SmallVector.h"
1819
#include "llvm/ADT/StringRef.h"
@@ -35,7 +36,7 @@ struct RemarkLocation {
3536
unsigned SourceColumn = 0;
3637

3738
/// Implement operator<< on RemarkLocation.
38-
void print(raw_ostream &OS) const;
39+
LLVM_ABI void print(raw_ostream &OS) const;
3940
};
4041

4142
// Create wrappers for C Binding types (see CBindingWrapping.h).
@@ -51,11 +52,11 @@ struct Argument {
5152
std::optional<RemarkLocation> Loc;
5253

5354
/// Implement operator<< on Argument.
54-
void print(raw_ostream &OS) const;
55+
LLVM_ABI void print(raw_ostream &OS) const;
5556
/// Return the value of argument as int.
56-
std::optional<int> getValAsInt() const;
57+
LLVM_ABI std::optional<int> getValAsInt() const;
5758
/// Check if the argument value can be parsed as int.
58-
bool isValInt() const;
59+
LLVM_ABI bool isValInt() const;
5960
};
6061

6162
// Create wrappers for C Binding types (see CBindingWrapping.h).
@@ -124,13 +125,13 @@ struct Remark {
124125
Remark &operator=(Remark &&) = default;
125126

126127
/// Return a message composed from the arguments as a string.
127-
std::string getArgsAsMsg() const;
128+
LLVM_ABI std::string getArgsAsMsg() const;
128129

129130
/// Clone this remark to explicitly ask for a copy.
130131
Remark clone() const { return *this; }
131132

132133
/// Implement operator<< on Remark.
133-
void print(raw_ostream &OS) const;
134+
LLVM_ABI void print(raw_ostream &OS) const;
134135

135136
private:
136137
/// In order to avoid unwanted copies, "delete" the copy constructor.

llvm/include/llvm/Remarks/RemarkFormat.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_REMARKS_REMARKFORMAT_H
1414
#define LLVM_REMARKS_REMARKFORMAT_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/ADT/StringRef.h"
1718
#include "llvm/Support/Error.h"
1819

@@ -25,10 +26,10 @@ constexpr StringLiteral Magic("REMARKS");
2526
enum class Format { Unknown, YAML, YAMLStrTab, Bitstream };
2627

2728
/// Parse and validate a string for the remark format.
28-
Expected<Format> parseFormat(StringRef FormatStr);
29+
LLVM_ABI Expected<Format> parseFormat(StringRef FormatStr);
2930

3031
/// Parse and validate a magic number to a remark format.
31-
Expected<Format> magicToFormat(StringRef Magic);
32+
LLVM_ABI Expected<Format> magicToFormat(StringRef Magic);
3233

3334
} // end namespace remarks
3435
} // end namespace llvm

0 commit comments

Comments
 (0)