diff options
author | Alexander Richardson <arichardson.kde@gmail.com> | 2017-11-07 13:24:44 +0000 |
---|---|---|
committer | Alexander Richardson <arichardson.kde@gmail.com> | 2017-11-07 13:24:44 +0000 |
commit | 7c37aa1189ebbf92ebc9cb3eb7b067466651b3f8 (patch) | |
tree | f3c89faec35f8853c90316e1b09abe41da913c7b /utils | |
parent | 1ed4428b8f035c686af2b4b35d75aa428d364c55 (diff) |
Add a -D flag to FileCheck to define variables
Summary:
This makes it very easy to test files that only differ in a constant
value somewhere in the test case.
Reviewers: jlebar, hfinkel, chandlerc, probinson
Reviewed By: probinson
Subscribers: probinson, llvm-commits
Differential Revision: https://reviews.llvm.org/D39629
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317572 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/FileCheck/FileCheck.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp index 9d808cc875c..7db97301637 100644 --- a/utils/FileCheck/FileCheck.cpp +++ b/utils/FileCheck/FileCheck.cpp @@ -62,6 +62,10 @@ static cl::list<std::string> ImplicitCheckNot( "this pattern occur which are not matched by a positive pattern"), cl::value_desc("pattern")); +static cl::list<std::string> GlobalDefines("D", cl::Prefix, + cl::desc("Define a variable to be used in capture patterns."), + cl::value_desc("VAR=VALUE")); + static cl::opt<bool> AllowEmptyInput( "allow-empty", cl::init(false), cl::desc("Allow the input file to be empty. This is useful when making\n" @@ -1295,6 +1299,9 @@ bool CheckInput(SourceMgr &SM, StringRef Buffer, /// VariableTable - This holds all the current filecheck variables. StringMap<StringRef> VariableTable; + for (const auto& Def : GlobalDefines) + VariableTable.insert(StringRef(Def).split('=')); + unsigned i = 0, j = 0, e = CheckStrings.size(); while (true) { StringRef CheckRegion; |