diff options
author | Samuel Benzaquen <sbenza@google.com> | 2014-04-23 14:04:52 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2014-04-23 14:04:52 +0000 |
commit | 045c15ba715ec4ad60412145fc8a071f96e69a75 (patch) | |
tree | f82ba71000245a48b05dda7387cd28c8029fae13 /clang-query/Query.cpp | |
parent | 34f55567cfe86204b44da9e3c5d080c9aca07dd2 (diff) |
Add new 'let' command to bind arbitrary values into constants.
Summary:
Add new 'let' command to bind arbitrary values into constants.
These constants can then be used in the matcher expressions.
Reviewers: pcc
CC: cfe-commits
Differential Revision: http://reviews.llvm.org/D3383
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@206984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-query/Query.cpp')
-rw-r--r-- | clang-query/Query.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang-query/Query.cpp b/clang-query/Query.cpp index dcfa80c5..65a68ede 100644 --- a/clang-query/Query.cpp +++ b/clang-query/Query.cpp @@ -54,7 +54,7 @@ struct CollectBoundNodes : MatchFinder::MatchCallback { } }; -} +} // namespace bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const { unsigned MatchCount = 0; @@ -124,6 +124,15 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const { return true; } +bool LetQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const { + if (Value) { + QS.NamedValues[Name] = Value; + } else { + QS.NamedValues.erase(Name); + } + return true; +} + #ifndef _MSC_VER const QueryKind SetQueryKind<bool>::value; const QueryKind SetQueryKind<OutputKind>::value; |