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,24 @@ 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,
102
+ const SourceMgr &SM) const ;
101
103
};
102
104
103
105
// / Class to represent an overflow error that might result when manipulating a
104
106
// / value.
105
107
class OverflowError : public ErrorInfo <OverflowError> {
106
108
public:
107
- static char ID;
109
+ LLVM_ABI static char ID;
108
110
109
111
std::error_code convertToErrorCode () const override {
110
112
return std::make_error_code (std::errc::value_too_large);
@@ -115,10 +117,14 @@ class OverflowError : public ErrorInfo<OverflowError> {
115
117
116
118
// / Performs operation and \returns its result or an error in case of failure,
117
119
// / 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);
122
128
Expected<APInt> exprMax (const APInt &Lhs, const APInt &Rhs, bool &Overflow);
123
129
Expected<APInt> exprMin (const APInt &Lhs, const APInt &Rhs, bool &Overflow);
124
130
@@ -169,7 +175,7 @@ class UndefVarError : public ErrorInfo<UndefVarError> {
169
175
StringRef VarName;
170
176
171
177
public:
172
- static char ID;
178
+ LLVM_ABI static char ID;
173
179
174
180
UndefVarError (StringRef VarName) : VarName(VarName) {}
175
181
@@ -277,7 +283,7 @@ class NumericVariable {
277
283
278
284
// / Class representing the use of a numeric variable in the AST of an
279
285
// / expression.
280
- class NumericVariableUse : public ExpressionAST {
286
+ class LLVM_ABI NumericVariableUse : public ExpressionAST {
281
287
private:
282
288
// / Pointer to the class instance for the variable this use is about.
283
289
NumericVariable *Variable;
@@ -299,7 +305,7 @@ class NumericVariableUse : public ExpressionAST {
299
305
using binop_eval_t = Expected<APInt> (*)(const APInt &, const APInt &, bool &);
300
306
301
307
// / Class representing a single binary operation in the AST of an expression.
302
- class BinaryOperation : public ExpressionAST {
308
+ class LLVM_ABI BinaryOperation : public ExpressionAST {
303
309
private:
304
310
// / Left operand.
305
311
std::unique_ptr<ExpressionAST> LeftOperand;
@@ -371,7 +377,7 @@ class Substitution {
371
377
virtual Expected<std::string> getResult () const = 0;
372
378
};
373
379
374
- class StringSubstitution : public Substitution {
380
+ class LLVM_ABI StringSubstitution : public Substitution {
375
381
public:
376
382
StringSubstitution (FileCheckPatternContext *Context, StringRef VarName,
377
383
size_t InsertIdx)
@@ -382,7 +388,7 @@ class StringSubstitution : public Substitution {
382
388
Expected<std::string> getResult () const override ;
383
389
};
384
390
385
- class NumericSubstitution : public Substitution {
391
+ class LLVM_ABI NumericSubstitution : public Substitution {
386
392
private:
387
393
// / Pointer to the class representing the expression whose value is to be
388
394
// / substituted.
@@ -447,24 +453,24 @@ class FileCheckPatternContext {
447
453
public:
448
454
// / \returns the value of string variable \p VarName or an error if no such
449
455
// / variable has been defined.
450
- Expected<StringRef> getPatternVarValue (StringRef VarName);
456
+ LLVM_ABI Expected<StringRef> getPatternVarValue (StringRef VarName);
451
457
452
458
// / Defines string and numeric variables from definitions given on the
453
459
// / command line, passed as a vector of [#]VAR=VAL strings in
454
460
// / \p CmdlineDefines. \returns an error list containing diagnostics against
455
461
// / \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);
458
464
459
465
// / Create @LINE pseudo variable. Value is set when pattern are being
460
466
// / matched.
461
- void createLineVariable ();
467
+ LLVM_ABI void createLineVariable ();
462
468
463
469
// / Undefines local variables (variables whose name does not start with a '$'
464
470
// / sign), i.e. removes them from GlobalVariableTable and from
465
471
// / GlobalNumericVariableTable and also clears the value of numeric
466
472
// / variables.
467
- void clearLocalVars ();
473
+ LLVM_ABI void clearLocalVars ();
468
474
469
475
private:
470
476
// / Makes a new numeric variable and registers it for destruction when the
@@ -490,7 +496,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
490
496
SMRange Range;
491
497
492
498
public:
493
- static char ID;
499
+ LLVM_ABI static char ID;
494
500
495
501
ErrorDiagnostic (SMDiagnostic &&Diag, SMRange Range)
496
502
: Diagnostic(Diag), Range(Range) {}
@@ -520,7 +526,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
520
526
521
527
class NotFoundError : public ErrorInfo <NotFoundError> {
522
528
public:
523
- static char ID;
529
+ LLVM_ABI static char ID;
524
530
525
531
std::error_code convertToErrorCode () const override {
526
532
return inconvertibleErrorCode ();
@@ -644,7 +650,7 @@ class Pattern {
644
650
FileCheckPatternContext *getContext () const { return Context; }
645
651
646
652
// / \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);
648
654
649
655
// / Parsing information about a variable.
650
656
struct VariableProperties {
@@ -657,8 +663,8 @@ class Pattern {
657
663
// / is the name of a pseudo variable, or an error holding a diagnostic
658
664
// / against \p SM if parsing fail. If parsing was successful, also strips
659
665
// / \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);
662
668
// / Parses \p Expr for a numeric substitution block at line \p LineNumber,
663
669
// / or before input is parsed if \p LineNumber is None. Parameter
664
670
// / \p IsLegacyLineExpr indicates whether \p Expr should be a legacy @LINE
@@ -669,7 +675,8 @@ class Pattern {
669
675
// / successful, sets \p DefinedNumericVariable to point to the class
670
676
// / representing the numeric variable defined in this numeric substitution
671
677
// / 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 (
673
680
StringRef Expr, std::optional<NumericVariable *> &DefinedNumericVariable,
674
681
bool IsLegacyLineExpr, std::optional<size_t > LineNumber,
675
682
FileCheckPatternContext *Context, const SourceMgr &SM);
@@ -680,8 +687,8 @@ class Pattern {
680
687
// / global options that influence the parsing such as whitespace
681
688
// / canonicalization, \p SM provides the SourceMgr used for error reports.
682
689
// / \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);
685
692
struct Match {
686
693
size_t Pos;
687
694
size_t Len;
@@ -705,7 +712,7 @@ class Pattern {
705
712
// / GlobalNumericVariableTable StringMap in the same class provides the
706
713
// / current values of FileCheck numeric variables and is updated if this
707
714
// / 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 ;
709
716
// / Prints the value of successful substitutions.
710
717
void printSubstitutions (const SourceMgr &SM, StringRef Buffer,
711
718
SMRange MatchRange, FileCheckDiag::MatchType MatchTy,
@@ -716,8 +723,9 @@ class Pattern {
716
723
bool hasVariable () const {
717
724
return !(Substitutions.empty () && VariableDefs.empty ());
718
725
}
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 ;
721
729
722
730
Check::FileCheckType getCheckTy () const { return CheckTy; }
723
731
0 commit comments