mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user