19
19
#include " llvm/ADT/StringMap.h"
20
20
#include " llvm/ADT/StringRef.h"
21
21
#include " llvm/FileCheck/FileCheck.h"
22
+ #include " llvm/Support/Compiler.h"
22
23
#include " llvm/Support/Error.h"
23
24
#include " llvm/Support/SourceMgr.h"
24
25
#include < map>
@@ -88,23 +89,23 @@ struct ExpressionFormat {
88
89
// / \returns a wildcard regular expression string that matches any value in
89
90
// / the format represented by this instance and no other value, or an error
90
91
// / if the format is NoFormat.
91
- Expected<std::string> getWildcardRegex () const ;
92
+ LLVM_ABI Expected<std::string> getWildcardRegex () const ;
92
93
93
94
// / \returns the string representation of \p Value in the format represented
94
95
// / by this instance, or an error if conversion to this format failed or the
95
96
// / format is NoFormat.
96
- Expected<std::string> getMatchingString (APInt Value) const ;
97
+ LLVM_ABI Expected<std::string> getMatchingString (APInt Value) const ;
97
98
98
99
// / \returns the value corresponding to string representation \p StrVal
99
100
// / 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, const SourceMgr &SM) const ;
101
102
};
102
103
103
104
// / Class to represent an overflow error that might result when manipulating a
104
105
// / value.
105
106
class OverflowError : public ErrorInfo <OverflowError> {
106
107
public:
107
- static char ID;
108
+ LLVM_ABI static char ID;
108
109
109
110
std::error_code convertToErrorCode () const override {
110
111
return std::make_error_code (std::errc::value_too_large);
@@ -115,10 +116,10 @@ class OverflowError : public ErrorInfo<OverflowError> {
115
116
116
117
// / Performs operation and \returns its result or an error in case of failure,
117
118
// / 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);
119
+ LLVM_ABI Expected<APInt> exprAdd (const APInt &Lhs, const APInt &Rhs, bool &Overflow);
120
+ LLVM_ABI Expected<APInt> exprSub (const APInt &Lhs, const APInt &Rhs, bool &Overflow);
121
+ LLVM_ABI Expected<APInt> exprMul (const APInt &Lhs, const APInt &Rhs, bool &Overflow);
122
+ LLVM_ABI Expected<APInt> exprDiv (const APInt &Lhs, const APInt &Rhs, bool &Overflow);
122
123
Expected<APInt> exprMax (const APInt &Lhs, const APInt &Rhs, bool &Overflow);
123
124
Expected<APInt> exprMin (const APInt &Lhs, const APInt &Rhs, bool &Overflow);
124
125
@@ -169,7 +170,7 @@ class UndefVarError : public ErrorInfo<UndefVarError> {
169
170
StringRef VarName;
170
171
171
172
public:
172
- static char ID;
173
+ LLVM_ABI static char ID;
173
174
174
175
UndefVarError (StringRef VarName) : VarName(VarName) {}
175
176
@@ -277,7 +278,7 @@ class NumericVariable {
277
278
278
279
// / Class representing the use of a numeric variable in the AST of an
279
280
// / expression.
280
- class NumericVariableUse : public ExpressionAST {
281
+ class LLVM_ABI NumericVariableUse : public ExpressionAST {
281
282
private:
282
283
// / Pointer to the class instance for the variable this use is about.
283
284
NumericVariable *Variable;
@@ -299,7 +300,7 @@ class NumericVariableUse : public ExpressionAST {
299
300
using binop_eval_t = Expected<APInt> (*)(const APInt &, const APInt &, bool &);
300
301
301
302
// / Class representing a single binary operation in the AST of an expression.
302
- class BinaryOperation : public ExpressionAST {
303
+ class LLVM_ABI BinaryOperation : public ExpressionAST {
303
304
private:
304
305
// / Left operand.
305
306
std::unique_ptr<ExpressionAST> LeftOperand;
@@ -371,7 +372,7 @@ class Substitution {
371
372
virtual Expected<std::string> getResult () const = 0;
372
373
};
373
374
374
- class StringSubstitution : public Substitution {
375
+ class LLVM_ABI StringSubstitution : public Substitution {
375
376
public:
376
377
StringSubstitution (FileCheckPatternContext *Context, StringRef VarName,
377
378
size_t InsertIdx)
@@ -382,7 +383,7 @@ class StringSubstitution : public Substitution {
382
383
Expected<std::string> getResult () const override ;
383
384
};
384
385
385
- class NumericSubstitution : public Substitution {
386
+ class LLVM_ABI NumericSubstitution : public Substitution {
386
387
private:
387
388
// / Pointer to the class representing the expression whose value is to be
388
389
// / substituted.
@@ -447,24 +448,24 @@ class FileCheckPatternContext {
447
448
public:
448
449
// / \returns the value of string variable \p VarName or an error if no such
449
450
// / variable has been defined.
450
- Expected<StringRef> getPatternVarValue (StringRef VarName);
451
+ LLVM_ABI Expected<StringRef> getPatternVarValue (StringRef VarName);
451
452
452
453
// / Defines string and numeric variables from definitions given on the
453
454
// / command line, passed as a vector of [#]VAR=VAL strings in
454
455
// / \p CmdlineDefines. \returns an error list containing diagnostics against
455
456
// / \p SM for all definition parsing failures, if any, or Success otherwise.
456
- Error defineCmdlineVariables (ArrayRef<StringRef> CmdlineDefines,
457
+ LLVM_ABI Error defineCmdlineVariables (ArrayRef<StringRef> CmdlineDefines,
457
458
SourceMgr &SM);
458
459
459
460
// / Create @LINE pseudo variable. Value is set when pattern are being
460
461
// / matched.
461
- void createLineVariable ();
462
+ LLVM_ABI void createLineVariable ();
462
463
463
464
// / Undefines local variables (variables whose name does not start with a '$'
464
465
// / sign), i.e. removes them from GlobalVariableTable and from
465
466
// / GlobalNumericVariableTable and also clears the value of numeric
466
467
// / variables.
467
- void clearLocalVars ();
468
+ LLVM_ABI void clearLocalVars ();
468
469
469
470
private:
470
471
// / Makes a new numeric variable and registers it for destruction when the
@@ -490,7 +491,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
490
491
SMRange Range;
491
492
492
493
public:
493
- static char ID;
494
+ LLVM_ABI static char ID;
494
495
495
496
ErrorDiagnostic (SMDiagnostic &&Diag, SMRange Range)
496
497
: Diagnostic(Diag), Range(Range) {}
@@ -520,7 +521,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
520
521
521
522
class NotFoundError : public ErrorInfo <NotFoundError> {
522
523
public:
523
- static char ID;
524
+ LLVM_ABI static char ID;
524
525
525
526
std::error_code convertToErrorCode () const override {
526
527
return inconvertibleErrorCode ();
@@ -644,7 +645,7 @@ class Pattern {
644
645
FileCheckPatternContext *getContext () const { return Context; }
645
646
646
647
// / \returns whether \p C is a valid first character for a variable name.
647
- static bool isValidVarNameStart (char C);
648
+ LLVM_ABI static bool isValidVarNameStart (char C);
648
649
649
650
// / Parsing information about a variable.
650
651
struct VariableProperties {
@@ -657,7 +658,7 @@ class Pattern {
657
658
// / is the name of a pseudo variable, or an error holding a diagnostic
658
659
// / against \p SM if parsing fail. If parsing was successful, also strips
659
660
// / \p Str from the variable name.
660
- static Expected<VariableProperties> parseVariable (StringRef &Str,
661
+ LLVM_ABI static Expected<VariableProperties> parseVariable (StringRef &Str,
661
662
const SourceMgr &SM);
662
663
// / Parses \p Expr for a numeric substitution block at line \p LineNumber,
663
664
// / or before input is parsed if \p LineNumber is None. Parameter
@@ -669,7 +670,7 @@ class Pattern {
669
670
// / successful, sets \p DefinedNumericVariable to point to the class
670
671
// / representing the numeric variable defined in this numeric substitution
671
672
// / block, or std::nullopt if this block does not define any variable.
672
- static Expected<std::unique_ptr<Expression>> parseNumericSubstitutionBlock (
673
+ LLVM_ABI static Expected<std::unique_ptr<Expression>> parseNumericSubstitutionBlock (
673
674
StringRef Expr, std::optional<NumericVariable *> &DefinedNumericVariable,
674
675
bool IsLegacyLineExpr, std::optional<size_t > LineNumber,
675
676
FileCheckPatternContext *Context, const SourceMgr &SM);
@@ -680,7 +681,7 @@ class Pattern {
680
681
// / global options that influence the parsing such as whitespace
681
682
// / canonicalization, \p SM provides the SourceMgr used for error reports.
682
683
// / \returns true in case of an error, false otherwise.
683
- bool parsePattern (StringRef PatternStr, StringRef Prefix, SourceMgr &SM,
684
+ LLVM_ABI bool parsePattern (StringRef PatternStr, StringRef Prefix, SourceMgr &SM,
684
685
const FileCheckRequest &Req);
685
686
struct Match {
686
687
size_t Pos;
@@ -705,7 +706,7 @@ class Pattern {
705
706
// / GlobalNumericVariableTable StringMap in the same class provides the
706
707
// / current values of FileCheck numeric variables and is updated if this
707
708
// / match defines new numeric values.
708
- MatchResult match (StringRef Buffer, const SourceMgr &SM) const ;
709
+ LLVM_ABI MatchResult match (StringRef Buffer, const SourceMgr &SM) const ;
709
710
// / Prints the value of successful substitutions.
710
711
void printSubstitutions (const SourceMgr &SM, StringRef Buffer,
711
712
SMRange MatchRange, FileCheckDiag::MatchType MatchTy,
@@ -716,7 +717,7 @@ class Pattern {
716
717
bool hasVariable () const {
717
718
return !(Substitutions.empty () && VariableDefs.empty ());
718
719
}
719
- void printVariableDefs (const SourceMgr &SM, FileCheckDiag::MatchType MatchTy,
720
+ LLVM_ABI void printVariableDefs (const SourceMgr &SM, FileCheckDiag::MatchType MatchTy,
720
721
std::vector<FileCheckDiag> *Diags) const ;
721
722
722
723
Check::FileCheckType getCheckTy () const { return CheckTy; }
0 commit comments