Skip to content

Commit 801079b

Browse files
committed
[Basic] Use start loc for original source range in isBeforeInSource
Given we're working with CharSourceRanges, the end location is past the end of the actual range, so when checking if e.g a function body macro is contained within the function decl, we fail since the end location is past the closing `}`. Check the start location instead, which is part of the range.
1 parent 21d09a0 commit 801079b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Basic/SourceLoc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,11 +836,11 @@ static bool isBeforeInSource(
836836
SourceLoc firstLocInLCA = firstMismatch == firstAncestors.end()
837837
? firstLoc
838838
: sourceMgr.getGeneratedSourceInfo(*firstMismatch)
839-
->originalSourceRange.getEnd();
839+
->originalSourceRange.getStart();
840840
SourceLoc secondLocInLCA = secondMismatch == secondAncestors.end()
841841
? secondLoc
842842
: sourceMgr.getGeneratedSourceInfo(*secondMismatch)
843-
->originalSourceRange.getEnd();
843+
->originalSourceRange.getStart();
844844
return sourceMgr.isBeforeInBuffer(firstLocInLCA, secondLocInLCA) ||
845845
(allowEqual && firstLocInLCA == secondLocInLCA);
846846
}

0 commit comments

Comments
 (0)