Stop using SourceManager::getBufferIdentifierForLoc to find buffer IDs

The right way is findBufferContainingLoc. getBufferIdentifierForLoc is
both slower and wrong in the presence of #sourceLocation.

I couldn't come up with a test for the change in IDE/Utils.cpp because
refactoring still seems to be broken around #sourceLocation. I'll file
bugs for that.
This commit is contained in:
Jordan Rose
2018-08-29 10:51:12 -07:00
parent b9af6e0110
commit 63cd1258ea
5 changed files with 74 additions and 9 deletions

View File

@@ -684,8 +684,7 @@ getParamParentNameOffset(const ValueDecl *VD, SourceLoc Cursor) {
if (Loc.isInvalid())
return None;
auto &SM = VD->getASTContext().SourceMgr;
return SM.getLocOffsetInBuffer(Loc, SM.getIDForBufferIdentifier(SM.
getBufferIdentifierForLoc(Loc)).getValue());
return SM.getLocOffsetInBuffer(Loc, SM.findBufferContainingLoc(Loc));
}
/// Returns true for failure to resolve.