@@ -94,11 +94,6 @@ class FileCheckNumericVariable {
94
94
// / Name of the numeric variable.
95
95
StringRef Name;
96
96
97
- // / Pointer to expression defining this numeric variable. Null for pseudo
98
- // / variable whose value is known at parse time (e.g. @LINE pseudo variable)
99
- // / or cleared local variable.
100
- FileCheckExpressionAST *ExpressionAST;
101
-
102
97
// / Value of numeric variable, if defined, or None otherwise.
103
98
Optional<uint64_t > Value;
104
99
@@ -109,40 +104,23 @@ class FileCheckNumericVariable {
109
104
110
105
public:
111
106
// / Constructor for a variable \p Name defined at line \p DefLineNumber or
112
- // / defined before input is parsed if \p DefLineNumber is None. If not null,
113
- // / the value set with setValue must match the result of evaluating
114
- // / \p ExpressionAST.
107
+ // / defined before input is parsed if DefLineNumber is None.
115
108
FileCheckNumericVariable (StringRef Name,
116
- Optional<size_t > DefLineNumber = None,
117
- FileCheckExpressionAST *ExpressionAST = nullptr )
118
- : Name(Name), ExpressionAST(ExpressionAST), DefLineNumber(DefLineNumber) {
119
- }
109
+ Optional<size_t > DefLineNumber = None)
110
+ : Name(Name), DefLineNumber(DefLineNumber) {}
120
111
121
112
// / \returns name of this numeric variable.
122
113
StringRef getName () const { return Name; }
123
114
124
115
// / \returns this variable's value.
125
116
Optional<uint64_t > getValue () const { return Value; }
126
117
127
- // / \returns the pointer to the expression defining this numeric variable, if
128
- // / any, or null otherwise.
129
- FileCheckExpressionAST *getExpressionAST () const { return ExpressionAST; }
130
-
131
- // / \returns whether this variable's value is known when performing the
132
- // / substitutions of the line where it is defined.
133
- bool isValueKnownAtMatchTime () const ;
134
-
135
- // / Sets value of this numeric variable to \p NewValue. Triggers an assertion
136
- // / failure if the variable is defined by an expression and the expression
137
- // / cannot be evaluated to be equal to \p NewValue.
138
- void setValue (uint64_t NewValue);
118
+ // / Sets value of this numeric variable to \p NewValue.
119
+ void setValue (uint64_t NewValue) { Value = NewValue; }
139
120
140
121
// / Clears value of this numeric variable, regardless of whether it is
141
122
// / currently defined or not.
142
- void clearValue () {
143
- Value = None;
144
- ExpressionAST = nullptr ;
145
- }
123
+ void clearValue () { Value = None; }
146
124
147
125
// / \returns the line number where this variable is defined, if any, or None
148
126
// / if defined before input is parsed.
@@ -529,22 +507,27 @@ class FileCheckPattern {
529
507
// / \p Str from the variable name.
530
508
static Expected<VariableProperties> parseVariable (StringRef &Str,
531
509
const SourceMgr &SM);
532
- // / Parses \p Expr for a numeric substitution block at line \p LineNumber,
533
- // / or before input is parsed if \p LineNumber is None. Parameter
510
+ // / Parses \p Expr for the name of a numeric variable to be defined at line
511
+ // / \p LineNumber or before input is parsed if \p LineNumber is None.
512
+ // / \returns a pointer to the class instance representing that variable,
513
+ // / creating it if needed, or an error holding a diagnostic against \p SM
514
+ // / should defining such a variable be invalid.
515
+ static Expected<FileCheckNumericVariable *> parseNumericVariableDefinition (
516
+ StringRef &Expr, FileCheckPatternContext *Context,
517
+ Optional<size_t > LineNumber, const SourceMgr &SM);
518
+ // / Parses \p Expr for a numeric substitution block. Parameter
534
519
// / \p IsLegacyLineExpr indicates whether \p Expr should be a legacy @LINE
535
- // / expression and \p Context points to the class instance holding the live
536
- // / string and numeric variables. \returns a pointer to the class instance
537
- // / representing the AST of the expression whose value must be substitued, or
538
- // / an error holding a diagnostic against \p SM if parsing fails. If
539
- // / substitution was successful, sets \p DefinedNumericVariable to point to
540
- // / the class representing the numeric variable defined in this numeric
520
+ // / expression. \returns a pointer to the class instance representing the AST
521
+ // / of the expression whose value must be substituted, or an error holding a
522
+ // / diagnostic against \p SM if parsing fails. If substitution was
523
+ // / successful, sets \p DefinedNumericVariable to point to the class
524
+ // / representing the numeric variable being defined in this numeric
541
525
// / substitution block, or None if this block does not define any variable.
542
- static Expected<std::unique_ptr<FileCheckExpressionAST>>
526
+ Expected<std::unique_ptr<FileCheckExpressionAST>>
543
527
parseNumericSubstitutionBlock (
544
528
StringRef Expr,
545
529
Optional<FileCheckNumericVariable *> &DefinedNumericVariable,
546
- bool IsLegacyLineExpr, Optional<size_t > LineNumber,
547
- FileCheckPatternContext *Context, const SourceMgr &SM);
530
+ bool IsLegacyLineExpr, const SourceMgr &SM) const ;
548
531
// / Parses the pattern in \p PatternStr and initializes this FileCheckPattern
549
532
// / instance accordingly.
550
533
// /
@@ -598,49 +581,28 @@ class FileCheckPattern {
598
581
// / was not found.
599
582
size_t FindRegexVarEnd (StringRef Str, SourceMgr &SM);
600
583
601
- // / Parses \p Expr for the name of a numeric variable to be defined at line
602
- // / \p LineNumber, or before input is parsed if \p LineNumber is None.
603
- // / \returns a pointer to the class instance representing that variable,
604
- // / creating it if needed, or an error holding a diagnostic against \p SM
605
- // / should defining such a variable be invalid.
606
- static Expected<FileCheckNumericVariable *> parseNumericVariableDefinition (
607
- StringRef &Expr, FileCheckPatternContext *Context,
608
- Optional<size_t > LineNumber, FileCheckExpressionAST *ExpressionAST,
609
- const SourceMgr &SM);
610
- // / Parses \p Name as a (pseudo if \p IsPseudo is true) numeric variable use
611
- // / at line \p LineNumber, or before input is parsed if \p LineNumber is
612
- // / None. Parameter \p Context points to the class instance holding the live
613
- // / string and numeric variables. \returns the pointer to the class instance
614
- // / representing that variable if successful, or an error holding a
615
- // / diagnostic against \p SM otherwise.
616
- static Expected<std::unique_ptr<FileCheckNumericVariableUse>>
584
+ // / Parses \p Name as a (pseudo if \p IsPseudo is true) numeric variable use.
585
+ // / \returns the pointer to the class instance representing that variable if
586
+ // / successful, or an error holding a diagnostic against \p SM otherwise.
587
+ Expected<std::unique_ptr<FileCheckNumericVariableUse>>
617
588
parseNumericVariableUse (StringRef Name, bool IsPseudo,
618
- Optional<size_t > LineNumber,
619
- FileCheckPatternContext *Context,
620
- const SourceMgr &SM);
589
+ const SourceMgr &SM) const ;
621
590
enum class AllowedOperand { LineVar, Literal, Any };
622
- // / Parses \p Expr for use of a numeric operand at line \p LineNumber, or
623
- // / before input is parsed if \p LineNumber is None. Accepts both literal
624
- // / values and numeric variables, depending on the value of \p AO. Parameter
625
- // / \p Context points to the class instance holding the live string and
626
- // / numeric variables. \returns the class representing that operand in the
627
- // / AST of the expression or an error holding a diagnostic against \p SM
628
- // / otherwise.
629
- static Expected<std::unique_ptr<FileCheckExpressionAST>>
591
+ // / Parses \p Expr for use of a numeric operand. Accepts both literal values
592
+ // / and numeric variables, depending on the value of \p AO. \returns the
593
+ // / class representing that operand in the AST of the expression or an error
594
+ // / holding a diagnostic against \p SM otherwise.
595
+ Expected<std::unique_ptr<FileCheckExpressionAST>>
630
596
parseNumericOperand (StringRef &Expr, AllowedOperand AO,
631
- Optional<size_t > LineNumber,
632
- FileCheckPatternContext *Context, const SourceMgr &SM);
633
- // / Parses \p Expr for a binary operation at line \p LineNumber, or before
634
- // / input is parsed if \p LineNumber is None. The left operand of this binary
597
+ const SourceMgr &SM) const ;
598
+ // / Parses \p Expr for a binary operation. The left operand of this binary
635
599
// / operation is given in \p LeftOp and \p IsLegacyLineExpr indicates whether
636
- // / we are parsing a legacy @LINE expression. Parameter \p Context points to
637
- // / the class instance holding the live string and numeric variables.
638
- // / \returns the class representing the binary operation in the AST of the
639
- // / expression, or an error holding a diagnostic against \p SM otherwise.
640
- static Expected<std::unique_ptr<FileCheckExpressionAST>>
600
+ // / we are parsing a legacy @LINE expression. \returns the class representing
601
+ // / the binary operation in the AST of the expression, or an error holding a
602
+ // / diagnostic against \p SM otherwise.
603
+ Expected<std::unique_ptr<FileCheckExpressionAST>>
641
604
parseBinop (StringRef &Expr, std::unique_ptr<FileCheckExpressionAST> LeftOp,
642
- bool IsLegacyLineExpr, Optional<size_t > LineNumber,
643
- FileCheckPatternContext *Context, const SourceMgr &SM);
605
+ bool IsLegacyLineExpr, const SourceMgr &SM) const ;
644
606
};
645
607
646
608
// ===----------------------------------------------------------------------===//
0 commit comments