Skip to content

Commit 5024cb2

Browse files
committed
[llvm] export private API so that FileCheckTests builds against Windows DLL
1 parent 41f22c5 commit 5024cb2

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;
@@ -377,7 +383,7 @@ class Substitution {
377383
virtual Expected<std::string> getResultForDiagnostics() const = 0;
378384
};
379385

380-
class StringSubstitution : public Substitution {
386+
class LLVM_ABI StringSubstitution : public Substitution {
381387
public:
382388
StringSubstitution(FileCheckPatternContext *Context, StringRef VarName,
383389
size_t InsertIdx)
@@ -393,7 +399,7 @@ class StringSubstitution : public Substitution {
393399
Expected<std::string> getResultForDiagnostics() const override;
394400
};
395401

396-
class NumericSubstitution : public Substitution {
402+
class LLVM_ABI NumericSubstitution : public Substitution {
397403
private:
398404
/// Pointer to the class representing the expression whose value is to be
399405
/// substituted.
@@ -463,24 +469,24 @@ class FileCheckPatternContext {
463469
public:
464470
/// \returns the value of string variable \p VarName or an error if no such
465471
/// variable has been defined.
466-
Expected<StringRef> getPatternVarValue(StringRef VarName);
472+
LLVM_ABI Expected<StringRef> getPatternVarValue(StringRef VarName);
467473

468474
/// Defines string and numeric variables from definitions given on the
469475
/// command line, passed as a vector of [#]VAR=VAL strings in
470476
/// \p CmdlineDefines. \returns an error list containing diagnostics against
471477
/// \p SM for all definition parsing failures, if any, or Success otherwise.
472-
Error defineCmdlineVariables(ArrayRef<StringRef> CmdlineDefines,
473-
SourceMgr &SM);
478+
LLVM_ABI Error defineCmdlineVariables(ArrayRef<StringRef> CmdlineDefines,
479+
SourceMgr &SM);
474480

475481
/// Create @LINE pseudo variable. Value is set when pattern are being
476482
/// matched.
477-
void createLineVariable();
483+
LLVM_ABI void createLineVariable();
478484

479485
/// Undefines local variables (variables whose name does not start with a '$'
480486
/// sign), i.e. removes them from GlobalVariableTable and from
481487
/// GlobalNumericVariableTable and also clears the value of numeric
482488
/// variables.
483-
void clearLocalVars();
489+
LLVM_ABI void clearLocalVars();
484490

485491
private:
486492
/// Makes a new numeric variable and registers it for destruction when the
@@ -506,7 +512,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
506512
SMRange Range;
507513

508514
public:
509-
static char ID;
515+
LLVM_ABI static char ID;
510516

511517
ErrorDiagnostic(SMDiagnostic &&Diag, SMRange Range)
512518
: Diagnostic(Diag), Range(Range) {}
@@ -536,7 +542,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
536542

537543
class NotFoundError : public ErrorInfo<NotFoundError> {
538544
public:
539-
static char ID;
545+
LLVM_ABI static char ID;
540546

541547
std::error_code convertToErrorCode() const override {
542548
return inconvertibleErrorCode();
@@ -660,7 +666,7 @@ class Pattern {
660666
FileCheckPatternContext *getContext() const { return Context; }
661667

662668
/// \returns whether \p C is a valid first character for a variable name.
663-
static bool isValidVarNameStart(char C);
669+
LLVM_ABI static bool isValidVarNameStart(char C);
664670

665671
/// Parsing information about a variable.
666672
struct VariableProperties {
@@ -673,8 +679,8 @@ class Pattern {
673679
/// is the name of a pseudo variable, or an error holding a diagnostic
674680
/// against \p SM if parsing fail. If parsing was successful, also strips
675681
/// \p Str from the variable name.
676-
static Expected<VariableProperties> parseVariable(StringRef &Str,
677-
const SourceMgr &SM);
682+
LLVM_ABI static Expected<VariableProperties>
683+
parseVariable(StringRef &Str, const SourceMgr &SM);
678684
/// Parses \p Expr for a numeric substitution block at line \p LineNumber,
679685
/// or before input is parsed if \p LineNumber is None. Parameter
680686
/// \p IsLegacyLineExpr indicates whether \p Expr should be a legacy @LINE
@@ -685,7 +691,8 @@ class Pattern {
685691
/// successful, sets \p DefinedNumericVariable to point to the class
686692
/// representing the numeric variable defined in this numeric substitution
687693
/// block, or std::nullopt if this block does not define any variable.
688-
static Expected<std::unique_ptr<Expression>> parseNumericSubstitutionBlock(
694+
LLVM_ABI static Expected<std::unique_ptr<Expression>>
695+
parseNumericSubstitutionBlock(
689696
StringRef Expr, std::optional<NumericVariable *> &DefinedNumericVariable,
690697
bool IsLegacyLineExpr, std::optional<size_t> LineNumber,
691698
FileCheckPatternContext *Context, const SourceMgr &SM);
@@ -696,8 +703,8 @@ class Pattern {
696703
/// global options that influence the parsing such as whitespace
697704
/// canonicalization, \p SM provides the SourceMgr used for error reports.
698705
/// \returns true in case of an error, false otherwise.
699-
bool parsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM,
700-
const FileCheckRequest &Req);
706+
LLVM_ABI bool parsePattern(StringRef PatternStr, StringRef Prefix,
707+
SourceMgr &SM, const FileCheckRequest &Req);
701708
struct Match {
702709
size_t Pos;
703710
size_t Len;
@@ -721,7 +728,7 @@ class Pattern {
721728
/// GlobalNumericVariableTable StringMap in the same class provides the
722729
/// current values of FileCheck numeric variables and is updated if this
723730
/// match defines new numeric values.
724-
MatchResult match(StringRef Buffer, const SourceMgr &SM) const;
731+
LLVM_ABI MatchResult match(StringRef Buffer, const SourceMgr &SM) const;
725732
/// Prints the value of successful substitutions.
726733
void printSubstitutions(const SourceMgr &SM, StringRef Buffer,
727734
SMRange MatchRange, FileCheckDiag::MatchType MatchTy,
@@ -732,8 +739,9 @@ class Pattern {
732739
bool hasVariable() const {
733740
return !(Substitutions.empty() && VariableDefs.empty());
734741
}
735-
void printVariableDefs(const SourceMgr &SM, FileCheckDiag::MatchType MatchTy,
736-
std::vector<FileCheckDiag> *Diags) const;
742+
LLVM_ABI void printVariableDefs(const SourceMgr &SM,
743+
FileCheckDiag::MatchType MatchTy,
744+
std::vector<FileCheckDiag> *Diags) const;
737745

738746
Check::FileCheckType getCheckTy() const { return CheckTy; }
739747

0 commit comments

Comments
 (0)