Skip to content

Commit cd32962

Browse files
committed
[llvm] export private API so that FileCheckTests builds against Windows DLL
1 parent 256b241 commit cd32962

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

llvm/lib/FileCheck/FileCheckImpl.h

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/ADT/StringMap.h"
2020
#include "llvm/ADT/StringRef.h"
2121
#include "llvm/FileCheck/FileCheck.h"
22+
#include "llvm/Support/Compiler.h"
2223
#include "llvm/Support/Error.h"
2324
#include "llvm/Support/SourceMgr.h"
2425
#include <map>
@@ -88,23 +89,24 @@ struct ExpressionFormat {
8889
/// \returns a wildcard regular expression string that matches any value in
8990
/// the format represented by this instance and no other value, or an error
9091
/// if the format is NoFormat.
91-
Expected<std::string> getWildcardRegex() const;
92+
LLVM_ABI Expected<std::string> getWildcardRegex() const;
9293

9394
/// \returns the string representation of \p Value in the format represented
9495
/// by this instance, or an error if conversion to this format failed or the
9596
/// format is NoFormat.
96-
Expected<std::string> getMatchingString(APInt Value) const;
97+
LLVM_ABI Expected<std::string> getMatchingString(APInt Value) const;
9798

9899
/// \returns the value corresponding to string representation \p StrVal
99100
/// according to the matching format represented by this instance.
100-
APInt valueFromStringRepr(StringRef StrVal, const SourceMgr &SM) const;
101+
LLVM_ABI APInt valueFromStringRepr(StringRef StrVal,
102+
const SourceMgr &SM) const;
101103
};
102104

103105
/// Class to represent an overflow error that might result when manipulating a
104106
/// value.
105107
class OverflowError : public ErrorInfo<OverflowError> {
106108
public:
107-
static char ID;
109+
LLVM_ABI static char ID;
108110

109111
std::error_code convertToErrorCode() const override {
110112
return std::make_error_code(std::errc::value_too_large);
@@ -115,10 +117,14 @@ class OverflowError : public ErrorInfo<OverflowError> {
115117

116118
/// Performs operation and \returns its result or an error in case of failure,
117119
/// such as if an overflow occurs.
118-
Expected<APInt> exprAdd(const APInt &Lhs, const APInt &Rhs, bool &Overflow);
119-
Expected<APInt> exprSub(const APInt &Lhs, const APInt &Rhs, bool &Overflow);
120-
Expected<APInt> exprMul(const APInt &Lhs, const APInt &Rhs, bool &Overflow);
121-
Expected<APInt> exprDiv(const APInt &Lhs, const APInt &Rhs, bool &Overflow);
120+
LLVM_ABI Expected<APInt> exprAdd(const APInt &Lhs, const APInt &Rhs,
121+
bool &Overflow);
122+
LLVM_ABI Expected<APInt> exprSub(const APInt &Lhs, const APInt &Rhs,
123+
bool &Overflow);
124+
LLVM_ABI Expected<APInt> exprMul(const APInt &Lhs, const APInt &Rhs,
125+
bool &Overflow);
126+
LLVM_ABI Expected<APInt> exprDiv(const APInt &Lhs, const APInt &Rhs,
127+
bool &Overflow);
122128
Expected<APInt> exprMax(const APInt &Lhs, const APInt &Rhs, bool &Overflow);
123129
Expected<APInt> exprMin(const APInt &Lhs, const APInt &Rhs, bool &Overflow);
124130

@@ -169,7 +175,7 @@ class UndefVarError : public ErrorInfo<UndefVarError> {
169175
StringRef VarName;
170176

171177
public:
172-
static char ID;
178+
LLVM_ABI static char ID;
173179

174180
UndefVarError(StringRef VarName) : VarName(VarName) {}
175181

@@ -277,7 +283,7 @@ class NumericVariable {
277283

278284
/// Class representing the use of a numeric variable in the AST of an
279285
/// expression.
280-
class NumericVariableUse : public ExpressionAST {
286+
class LLVM_ABI NumericVariableUse : public ExpressionAST {
281287
private:
282288
/// Pointer to the class instance for the variable this use is about.
283289
NumericVariable *Variable;
@@ -299,7 +305,7 @@ class NumericVariableUse : public ExpressionAST {
299305
using binop_eval_t = Expected<APInt> (*)(const APInt &, const APInt &, bool &);
300306

301307
/// Class representing a single binary operation in the AST of an expression.
302-
class BinaryOperation : public ExpressionAST {
308+
class LLVM_ABI BinaryOperation : public ExpressionAST {
303309
private:
304310
/// Left operand.
305311
std::unique_ptr<ExpressionAST> LeftOperand;
@@ -371,7 +377,7 @@ class Substitution {
371377
virtual Expected<std::string> getResult() const = 0;
372378
};
373379

374-
class StringSubstitution : public Substitution {
380+
class LLVM_ABI StringSubstitution : public Substitution {
375381
public:
376382
StringSubstitution(FileCheckPatternContext *Context, StringRef VarName,
377383
size_t InsertIdx)
@@ -382,7 +388,7 @@ class StringSubstitution : public Substitution {
382388
Expected<std::string> getResult() const override;
383389
};
384390

385-
class NumericSubstitution : public Substitution {
391+
class LLVM_ABI NumericSubstitution : public Substitution {
386392
private:
387393
/// Pointer to the class representing the expression whose value is to be
388394
/// substituted.
@@ -447,24 +453,24 @@ class FileCheckPatternContext {
447453
public:
448454
/// \returns the value of string variable \p VarName or an error if no such
449455
/// variable has been defined.
450-
Expected<StringRef> getPatternVarValue(StringRef VarName);
456+
LLVM_ABI Expected<StringRef> getPatternVarValue(StringRef VarName);
451457

452458
/// Defines string and numeric variables from definitions given on the
453459
/// command line, passed as a vector of [#]VAR=VAL strings in
454460
/// \p CmdlineDefines. \returns an error list containing diagnostics against
455461
/// \p SM for all definition parsing failures, if any, or Success otherwise.
456-
Error defineCmdlineVariables(ArrayRef<StringRef> CmdlineDefines,
457-
SourceMgr &SM);
462+
LLVM_ABI Error defineCmdlineVariables(ArrayRef<StringRef> CmdlineDefines,
463+
SourceMgr &SM);
458464

459465
/// Create @LINE pseudo variable. Value is set when pattern are being
460466
/// matched.
461-
void createLineVariable();
467+
LLVM_ABI void createLineVariable();
462468

463469
/// Undefines local variables (variables whose name does not start with a '$'
464470
/// sign), i.e. removes them from GlobalVariableTable and from
465471
/// GlobalNumericVariableTable and also clears the value of numeric
466472
/// variables.
467-
void clearLocalVars();
473+
LLVM_ABI void clearLocalVars();
468474

469475
private:
470476
/// Makes a new numeric variable and registers it for destruction when the
@@ -490,7 +496,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
490496
SMRange Range;
491497

492498
public:
493-
static char ID;
499+
LLVM_ABI static char ID;
494500

495501
ErrorDiagnostic(SMDiagnostic &&Diag, SMRange Range)
496502
: Diagnostic(Diag), Range(Range) {}
@@ -520,7 +526,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
520526

521527
class NotFoundError : public ErrorInfo<NotFoundError> {
522528
public:
523-
static char ID;
529+
LLVM_ABI static char ID;
524530

525531
std::error_code convertToErrorCode() const override {
526532
return inconvertibleErrorCode();
@@ -644,7 +650,7 @@ class Pattern {
644650
FileCheckPatternContext *getContext() const { return Context; }
645651

646652
/// \returns whether \p C is a valid first character for a variable name.
647-
static bool isValidVarNameStart(char C);
653+
LLVM_ABI static bool isValidVarNameStart(char C);
648654

649655
/// Parsing information about a variable.
650656
struct VariableProperties {
@@ -657,8 +663,8 @@ class Pattern {
657663
/// is the name of a pseudo variable, or an error holding a diagnostic
658664
/// against \p SM if parsing fail. If parsing was successful, also strips
659665
/// \p Str from the variable name.
660-
static Expected<VariableProperties> parseVariable(StringRef &Str,
661-
const SourceMgr &SM);
666+
LLVM_ABI static Expected<VariableProperties>
667+
parseVariable(StringRef &Str, const SourceMgr &SM);
662668
/// Parses \p Expr for a numeric substitution block at line \p LineNumber,
663669
/// or before input is parsed if \p LineNumber is None. Parameter
664670
/// \p IsLegacyLineExpr indicates whether \p Expr should be a legacy @LINE
@@ -669,7 +675,8 @@ class Pattern {
669675
/// successful, sets \p DefinedNumericVariable to point to the class
670676
/// representing the numeric variable defined in this numeric substitution
671677
/// block, or std::nullopt if this block does not define any variable.
672-
static Expected<std::unique_ptr<Expression>> parseNumericSubstitutionBlock(
678+
LLVM_ABI static Expected<std::unique_ptr<Expression>>
679+
parseNumericSubstitutionBlock(
673680
StringRef Expr, std::optional<NumericVariable *> &DefinedNumericVariable,
674681
bool IsLegacyLineExpr, std::optional<size_t> LineNumber,
675682
FileCheckPatternContext *Context, const SourceMgr &SM);
@@ -680,8 +687,8 @@ class Pattern {
680687
/// global options that influence the parsing such as whitespace
681688
/// canonicalization, \p SM provides the SourceMgr used for error reports.
682689
/// \returns true in case of an error, false otherwise.
683-
bool parsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM,
684-
const FileCheckRequest &Req);
690+
LLVM_ABI bool parsePattern(StringRef PatternStr, StringRef Prefix,
691+
SourceMgr &SM, const FileCheckRequest &Req);
685692
struct Match {
686693
size_t Pos;
687694
size_t Len;
@@ -705,7 +712,7 @@ class Pattern {
705712
/// GlobalNumericVariableTable StringMap in the same class provides the
706713
/// current values of FileCheck numeric variables and is updated if this
707714
/// match defines new numeric values.
708-
MatchResult match(StringRef Buffer, const SourceMgr &SM) const;
715+
LLVM_ABI MatchResult match(StringRef Buffer, const SourceMgr &SM) const;
709716
/// Prints the value of successful substitutions.
710717
void printSubstitutions(const SourceMgr &SM, StringRef Buffer,
711718
SMRange MatchRange, FileCheckDiag::MatchType MatchTy,
@@ -716,8 +723,9 @@ class Pattern {
716723
bool hasVariable() const {
717724
return !(Substitutions.empty() && VariableDefs.empty());
718725
}
719-
void printVariableDefs(const SourceMgr &SM, FileCheckDiag::MatchType MatchTy,
720-
std::vector<FileCheckDiag> *Diags) const;
726+
LLVM_ABI void printVariableDefs(const SourceMgr &SM,
727+
FileCheckDiag::MatchType MatchTy,
728+
std::vector<FileCheckDiag> *Diags) const;
721729

722730
Check::FileCheckType getCheckTy() const { return CheckTy; }
723731

0 commit comments

Comments
 (0)