@@ -83,11 +83,11 @@ bool ASTScopeImpl::checkSourceRangeOfThisASTNode() const {
83
83
// / If the \p loc is in a new buffer but \p range is not, consider the location
84
84
// / is at the start of replaced range. Otherwise, returns \p loc as is.
85
85
static SourceLoc translateLocForReplacedRange (SourceManager &sourceMgr,
86
- SourceRange range,
86
+ CharSourceRange range,
87
87
SourceLoc loc) {
88
88
if (const auto &replacedRange = sourceMgr.getReplacedRange ()) {
89
89
if (sourceMgr.rangeContainsTokenLoc (replacedRange.New , loc) &&
90
- !sourceMgr.rangeContains (replacedRange.New , range)) {
90
+ !sourceMgr.rangeContainsTokenLoc (replacedRange.New , range. getStart () )) {
91
91
return replacedRange.Original .Start ;
92
92
}
93
93
}
@@ -101,17 +101,19 @@ ASTScopeImpl::findChildContaining(SourceLoc loc,
101
101
auto *const *child = llvm::lower_bound (
102
102
getChildren (), loc,
103
103
[&sourceMgr](const ASTScopeImpl *scope, SourceLoc loc) {
104
- ASTScopeAssert (scope->checkSourceRangeOfThisASTNode (), " Bad range." );
105
- auto rangeOfScope = scope->getSourceRangeOfScope ();
104
+ auto rangeOfScope = scope->getCharSourceRangeOfScope (sourceMgr);
105
+ ASTScopeAssert (!sourceMgr.isBeforeInBuffer (rangeOfScope.getEnd (),
106
+ rangeOfScope.getStart ()),
107
+ " Source range is backwards" );
106
108
loc = translateLocForReplacedRange (sourceMgr, rangeOfScope, loc);
107
- return - 1 == ASTScopeImpl::compare (rangeOfScope, loc, sourceMgr,
108
- /* ensureDisjoint= */ false );
109
+ return (rangeOfScope. getEnd () == loc ||
110
+ sourceMgr. isBeforeInBuffer (rangeOfScope. getEnd (), loc) );
109
111
});
110
112
111
113
if (child != getChildren ().end ()) {
112
- auto rangeOfScope = (*child)->getSourceRangeOfScope ( );
114
+ auto rangeOfScope = (*child)->getCharSourceRangeOfScope (sourceMgr );
113
115
loc = translateLocForReplacedRange (sourceMgr, rangeOfScope, loc);
114
- if (sourceMgr. rangeContainsTokenLoc (rangeOfScope, loc))
116
+ if (rangeOfScope. contains ( loc))
115
117
return *child;
116
118
}
117
119
0 commit comments