Index: llvm/trunk/docs/CommandGuide/FileCheck.rst =================================================================== --- llvm/trunk/docs/CommandGuide/FileCheck.rst +++ llvm/trunk/docs/CommandGuide/FileCheck.rst @@ -592,12 +592,12 @@ * ```` is the name of a defined numeric variable. -* ```` is an optional numeric operation to perform on the value of - ````. Currently supported numeric operations are ``+`` and ``-``. +* ```` is an optional operation to perform on the value of ````. + Currently supported operations are ``+`` and ``-``. * ```` is the immediate value that constitutes the second operand of - the numeric operation . It must be present if ```` is present, - absent otherwise. + the operation ````. It must be present if ```` is present, absent + otherwise. Spaces are accepted before, after and between any of these elements. @@ -627,8 +627,8 @@ The ``--enable-var-scope`` option has the same effect on numeric variables as on string variables. -Important note: In its current implementation, a numeric expression cannot use -a numeric variable defined on the same line. +Important note: In its current implementation, an expression cannot use a +numeric variable defined on the same line. FileCheck Pseudo Numeric Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -639,9 +639,9 @@ line numbers in the same file, which have to be updated whenever line numbers change due to text addition or deletion. -To support this case, FileCheck numeric expressions understand the ``@LINE`` -pseudo numeric variable which evaluates to the line number of the CHECK pattern -where it is found. +To support this case, FileCheck expressions understand the ``@LINE`` pseudo +numeric variable which evaluates to the line number of the CHECK pattern where +it is found. This way match patterns can be put near the relevant test lines and include relative line number references, for example: Index: llvm/trunk/include/llvm/Support/FileCheck.h =================================================================== --- llvm/trunk/include/llvm/Support/FileCheck.h +++ llvm/trunk/include/llvm/Support/FileCheck.h @@ -66,10 +66,10 @@ FileCheckNumericVariable(StringRef Name, uint64_t Value) : Name(Name), Value(Value), DefLineNumber(0) {} - /// \returns name of that numeric variable. + /// \returns name of this numeric variable. StringRef getName() const { return Name; } - /// \returns value of this numeric variable. + /// \returns this variable's value. Optional getValue() const { return Value; } /// Sets value of this numeric variable if not defined. \returns whether the @@ -111,10 +111,10 @@ } }; -/// Class representing a numeric expression consisting of either a single -/// numeric variable or a binary operation between a numeric variable and an +/// Class representing an expression consisting of either a single numeric +/// variable or a binary operation between a numeric variable and an /// immediate. -class FileCheckNumExpr { +class FileCheckExpression { private: /// Left operand. FileCheckNumericVariable *LeftOp; @@ -126,13 +126,14 @@ binop_eval_t EvalBinop; public: - FileCheckNumExpr(binop_eval_t EvalBinop, - FileCheckNumericVariable *OperandLeft, uint64_t OperandRight) + FileCheckExpression(binop_eval_t EvalBinop, + FileCheckNumericVariable *OperandLeft, + uint64_t OperandRight) : LeftOp(OperandLeft), RightOp(OperandRight), EvalBinop(EvalBinop) {} - /// Evaluates the value of this numeric expression, using EvalBinop to - /// perform the binary operation it consists of. \returns an error if the - /// numeric variable used is undefined, or the expression value otherwise. + /// Evaluates the value of this expression, using EvalBinop to perform the + /// binary operation it consists of. \returns an error if the numeric + /// variable used is undefined, or the expression value otherwise. Expected eval() const; }; @@ -144,14 +145,13 @@ /// Pointer to a class instance holding, among other things, the table with /// the values of live string variables at the start of any given CHECK line. /// Used for substituting string variables with the text they were defined - /// as. Numeric expressions are linked to the numeric variables they use at + /// as. Expressions are linked to the numeric variables they use at /// parse time and directly access the value of the numeric variable to /// evaluate their value. FileCheckPatternContext *Context; /// The string that needs to be substituted for something else. For a - /// string variable this is its name, otherwise this is the whole numeric - /// expression. + /// string variable this is its name, otherwise this is the whole expression. StringRef FromStr; // Index in RegExStr of where to do the substitution. @@ -188,17 +188,20 @@ class FileCheckNumericSubstitution : public FileCheckSubstitution { private: - /// Pointer to the class representing the numeric expression whose value is - /// to be substituted. - FileCheckNumExpr *NumExpr; + /// Pointer to the class representing the expression whose value is to be + /// substituted. + FileCheckExpression *Expression; public: - FileCheckNumericSubstitution(FileCheckPatternContext *Context, StringRef Expr, - FileCheckNumExpr *NumExpr, size_t InsertIdx) - : FileCheckSubstitution(Context, Expr, InsertIdx), NumExpr(NumExpr) {} + FileCheckNumericSubstitution(FileCheckPatternContext *Context, + StringRef ExpressionStr, + FileCheckExpression *Expression, + size_t InsertIdx) + : FileCheckSubstitution(Context, ExpressionStr, InsertIdx), + Expression(Expression) {} - /// \returns a string containing the result of evaluating the numeric - /// expression in this substitution, or an error if evaluation failed. + /// \returns a string containing the result of evaluating the expression in + /// this substitution, or an error if evaluation failed. Expected getResult() const override; }; @@ -276,10 +279,9 @@ /// pattern. StringMap GlobalNumericVariableTable; - /// Vector holding pointers to all parsed numeric expressions. Used to - /// automatically free the numeric expressions once they are guaranteed to no - /// longer be used. - std::vector> NumExprs; + /// Vector holding pointers to all parsed expressions. Used to automatically + /// free the expressions once they are guaranteed to no longer be used. + std::vector> Expressions; /// Vector holding pointers to all parsed numeric variables. Used to /// automatically free them once they are guaranteed to no longer be used. @@ -308,11 +310,11 @@ void clearLocalVars(); private: - /// Makes a new numeric expression instance and registers it for destruction - /// when the context is destroyed. - FileCheckNumExpr *makeNumExpr(binop_eval_t EvalBinop, - FileCheckNumericVariable *OperandLeft, - uint64_t OperandRight); + /// Makes a new expression instance and registers it for destruction when + /// the context is destroyed. + FileCheckExpression *makeExpression(binop_eval_t EvalBinop, + FileCheckNumericVariable *OperandLeft, + uint64_t OperandRight); /// Makes a new numeric variable and registers it for destruction when the /// context is destroyed. @@ -326,9 +328,9 @@ /// Makes a new numeric substitution and registers it for destruction when /// the context is destroyed. - FileCheckSubstitution *makeNumericSubstitution(StringRef Expr, - FileCheckNumExpr *NumExpr, - size_t InsertIdx); + FileCheckSubstitution * + makeNumericSubstitution(StringRef ExpressionStr, + FileCheckExpression *Expression, size_t InsertIdx); }; /// Class to represent an error holding a diagnostic with location information @@ -384,12 +386,12 @@ /// a fixed string to match. std::string RegExStr; - /// Entries in this vector represent a substitution of a string variable or a - /// numeric expression in the RegExStr regex at match time. For example, in - /// the case of a CHECK directive with the pattern "foo[[bar]]baz[[#N+1]]", + /// Entries in this vector represent a substitution of a string variable or + /// an expression in the RegExStr regex at match time. For example, in the + /// case of a CHECK directive with the pattern "foo[[bar]]baz[[#N+1]]", /// RegExStr will contain "foobaz" and we'll get two entries in this vector /// that tells us to insert the value of string variable "bar" at offset 3 - /// and the value of numeric expression "N+1" at offset 6. + /// and the value of expression "N+1" at offset 6. std::vector Substitutions; /// Maps names of string variables defined in a pattern to the number of @@ -409,7 +411,7 @@ /// It holds the pointer to the class representing the numeric variable whose /// value is being defined and the number of the parenthesis group in /// RegExStr to capture that value. - struct FileCheckNumExprMatch { + struct FileCheckNumericVariableMatch { /// Pointer to class representing the numeric variable whose value is being /// defined. FileCheckNumericVariable *DefinedNumericVariable; @@ -423,7 +425,7 @@ /// corresponding FileCheckNumericVariable class instance of all numeric /// variable definitions. Used to set the matched value of all those /// variables. - StringMap NumericVariableDefs; + StringMap NumericVariableDefs; /// Pointer to a class instance holding the global state shared by all /// patterns: @@ -468,13 +470,12 @@ FileCheckPatternContext *Context, const SourceMgr &SM); /// Parses \p Expr for a numeric substitution block. \returns the class - /// representing the AST of the numeric expression whose value must be - /// substituted, or an error holding a diagnostic against \p SM if parsing - /// fails. If substitution was successful, sets \p DefinedNumericVariable to - /// point to the class representing the numeric variable defined in this - /// numeric substitution block, or None if this block does not define any - /// variable. - Expected parseNumericSubstitutionBlock( + /// representing the AST of the expression whose value must be substituted, + /// or an error holding a diagnostic against \p SM if parsing fails. If + /// substitution was successful, sets \p DefinedNumericVariable to point to + /// the class representing the numeric variable defined in this numeric + /// substitution block, or None if this block does not define any variable. + Expected parseNumericSubstitutionBlock( StringRef Expr, Optional &DefinedNumericVariable, const SourceMgr &SM) const; @@ -537,10 +538,10 @@ Expected parseNumericVariableUse(StringRef &Expr, const SourceMgr &SM) const; /// Parses \p Expr for a binary operation. - /// \returns the class representing the binary operation of the numeric - /// expression, or an error holding a diagnostic against \p SM otherwise. - Expected parseBinop(StringRef &Expr, - const SourceMgr &SM) const; + /// \returns the class representing the binary operation of the expression, + /// or an error holding a diagnostic against \p SM otherwise. + Expected parseBinop(StringRef &Expr, + const SourceMgr &SM) const; }; //===----------------------------------------------------------------------===// Index: llvm/trunk/lib/Support/FileCheck.cpp =================================================================== --- llvm/trunk/lib/Support/FileCheck.cpp +++ llvm/trunk/lib/Support/FileCheck.cpp @@ -38,8 +38,8 @@ return false; } -Expected FileCheckNumExpr::eval() const { - assert(LeftOp && "Evaluating an empty numeric expression"); +Expected FileCheckExpression::eval() const { + assert(LeftOp && "Evaluating an empty expression"); Optional LeftOpValue = LeftOp->getValue(); // Variable is undefined. if (!LeftOpValue) @@ -48,7 +48,7 @@ } Expected FileCheckNumericSubstitution::getResult() const { - Expected EvaluatedValue = NumExpr->eval(); + Expected EvaluatedValue = Expression->eval(); if (!EvaluatedValue) return EvaluatedValue.takeError(); return utostr(*EvaluatedValue); @@ -174,7 +174,7 @@ return LeftOp - RightOp; } -Expected +Expected FileCheckPattern::parseBinop(StringRef &Expr, const SourceMgr &SM) const { Expected LeftParseResult = parseNumericVariableUse(Expr, SM); @@ -187,7 +187,7 @@ // it. Expr = Expr.ltrim(SpaceChars); if (Expr.empty()) - return Context->makeNumExpr(add, LeftOp, 0); + return Context->makeExpression(add, LeftOp, 0); SMLoc OpLoc = SMLoc::getFromPointer(Expr.data()); char Operator = popFront(Expr); binop_eval_t EvalBinop; @@ -200,29 +200,27 @@ break; default: return FileCheckErrorDiagnostic::get( - SM, OpLoc, - Twine("unsupported numeric operation '") + Twine(Operator) + "'"); + SM, OpLoc, Twine("unsupported operation '") + Twine(Operator) + "'"); } // Parse right operand. Expr = Expr.ltrim(SpaceChars); if (Expr.empty()) - return FileCheckErrorDiagnostic::get( - SM, Expr, "missing operand in numeric expression"); + return FileCheckErrorDiagnostic::get(SM, Expr, + "missing operand in expression"); uint64_t RightOp; if (Expr.consumeInteger(10, RightOp)) return FileCheckErrorDiagnostic::get( - SM, Expr, "invalid offset in numeric expression '" + Expr + "'"); + SM, Expr, "invalid offset in expression '" + Expr + "'"); Expr = Expr.ltrim(SpaceChars); if (!Expr.empty()) return FileCheckErrorDiagnostic::get( - SM, Expr, - "unexpected characters at end of numeric expression '" + Expr + "'"); + SM, Expr, "unexpected characters at end of expression '" + Expr + "'"); - return Context->makeNumExpr(EvalBinop, LeftOp, RightOp); + return Context->makeExpression(EvalBinop, LeftOp, RightOp); } -Expected FileCheckPattern::parseNumericSubstitutionBlock( +Expected FileCheckPattern::parseNumericSubstitutionBlock( StringRef Expr, Optional &DefinedNumericVariable, const SourceMgr &SM) const { @@ -252,10 +250,10 @@ return FileCheckErrorDiagnostic::get( SM, UseExpr, "unexpected string after variable definition: '" + UseExpr + "'"); - return Context->makeNumExpr(add, nullptr, 0); + return Context->makeExpression(add, nullptr, 0); } - // Parse the numeric expression itself. + // Parse the expression itself. Expr = Expr.ltrim(SpaceChars); return parseBinop(Expr, SM); } @@ -380,7 +378,7 @@ StringRef MatchRegexp; size_t SubstInsertIdx = RegExStr.size(); - // Parse string variable or legacy numeric expression. + // Parse string variable or legacy expression. if (!IsNumBlock) { size_t VarEndIdx = MatchStr.find(":"); size_t SpacePos = MatchStr.substr(0, VarEndIdx).find_first_of(" \t"); @@ -431,16 +429,16 @@ } // Parse numeric substitution block. - FileCheckNumExpr *NumExpr; + FileCheckExpression *Expression; Optional DefinedNumericVariable; if (IsNumBlock) { - Expected ParseResult = + Expected ParseResult = parseNumericSubstitutionBlock(MatchStr, DefinedNumericVariable, SM); if (!ParseResult) { logAllUnhandledErrors(ParseResult.takeError(), errs()); return true; } - NumExpr = *ParseResult; + Expression = *ParseResult; if (DefinedNumericVariable) { IsDefinition = true; DefName = (*DefinedNumericVariable)->getName(); @@ -452,9 +450,8 @@ // Handle substitutions: [[foo]] and [[#]]. if (!IsDefinition) { // Handle substitution of string variables that were defined earlier on - // the same line by emitting a backreference. Numeric expressions do - // not support substituting a numeric variable defined on the same - // line. + // the same line by emitting a backreference. Expressions do not + // support substituting a numeric variable defined on the same line. if (!IsNumBlock && VariableDefs.find(SubstStr) != VariableDefs.end()) { unsigned CaptureParenGroup = VariableDefs[SubstStr]; if (CaptureParenGroup < 1 || CaptureParenGroup > 9) { @@ -466,10 +463,10 @@ AddBackrefToRegEx(CaptureParenGroup); } else { // Handle substitution of string variables ([[]]) defined in - // previous CHECK patterns, and substitution of numeric expressions. + // previous CHECK patterns, and substitution of expressions. FileCheckSubstitution *Substitution = IsNumBlock - ? Context->makeNumericSubstitution(SubstStr, NumExpr, + ? Context->makeNumericSubstitution(SubstStr, Expression, SubstInsertIdx) : Context->makeStringSubstitution(SubstStr, SubstInsertIdx); Substitutions.push_back(Substitution); @@ -480,8 +477,9 @@ // Handle variable definitions: [[:(...)]] and // [[#(...):(...)]]. if (IsNumBlock) { - FileCheckNumExprMatch NumExprDef = {*DefinedNumericVariable, CurParen}; - NumericVariableDefs[DefName] = NumExprDef; + FileCheckNumericVariableMatch NumericVariableDefinition = { + *DefinedNumericVariable, CurParen}; + NumericVariableDefs[DefName] = NumericVariableDefinition; // This store is done here rather than in match() to allow // parseNumericVariableUse() to get the pointer to the class instance // of the right variable definition corresponding to a given numeric @@ -570,9 +568,9 @@ TmpStr = RegExStr; size_t InsertOffset = 0; - // Substitute all string variables and numeric expressions whose values are - // only now known. Use of string variables defined on the same line are - // handled by back-references. + // Substitute all string variables and expressions whose values are only + // now known. Use of string variables defined on the same line are handled + // by back-references. for (const auto &Substitution : Substitutions) { // Substitute and check for failure (e.g. use of undefined variable). Expected Value = Substitution->getResult(); @@ -606,7 +604,7 @@ // If this defines any numeric variables, remember their values. for (const auto &NumericVariableDef : NumericVariableDefs) { - const FileCheckNumExprMatch &NumericVariableMatch = + const FileCheckNumericVariableMatch &NumericVariableMatch = NumericVariableDef.getValue(); unsigned CaptureParenGroup = NumericVariableMatch.CaptureParenGroup; assert(CaptureParenGroup < MatchInfo.size() && "Internal paren error"); @@ -765,13 +763,13 @@ return VarIter->second; } -FileCheckNumExpr * -FileCheckPatternContext::makeNumExpr(binop_eval_t EvalBinop, - FileCheckNumericVariable *OperandLeft, - uint64_t OperandRight) { - NumExprs.push_back(llvm::make_unique(EvalBinop, OperandLeft, - OperandRight)); - return NumExprs.back().get(); +FileCheckExpression * +FileCheckPatternContext::makeExpression(binop_eval_t EvalBinop, + FileCheckNumericVariable *OperandLeft, + uint64_t OperandRight) { + Expressions.push_back(llvm::make_unique( + EvalBinop, OperandLeft, OperandRight)); + return Expressions.back().get(); } template @@ -791,9 +789,10 @@ } FileCheckSubstitution *FileCheckPatternContext::makeNumericSubstitution( - StringRef Expr, FileCheckNumExpr *NumExpr, size_t InsertIdx) { + StringRef ExpressionStr, FileCheckExpression *Expression, + size_t InsertIdx) { Substitutions.push_back(llvm::make_unique( - this, Expr, NumExpr, InsertIdx)); + this, ExpressionStr, Expression, InsertIdx)); return Substitutions.back().get(); } Index: llvm/trunk/test/FileCheck/line-count.txt =================================================================== --- llvm/trunk/test/FileCheck/line-count.txt +++ llvm/trunk/test/FileCheck/line-count.txt @@ -47,13 +47,13 @@ 47 ERR8: line-count.txt:[[#@LINE-1]]:12: error: invalid pseudo numeric variable '@LIN' 48 49 BAD9: [[@LINE*2]] -50 ERR9: line-count.txt:[[#@LINE-1]]:17: error: unsupported numeric operation '*' +50 ERR9: line-count.txt:[[#@LINE-1]]:17: error: unsupported operation '*' 51 52 BAD10: [[@LINE-x]] -53 ERR10: line-count.txt:[[#@LINE-1]]:19: error: invalid offset in numeric expression 'x' +53 ERR10: line-count.txt:[[#@LINE-1]]:19: error: invalid offset in expression 'x' 54 55 BAD11: [[@LINE-1x]] -56 ERR11: line-count.txt:[[#@LINE-1]]:20: error: unexpected characters at end of numeric expression 'x' +56 ERR11: line-count.txt:[[#@LINE-1]]:20: error: unexpected characters at end of expression 'x' 57 58 CHECK: [[#@LINE]] CHECK 59 CHECK: [[# @LINE]] CHECK Index: llvm/trunk/test/FileCheck/numeric-expression.txt =================================================================== --- llvm/trunk/test/FileCheck/numeric-expression.txt +++ llvm/trunk/test/FileCheck/numeric-expression.txt @@ -88,7 +88,7 @@ NUMVAR*2: 22 INVAL-OP-LABEL: INVALID OPERATOR INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]] -INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported numeric operation '*' +INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*' INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}} INVAL-OP-MSG-NEXT: {{^ \^$}} Index: llvm/trunk/unittests/Support/FileCheckTest.cpp =================================================================== --- llvm/trunk/unittests/Support/FileCheckTest.cpp +++ llvm/trunk/unittests/Support/FileCheckTest.cpp @@ -47,12 +47,12 @@ }); } -TEST_F(FileCheckTest, NumExpr) { +TEST_F(FileCheckTest, Expression) { FileCheckNumericVariable FooVar = FileCheckNumericVariable("FOO", 42); - FileCheckNumExpr NumExpr = FileCheckNumExpr(doAdd, &FooVar, 18); + FileCheckExpression Expression = FileCheckExpression(doAdd, &FooVar, 18); // Defined variable: eval returns right value. - Expected Value = NumExpr.eval(); + Expected Value = Expression.eval(); EXPECT_TRUE(static_cast(Value)); EXPECT_EQ(60U, *Value); @@ -60,7 +60,7 @@ // getUndefVarName first to check that it can be called without calling // eval() first. FooVar.clearValue(); - Error EvalError = NumExpr.eval().takeError(); + Error EvalError = Expression.eval().takeError(); EXPECT_TRUE(errorToBool(std::move(EvalError))); expectUndefError("FOO", std::move(EvalError)); } @@ -354,12 +354,12 @@ // the right value. FileCheckNumericVariable LineVar = FileCheckNumericVariable("@LINE", 42); FileCheckNumericVariable NVar = FileCheckNumericVariable("N", 10); - FileCheckNumExpr NumExprLine = FileCheckNumExpr(doAdd, &LineVar, 0); - FileCheckNumExpr NumExprN = FileCheckNumExpr(doAdd, &NVar, 3); + FileCheckExpression LineExpression = FileCheckExpression(doAdd, &LineVar, 0); + FileCheckExpression NExpression = FileCheckExpression(doAdd, &NVar, 3); FileCheckNumericSubstitution SubstitutionLine = - FileCheckNumericSubstitution(&Context, "@LINE", &NumExprLine, 12); + FileCheckNumericSubstitution(&Context, "@LINE", &LineExpression, 12); FileCheckNumericSubstitution SubstitutionN = - FileCheckNumericSubstitution(&Context, "N", &NumExprN, 30); + FileCheckNumericSubstitution(&Context, "N", &NExpression, 30); Expected Value = SubstitutionLine.getResult(); EXPECT_TRUE(static_cast(Value)); EXPECT_EQ("42", *Value); @@ -445,16 +445,16 @@ Expected LocalVar = Cxt.getPatternVarValue(LocalVarStr); FileCheckPattern P = FileCheckPattern(Check::CheckPlain, &Cxt, 1); Optional DefinedNumericVariable; - Expected NumExpr = P.parseNumericSubstitutionBlock( + Expected Expression = P.parseNumericSubstitutionBlock( LocalNumVarRef, DefinedNumericVariable, SM); Expected EmptyVar = Cxt.getPatternVarValue(EmptyVarStr); Expected UnknownVar = Cxt.getPatternVarValue(UnknownVarStr); EXPECT_TRUE(static_cast(LocalVar)); EXPECT_EQ(*LocalVar, "FOO"); - EXPECT_TRUE(static_cast(NumExpr)); - Expected NumExprVal = (*NumExpr)->eval(); - EXPECT_TRUE(static_cast(NumExprVal)); - EXPECT_EQ(*NumExprVal, 18U); + EXPECT_TRUE(static_cast(Expression)); + Expected ExpressionVal = (*Expression)->eval(); + EXPECT_TRUE(static_cast(ExpressionVal)); + EXPECT_EQ(*ExpressionVal, 18U); EXPECT_TRUE(static_cast(EmptyVar)); EXPECT_EQ(*EmptyVar, ""); EXPECT_TRUE(errorToBool(UnknownVar.takeError())); @@ -467,11 +467,11 @@ // local variables, if it was created before. This is important because local // variable clearing due to --enable-var-scope happens after numeric // expressions are linked to the numeric variables they use. - EXPECT_TRUE(errorToBool((*NumExpr)->eval().takeError())); + EXPECT_TRUE(errorToBool((*Expression)->eval().takeError())); P = FileCheckPattern(Check::CheckPlain, &Cxt, 2); - NumExpr = P.parseNumericSubstitutionBlock(LocalNumVarRef, - DefinedNumericVariable, SM); - EXPECT_TRUE(errorToBool(NumExpr.takeError())); + Expression = P.parseNumericSubstitutionBlock(LocalNumVarRef, + DefinedNumericVariable, SM); + EXPECT_TRUE(errorToBool(Expression.takeError())); EmptyVar = Cxt.getPatternVarValue(EmptyVarStr); EXPECT_TRUE(errorToBool(EmptyVar.takeError())); @@ -485,22 +485,22 @@ EXPECT_TRUE(static_cast(GlobalVar)); EXPECT_EQ(*GlobalVar, "BAR"); P = FileCheckPattern(Check::CheckPlain, &Cxt, 3); - NumExpr = P.parseNumericSubstitutionBlock(GlobalNumVarRef, - DefinedNumericVariable, SM); - EXPECT_TRUE(static_cast(NumExpr)); - NumExprVal = (*NumExpr)->eval(); - EXPECT_TRUE(static_cast(NumExprVal)); - EXPECT_EQ(*NumExprVal, 36U); + Expression = P.parseNumericSubstitutionBlock(GlobalNumVarRef, + DefinedNumericVariable, SM); + EXPECT_TRUE(static_cast(Expression)); + ExpressionVal = (*Expression)->eval(); + EXPECT_TRUE(static_cast(ExpressionVal)); + EXPECT_EQ(*ExpressionVal, 36U); // Clear local variables and check global variables remain defined. Cxt.clearLocalVars(); EXPECT_FALSE(errorToBool(Cxt.getPatternVarValue(GlobalVarStr).takeError())); P = FileCheckPattern(Check::CheckPlain, &Cxt, 4); - NumExpr = P.parseNumericSubstitutionBlock(GlobalNumVarRef, - DefinedNumericVariable, SM); - EXPECT_TRUE(static_cast(NumExpr)); - NumExprVal = (*NumExpr)->eval(); - EXPECT_TRUE(static_cast(NumExprVal)); - EXPECT_EQ(*NumExprVal, 36U); + Expression = P.parseNumericSubstitutionBlock(GlobalNumVarRef, + DefinedNumericVariable, SM); + EXPECT_TRUE(static_cast(Expression)); + ExpressionVal = (*Expression)->eval(); + EXPECT_TRUE(static_cast(ExpressionVal)); + EXPECT_EQ(*ExpressionVal, 36U); } } // namespace