SourceManager: make findBufferContainingLoc() always succeed.

Every valid source location corresponds to a source buffer.  There should be no
cases where we create a source location for a random string.  Thus,
findBufferContainingLoc() always succeeds.


Swift SVN r7120
This commit is contained in:
Dmitri Hrybenko
2013-08-10 01:48:04 +00:00
parent 09837a1b88
commit 13070a31bd
8 changed files with 36 additions and 26 deletions

View File

@@ -46,10 +46,11 @@ static llvm::error_code findModule(ASTContext &ctx, AccessPathElem moduleID,
// First, search in the directory corresponding to the import location.
// FIXME: This screams for a proper FileManager abstraction.
int currentBufferID = ctx.SourceMgr.findBufferContainingLoc(moduleID.second);
if (currentBufferID >= 0) {
if (moduleID.second.isValid()) {
unsigned currentBufferID =
ctx.SourceMgr.findBufferContainingLoc(moduleID.second);
const llvm::MemoryBuffer *importingBuffer
= ctx.SourceMgr->getBufferInfo(currentBufferID).Buffer;
= ctx.SourceMgr->getMemoryBuffer(currentBufferID);
StringRef currentDirectory
= llvm::sys::path::parent_path(importingBuffer->getBufferIdentifier());
if (!currentDirectory.empty()) {