summaryrefslogtreecommitdiff
path: root/include/clang/Tooling
diff options
context:
space:
mode:
authorYitzhak Mandelbaum <yitzhakm@google.com>2019-09-20 17:11:03 +0000
committerYitzhak Mandelbaum <yitzhakm@google.com>2019-09-20 17:11:03 +0000
commit2ecd583adaae907d88e4f544ed62939a8103e968 (patch)
tree56cf60cdc5649431a4bdc9c8f640f9798728cf94 /include/clang/Tooling
parent5765299b76e9098d2c84c69178b4ccfdb6c23bc0 (diff)
downloadclang-2ecd583adaae907d88e4f544ed62939a8103e968.tar.gz
[libTooling] Add `ifBound`, `elseBranch` RangeSelector combinators.
Summary: Adds two new combinators and corresponding tests to the RangeSelector library. * `ifBound` -- conditional evaluation of range-selectors, based on whether a given node id is bound in the match. * `elseBranch` -- selects the source range of the else and its statement. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67621 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Tooling')
-rw-r--r--include/clang/Tooling/Refactoring/RangeSelector.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/clang/Tooling/Refactoring/RangeSelector.h b/include/clang/Tooling/Refactoring/RangeSelector.h
index b117e4d82a..e5fe051413 100644
--- a/include/clang/Tooling/Refactoring/RangeSelector.h
+++ b/include/clang/Tooling/Refactoring/RangeSelector.h
@@ -79,10 +79,19 @@ RangeSelector statements(std::string ID);
// (all source between the braces).
RangeSelector initListElements(std::string ID);
+/// Given an \IfStmt (bound to \p ID), selects the range of the else branch,
+/// starting from the \c else keyword.
+RangeSelector elseBranch(std::string ID);
+
/// Selects the range from which `S` was expanded (possibly along with other
/// source), if `S` is an expansion, and `S` itself, otherwise. Corresponds to
/// `SourceManager::getExpansionRange`.
RangeSelector expansion(RangeSelector S);
+
+/// Chooses between the two selectors, based on whether \p ID is bound in the
+/// match.
+RangeSelector ifBound(std::string ID, RangeSelector TrueSelector,
+ RangeSelector FalseSelector);
} // namespace tooling
} // namespace clang