================
@@ -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()
----------------
ymand wrote:
I think we generally don't compare source ranges when we care about semantic
details. Instead, we use APIs like isBeforeInTranslationUnit. I don't remember
the subtleties offhand, but that's what we use e.g. on line 169 and should be a
good start at least. I would recommend you look at the declaration and
implementation of makeFileCharRange to get a sense for the subtleties involved
here.
https://github.com/llvm/llvm-project/pull/169560
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits