Fixed a problem where the second @import statement

in a session would be silently ignored by the compiler
because the compiler looked at its SourceLocation and
decided it had already handled it.

Also updated the relevant test case.

<rdar://problem/20315447>

llvm-svn: 234330
This commit is contained in:
Sean Callanan 2015-04-07 17:02:02 +00:00
parent d382ed25f6
commit 157f1af743
2 changed files with 9 additions and 3 deletions

View File

@ -80,6 +80,7 @@ namespace {
llvm::IntrusiveRefCntPtr<clang::CompilerInvocation> m_compiler_invocation;
std::unique_ptr<clang::CompilerInstance> m_compiler_instance;
std::unique_ptr<clang::Parser> m_parser;
size_t m_source_location_index = 0; // used to give name components fake SourceLocations
};
}
@ -177,13 +178,12 @@ ClangModulesDeclVendorImpl::AddModule(std::vector<llvm::StringRef> &path,
llvm::SmallVector<std::pair<clang::IdentifierInfo *, clang::SourceLocation>, 4> clang_path;
{
size_t source_loc_counter = 0;
clang::SourceManager &source_manager = m_compiler_instance->getASTContext().getSourceManager();
for (llvm::StringRef &component : path)
{
clang_path.push_back(std::make_pair(&m_compiler_instance->getASTContext().Idents.get(component),
source_manager.getLocForStartOfFile(source_manager.getMainFileID()).getLocWithOffset(source_loc_counter++)));
source_manager.getLocForStartOfFile(source_manager.getMainFileID()).getLocWithOffset(m_source_location_index++)));
}
}

View File

@ -67,9 +67,15 @@ class ObjCModulesTestCase(TestBase):
self.common_setup()
self.expect("expr @import Foundation; 3", VARIABLES_DISPLAYED_CORRECTLY,
self.expect("expr @import Darwin; 3", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["int", "3"])
self.expect("expr getpid()", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["pid_t"])
self.expect("expr @import Foundation; 4", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["int", "4"])
self.expect("expr string.length", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["NSUInteger", "5"])