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;
@@ -377,7 +383,7 @@ class Substitution {
377
383
virtual Expected<std::string> getResultForDiagnostics () const = 0;
378
384
};
379
385
380
- class StringSubstitution : public Substitution {
386
+ class LLVM_ABI StringSubstitution : public Substitution {
381
387
public:
382
388
StringSubstitution (FileCheckPatternContext *Context, StringRef VarName,
383
389
size_t InsertIdx)
@@ -393,7 +399,7 @@ class StringSubstitution : public Substitution {
393
399
Expected<std::string> getResultForDiagnostics () const override ;
394
400
};
395
401
396
- class NumericSubstitution : public Substitution {
402
+ class LLVM_ABI NumericSubstitution : public Substitution {
397
403
private:
398
404
// / Pointer to the class representing the expression whose value is to be
399
405
// / substituted.
@@ -463,24 +469,24 @@ class FileCheckPatternContext {
463
469
public:
464
470
// / \returns the value of string variable \p VarName or an error if no such
465
471
// / variable has been defined.
466
- Expected<StringRef> getPatternVarValue (StringRef VarName);
472
+ LLVM_ABI Expected<StringRef> getPatternVarValue (StringRef VarName);
467
473
468
474
// / Defines string and numeric variables from definitions given on the
469
475
// / command line, passed as a vector of [#]VAR=VAL strings in
470
476
// / \p CmdlineDefines. \returns an error list containing diagnostics against
471
477
// / \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);
474
480
475
481
// / Create @LINE pseudo variable. Value is set when pattern are being
476
482
// / matched.
477
- void createLineVariable ();
483
+ LLVM_ABI void createLineVariable ();
478
484
479
485
// / Undefines local variables (variables whose name does not start with a '$'
480
486
// / sign), i.e. removes them from GlobalVariableTable and from
481
487
// / GlobalNumericVariableTable and also clears the value of numeric
482
488
// / variables.
483
- void clearLocalVars ();
489
+ LLVM_ABI void clearLocalVars ();
484
490
485
491
private:
486
492
// / Makes a new numeric variable and registers it for destruction when the
@@ -506,7 +512,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
506
512
SMRange Range;
507
513
508
514
public:
509
- static char ID;
515
+ LLVM_ABI static char ID;
510
516
511
517
ErrorDiagnostic (SMDiagnostic &&Diag, SMRange Range)
512
518
: Diagnostic(Diag), Range(Range) {}
@@ -536,7 +542,7 @@ class ErrorDiagnostic : public ErrorInfo<ErrorDiagnostic> {
536
542
537
543
class NotFoundError : public ErrorInfo <NotFoundError> {
538
544
public:
539
- static char ID;
545
+ LLVM_ABI static char ID;
540
546
541
547
std::error_code convertToErrorCode () const override {
542
548
return inconvertibleErrorCode ();
@@ -660,7 +666,7 @@ class Pattern {
660
666
FileCheckPatternContext *getContext () const { return Context; }
661
667
662
668
// / \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);
664
670
665
671
// / Parsing information about a variable.
666
672
struct VariableProperties {
@@ -673,8 +679,8 @@ class Pattern {
673
679
// / is the name of a pseudo variable, or an error holding a diagnostic
674
680
// / against \p SM if parsing fail. If parsing was successful, also strips
675
681
// / \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);
678
684
// / Parses \p Expr for a numeric substitution block at line \p LineNumber,
679
685
// / or before input is parsed if \p LineNumber is None. Parameter
680
686
// / \p IsLegacyLineExpr indicates whether \p Expr should be a legacy @LINE
@@ -685,7 +691,8 @@ class Pattern {
685
691
// / successful, sets \p DefinedNumericVariable to point to the class
686
692
// / representing the numeric variable defined in this numeric substitution
687
693
// / 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 (
689
696
StringRef Expr, std::optional<NumericVariable *> &DefinedNumericVariable,
690
697
bool IsLegacyLineExpr, std::optional<size_t > LineNumber,
691
698
FileCheckPatternContext *Context, const SourceMgr &SM);
@@ -696,8 +703,8 @@ class Pattern {
696
703
// / global options that influence the parsing such as whitespace
697
704
// / canonicalization, \p SM provides the SourceMgr used for error reports.
698
705
// / \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);
701
708
struct Match {
702
709
size_t Pos;
703
710
size_t Len;
@@ -721,7 +728,7 @@ class Pattern {
721
728
// / GlobalNumericVariableTable StringMap in the same class provides the
722
729
// / current values of FileCheck numeric variables and is updated if this
723
730
// / 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 ;
725
732
// / Prints the value of successful substitutions.
726
733
void printSubstitutions (const SourceMgr &SM, StringRef Buffer,
727
734
SMRange MatchRange, FileCheckDiag::MatchType MatchTy,
@@ -732,8 +739,9 @@ class Pattern {
732
739
bool hasVariable () const {
733
740
return !(Substitutions.empty () && VariableDefs.empty ());
734
741
}
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 ;
737
745
738
746
Check::FileCheckType getCheckTy () const { return CheckTy; }
739
747
0 commit comments