diff --git a/llvm/include/llvm/Support/FileCheck.h b/llvm/include/llvm/Support/FileCheck.h --- a/llvm/include/llvm/Support/FileCheck.h +++ b/llvm/include/llvm/Support/FileCheck.h @@ -48,7 +48,7 @@ StringRef Name; /// Value of numeric variable, if defined, or None otherwise. - llvm::Optional Value; + Optional Value; public: /// Constructor for numeric variable \p Name with a known \p Value at parse @@ -60,7 +60,7 @@ StringRef getName() const { return Name; } /// \returns value of this numeric variable. - llvm::Optional getValue() const { return Value; } + Optional getValue() const { return Value; } /// Sets value of this numeric variable if not defined. \returns whether the /// variable was already defined. @@ -96,7 +96,7 @@ /// Evaluates the value of this numeric expression, using EvalBinop to /// perform the binary operation it consists of. \returns None if the numeric /// variable used is undefined, or the expression value otherwise. - llvm::Optional eval() const; + Optional eval() const; /// \returns the name of the undefined variable used in this expression if /// any or an empty string otherwise. @@ -139,7 +139,7 @@ /// \returns a string containing the result of the substitution represented /// by this class instance or None if substitution failed. - virtual llvm::Optional getResult() const = 0; + virtual Optional getResult() const = 0; /// \returns the name of the variable used in this substitution if undefined, /// or an empty string otherwise. @@ -154,7 +154,7 @@ /// \returns the text that the string variable in this substitution matched /// when defined, or None if the variable is undefined. - llvm::Optional getResult() const override; + Optional getResult() const override; /// \returns the name of the string variable used in this substitution if /// undefined, or an empty string otherwise. @@ -174,7 +174,7 @@ /// \returns a string containing the result of evaluating the numeric /// expression in this substitution, or None if evaluation failed. - llvm::Optional getResult() const override; + Optional getResult() const override; /// \returns the name of the numeric variable used in this substitution if /// undefined, or an empty string otherwise. @@ -268,7 +268,7 @@ public: /// \returns the value of string variable \p VarName or None if no such /// variable has been defined. - llvm::Optional getPatternVarValue(StringRef VarName); + Optional getPatternVarValue(StringRef VarName); /// Defines string and numeric variables from definitions given on the /// command line, passed as a vector of [#]VAR=VAL strings in diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/Support/FileCheck.cpp --- a/llvm/lib/Support/FileCheck.cpp +++ b/llvm/lib/Support/FileCheck.cpp @@ -34,15 +34,15 @@ bool FileCheckNumericVariable::clearValue() { if (!Value) return true; - Value = llvm::None; + Value = None; return false; } -llvm::Optional FileCheckNumExpr::eval() const { - llvm::Optional LeftOp = this->LeftOp->getValue(); +Optional FileCheckNumExpr::eval() const { + Optional LeftOp = this->LeftOp->getValue(); // Variable is undefined. if (!LeftOp) - return llvm::None; + return None; return EvalBinop(*LeftOp, RightOp); } @@ -52,18 +52,18 @@ return StringRef(); } -llvm::Optional FileCheckNumericSubstitution::getResult() const { - llvm::Optional EvaluatedValue = NumExpr->eval(); +Optional FileCheckNumericSubstitution::getResult() const { + Optional EvaluatedValue = NumExpr->eval(); if (!EvaluatedValue) - return llvm::None; + return None; return utostr(*EvaluatedValue); } -llvm::Optional FileCheckStringSubstitution::getResult() const { +Optional FileCheckStringSubstitution::getResult() const { // Look up the value and escape it so that we can put it into the regex. - llvm::Optional VarVal = Context->getPatternVarValue(FromStr); + Optional VarVal = Context->getPatternVarValue(FromStr); if (!VarVal) - return llvm::None; + return None; return Regex::escape(*VarVal); } @@ -472,7 +472,7 @@ // handled by back-references. for (const auto &Substitution : Substitutions) { // Substitute and check for failure (e.g. use of undefined variable). - llvm::Optional Value = Substitution->getResult(); + Optional Value = Substitution->getResult(); if (!Value) return StringRef::npos; @@ -533,7 +533,7 @@ for (const auto &Substitution : Substitutions) { SmallString<256> Msg; raw_svector_ostream OS(Msg); - llvm::Optional MatchedValue = Substitution->getResult(); + Optional MatchedValue = Substitution->getResult(); // Substitution failed or is not known at match time, print the undefined // variable it uses. @@ -625,11 +625,11 @@ } } -llvm::Optional +Optional FileCheckPatternContext::getPatternVarValue(StringRef VarName) { auto VarIter = GlobalVariableTable.find(VarName); if (VarIter == GlobalVariableTable.end()) - return llvm::None; + return None; return VarIter->second; } @@ -638,15 +638,15 @@ FileCheckPatternContext::makeNumExpr(binop_eval_t EvalBinop, FileCheckNumericVariable *OperandLeft, uint64_t OperandRight) { - NumExprs.push_back(llvm::make_unique(EvalBinop, OperandLeft, - OperandRight)); + NumExprs.push_back( + make_unique(EvalBinop, OperandLeft, OperandRight)); return NumExprs.back().get(); } FileCheckNumericVariable * FileCheckPatternContext::makeNumericVariable(StringRef Name, uint64_t Value) { NumericVariables.push_back( - llvm::make_unique(Name, Value)); + make_unique(Name, Value)); return NumericVariables.back().get(); } @@ -654,13 +654,13 @@ FileCheckPatternContext::makeStringSubstitution(StringRef VarName, size_t InsertIdx) { Substitutions.push_back( - llvm::make_unique(this, VarName, InsertIdx)); + make_unique(this, VarName, InsertIdx)); return Substitutions.back().get(); } FileCheckSubstitution *FileCheckPatternContext::makeNumericSubstitution( StringRef Expr, FileCheckNumExpr *NumExpr, size_t InsertIdx) { - Substitutions.push_back(llvm::make_unique( + Substitutions.push_back(make_unique( this, Expr, NumExpr, InsertIdx)); return Substitutions.back().get(); } @@ -703,9 +703,8 @@ return StringRef::npos; } -StringRef -llvm::FileCheck::CanonicalizeFile(MemoryBuffer &MB, - SmallVectorImpl &OutputBuffer) { +StringRef FileCheck::CanonicalizeFile(MemoryBuffer &MB, + SmallVectorImpl &OutputBuffer) { OutputBuffer.reserve(MB.getBufferSize()); for (const char *Ptr = MB.getBufferStart(), *End = MB.getBufferEnd(); @@ -923,9 +922,8 @@ return {StringRef(), StringRef()}; } -bool llvm::FileCheck::ReadCheckFile( - SourceMgr &SM, StringRef Buffer, Regex &PrefixRE, - std::vector &CheckStrings) { +bool FileCheck::ReadCheckFile(SourceMgr &SM, StringRef Buffer, Regex &PrefixRE, + std::vector &CheckStrings) { if (PatternContext.defineCmdlineVariables(Req.GlobalDefines, SM)) return true; @@ -1499,7 +1497,7 @@ return Validator.match(CheckPrefix); } -bool llvm::FileCheck::ValidateCheckPrefixes() { +bool FileCheck::ValidateCheckPrefixes() { StringSet<> PrefixSet; for (StringRef Prefix : Req.CheckPrefixes) { @@ -1517,7 +1515,7 @@ return true; } -Regex llvm::FileCheck::buildCheckPrefixRegex() { +Regex FileCheck::buildCheckPrefixRegex() { // I don't think there's a way to specify an initial value for cl::list, // so if nothing was specified, add the default if (Req.CheckPrefixes.empty()) @@ -1682,9 +1680,9 @@ GlobalNumericVariableTable.erase(Var); } -bool llvm::FileCheck::CheckInput(SourceMgr &SM, StringRef Buffer, - ArrayRef CheckStrings, - std::vector *Diags) { +bool FileCheck::CheckInput(SourceMgr &SM, StringRef Buffer, + ArrayRef CheckStrings, + std::vector *Diags) { bool ChecksFailed = false; unsigned i = 0, j = 0, e = CheckStrings.size();