Skip to content

Revert "[llvm] annotate interfaces in llvm/Option and llvm/Remarks for DLL export (#142856) #144412

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions llvm/include/llvm/Option/Arg.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/Compiler.h"
#include <string>

namespace llvm {
Expand Down Expand Up @@ -71,16 +70,15 @@ class Arg {
std::unique_ptr<Arg> Alias;

public:
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 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);
Arg(const Arg &) = delete;
Arg &operator=(const Arg &) = delete;
LLVM_ABI ~Arg();
~Arg();

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

Expand Down Expand Up @@ -136,23 +134,23 @@ class Arg {
}

/// Append the argument onto the given array as strings.
LLVM_ABI void render(const ArgList &Args, ArgStringList &Output) const;
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).
LLVM_ABI void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
void renderAsInput(const ArgList &Args, ArgStringList &Output) const;

LLVM_ABI void print(raw_ostream &O) const;
LLVM_ABI void dump() const;
void print(raw_ostream &O) const;
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.
LLVM_ABI std::string getAsString(const ArgList &Args) const;
std::string getAsString(const ArgList &Args) const;
};

} // end namespace opt
Expand Down
64 changes: 29 additions & 35 deletions llvm/include/llvm/Option/ArgList.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@

#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>
Expand Down Expand Up @@ -140,7 +139,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.
LLVM_ABI OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;
OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;

protected:
// Make the default special members protected so they won't be used to slice
Expand Down Expand Up @@ -179,7 +178,7 @@ class ArgList {
/// @{

/// append - Append \p A to the arg list.
LLVM_ABI void append(Arg *A);
void append(Arg *A);

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

Expand Down Expand Up @@ -228,7 +227,7 @@ class ArgList {
/// @{

/// eraseArg - Remove any option matching \p Id.
LLVM_ABI void eraseArg(OptSpecifier Id);
void eraseArg(OptSpecifier Id);

/// @}
/// @name Arg Access
Expand Down Expand Up @@ -285,12 +284,11 @@ class ArgList {
/// @{

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

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

/// @}
/// @name Translation Utilities
Expand All @@ -300,21 +298,20 @@ 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.
LLVM_ABI bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
LLVM_ABI bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg,
bool Default) const;
bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
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.
LLVM_ABI bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias,
OptSpecifier Neg, bool Default) const;
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.
LLVM_ABI void addOptInFlag(ArgStringList &Output, OptSpecifier Pos,
OptSpecifier Neg) const;
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 {
Expand All @@ -334,35 +331,32 @@ class ArgList {

/// AddAllArgsExcept - Render all arguments matching any of the given ids
/// and not matching any of the excluded ids.
LLVM_ABI void AddAllArgsExcept(ArgStringList &Output,
ArrayRef<OptSpecifier> Ids,
ArrayRef<OptSpecifier> ExcludeIds) const;
void AddAllArgsExcept(ArgStringList &Output, ArrayRef<OptSpecifier> Ids,
ArrayRef<OptSpecifier> ExcludeIds) const;
/// Render all arguments matching any of the given ids.
LLVM_ABI void addAllArgs(ArgStringList &Output,
ArrayRef<OptSpecifier> Ids) const;
void addAllArgs(ArgStringList &Output, ArrayRef<OptSpecifier> Ids) const;

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

/// AddAllArgValues - Render the argument values of all arguments
/// matching the given ids.
LLVM_ABI void AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
OptSpecifier Id1 = 0U,
OptSpecifier Id2 = 0U) const;
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
/// name instead of the first option value.
///
/// \param Joined - If true, render the argument as joined with
/// the option specifier.
LLVM_ABI void AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
const char *Translation,
bool Joined = false) const;
void AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
const char *Translation,
bool Joined = false) const;

/// ClaimAllArgs - Claim all arguments which match the given
/// option id.
LLVM_ABI void ClaimAllArgs(OptSpecifier Id0) const;
void ClaimAllArgs(OptSpecifier Id0) const;

template <typename... OptSpecifiers>
void claimAllArgs(OptSpecifiers... Ids) const {
Expand All @@ -372,7 +366,7 @@ class ArgList {

/// ClaimAllArgs - Claim all arguments.
///
LLVM_ABI void ClaimAllArgs() const;
void ClaimAllArgs() const;
/// @}
/// @name Arg Synthesis
/// @{
Expand All @@ -387,16 +381,16 @@ class ArgList {

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

LLVM_ABI void print(raw_ostream &O) const;
LLVM_ABI void dump() const;
void print(raw_ostream &O) const;
void dump() const;

/// @}
};

class LLVM_ABI InputArgList final : public ArgList {
class InputArgList final : public ArgList {
private:
/// List of argument strings used by the contained Args.
///
Expand Down Expand Up @@ -469,7 +463,7 @@ class LLVM_ABI InputArgList final : public ArgList {

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

/// The list of arguments we synthesized.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Option/OptSpecifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OptSpecifier {
OptSpecifier() = default;
explicit OptSpecifier(bool) = delete;
/*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
/*implicit*/ LLVM_ABI OptSpecifier(const Option *Opt);
/*implicit*/ OptSpecifier(const Option *Opt);

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

Expand Down
9 changes: 4 additions & 5 deletions llvm/include/llvm/Option/OptTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#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>
Expand Down Expand Up @@ -51,7 +50,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 LLVM_ABI OptTable {
class OptTable {
public:
/// Entry for a single option instance in the option data table.
struct Info {
Expand Down Expand Up @@ -426,9 +425,9 @@ class LLVM_ABI OptTable {
/// Specialization of OptTable
class GenericOptTable : public OptTable {
protected:
LLVM_ABI GenericOptTable(const StringTable &StrTable,
ArrayRef<StringTable::Offset> PrefixesTable,
ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
GenericOptTable(const StringTable &StrTable,
ArrayRef<StringTable::Offset> PrefixesTable,
ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
};

class PrecomputedOptTable : public OptTable {
Expand Down
14 changes: 6 additions & 8 deletions llvm/include/llvm/Option/Option.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#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>

Expand Down Expand Up @@ -82,7 +81,7 @@ class Option {
const OptTable *Owner;

public:
LLVM_ABI Option(const OptTable::Info *Info, const OptTable *Owner);
Option(const OptTable::Info *Info, const OptTable *Owner);

bool isValid() const {
return Info != nullptr;
Expand Down Expand Up @@ -214,7 +213,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.
LLVM_ABI bool matches(OptSpecifier ID) const;
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
Expand All @@ -228,17 +227,16 @@ 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.
LLVM_ABI std::unique_ptr<Arg> accept(const ArgList &Args, StringRef CurArg,
bool GroupedShortOption,
unsigned &Index) const;
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:
LLVM_ABI void print(raw_ostream &O, bool AddNewLine = true) const;
LLVM_ABI void dump() const;
void print(raw_ostream &O, bool AddNewLine = true) const;
void dump() const;
};

} // end namespace opt
Expand Down
13 changes: 6 additions & 7 deletions llvm/include/llvm/Remarks/Remark.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#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>
Expand All @@ -36,7 +35,7 @@ struct RemarkLocation {
unsigned SourceColumn = 0;

/// Implement operator<< on RemarkLocation.
LLVM_ABI void print(raw_ostream &OS) const;
void print(raw_ostream &OS) const;
};

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

/// Implement operator<< on Argument.
LLVM_ABI void print(raw_ostream &OS) const;
void print(raw_ostream &OS) const;
/// Return the value of argument as int.
LLVM_ABI std::optional<int> getValAsInt() const;
std::optional<int> getValAsInt() const;
/// Check if the argument value can be parsed as int.
LLVM_ABI bool isValInt() const;
bool isValInt() const;
};

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

/// Return a message composed from the arguments as a string.
LLVM_ABI std::string getArgsAsMsg() const;
std::string getArgsAsMsg() const;

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

/// Implement operator<< on Remark.
LLVM_ABI void print(raw_ostream &OS) const;
void print(raw_ostream &OS) const;

private:
/// In order to avoid unwanted copies, "delete" the copy constructor.
Expand Down
5 changes: 2 additions & 3 deletions llvm/include/llvm/Remarks/RemarkFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#define LLVM_REMARKS_REMARKFORMAT_H

#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"

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

/// Parse and validate a string for the remark format.
LLVM_ABI Expected<Format> parseFormat(StringRef FormatStr);
Expected<Format> parseFormat(StringRef FormatStr);

/// Parse and validate a magic number to a remark format.
LLVM_ABI Expected<Format> magicToFormat(StringRef Magic);
Expected<Format> magicToFormat(StringRef Magic);

} // end namespace remarks
} // end namespace llvm
Expand Down
Loading
Loading