[clang] [clang][transformer] Add `merge` range-selector for selecting the merge of two ranges. (PR #169560)
Yu Hao via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 25 17:59:48 PST 2025
================
@@ -178,6 +178,56 @@ RangeSelector transformer::encloseNodes(std::string BeginID,
return transformer::enclose(node(std::move(BeginID)), node(std::move(EndID)));
}
+RangeSelector transformer::merge(RangeSelector First, RangeSelector Second) {
+ return [First,
+ Second](const MatchResult &Result) -> Expected<CharSourceRange> {
+ Expected<CharSourceRange> FirstRange = First(Result);
+ if (!FirstRange)
+ return FirstRange.takeError();
+ Expected<CharSourceRange> SecondRange = Second(Result);
+ if (!SecondRange)
+ return SecondRange.takeError();
+ // Result begin loc is the minimum of the begin locs of the two ranges.
+ SourceLocation B = FirstRange->getBegin() < SecondRange->getBegin()
----------------
yuhaouy wrote:
Thanks! Fixed.
https://github.com/llvm/llvm-project/pull/169560
More information about the cfe-commits
mailing list