diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index e311465cba1ade4e651c4f247b6f2ca596ec6dd2..0d2af334d79acdade20f85aae2e9b3b675a88f13 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -1129,11 +1129,15 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, } else { // Search for a module with the given name. Module = PP->getHeaderSearchInfo().lookupModule(ModuleName); - std::string ModuleFileName; - if (Module) { - ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(Module); - } else - ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(ModuleName); + if (!Module) { + getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found) + << ModuleName + << SourceRange(ImportLoc, ModuleNameLoc); + ModuleBuildFailed = true; + return ModuleLoadResult(); + } + + std::string ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(Module); // If we don't already have an ASTReader, create one now. if (!ModuleManager) { @@ -1180,17 +1184,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, case ASTReader::OutOfDate: case ASTReader::Missing: { // The module file is missing or out-of-date. Build it. - - // If we don't have a module, we don't know how to build the module file. - // Complain and return. - if (!Module) { - getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found) - << ModuleName - << SourceRange(ImportLoc, ModuleNameLoc); - ModuleBuildFailed = true; - return ModuleLoadResult(); - } - + assert(Module && "missing module file"); // Check whether there is a cycle in the module graph. ModuleBuildStack ModPath = getSourceManager().getModuleBuildStack(); ModuleBuildStack::iterator Pos = ModPath.begin(), PosEnd = ModPath.end(); @@ -1267,13 +1261,6 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, ModuleBuildFailed = true; return ModuleLoadResult(); } - - if (!Module) { - // If we loaded the module directly, without finding a module map first, - // we'll have loaded the module's information from the module itself. - Module = PP->getHeaderSearchInfo().getModuleMap() - .findModule((Path[0].first->getName())); - } // Cache the result of this top-level module lookup for later. Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first; diff --git a/test/Modules/config_macros.m b/test/Modules/config_macros.m index 200744d614a7b53b5f529bcf71d533c32fa9d6d5..b147317bf60d382d017cf308fcfb2007c77ed341 100644 --- a/test/Modules/config_macros.m +++ b/test/Modules/config_macros.m @@ -24,5 +24,5 @@ char *test_bar() { // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -DWANT_FOO=1 -emit-module -fmodule-name=config %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -DWANT_FOO=1 %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -DWANT_FOO=1 %s -verify diff --git a/test/Modules/diag-pragma.c b/test/Modules/diag-pragma.c index 7ec3400bba24bb98789dbddcdeedf9bb0b7b0a4e..89435c176ed59118a413e488c6fc91c5404efbac 100644 --- a/test/Modules/diag-pragma.c +++ b/test/Modules/diag-pragma.c @@ -1,6 +1,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diag_pragma %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t %s +// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s // FIXME: When we have a syntax for modules in C, use that. @import diag_pragma; diff --git a/test/Modules/diamond-pch.c b/test/Modules/diamond-pch.c index e7ad02dbe48aa8190fe4da63b160c5eea7226995..37a8cbe25d2402a8969ceb945d93dad44bf65a05 100644 --- a/test/Modules/diamond-pch.c +++ b/test/Modules/diamond-pch.c @@ -3,7 +3,7 @@ // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_left %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodules-cache-path=%t -o %t.pch %S/Inputs/diamond.h +// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodules-cache-path=%t -I %S/Inputs -o %t.pch %S/Inputs/diamond.h // RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -include-pch %t.pch %s -verify // FIXME: When we have a syntax for modules in C, use that. diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c index 89d5bc0dda5f6c901e8e51ced2cda8f3c2044c79..8b824081a1e398f114b57ab5420ce6d78547a0ff 100644 --- a/test/Modules/diamond.c +++ b/test/Modules/diamond.c @@ -3,7 +3,7 @@ // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_left %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t %s -verify +// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s -verify // FIXME: When we have a syntax for modules in C, use that. @import diamond_bottom; diff --git a/test/Modules/irgen.c b/test/Modules/irgen.c index 9a7cf7eff08c6315dbdd5084760ab81ddbf98052..c44afb1becb12a11db411c1817547cacfbf19722 100644 --- a/test/Modules/irgen.c +++ b/test/Modules/irgen.c @@ -1,6 +1,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=irgen -triple x86_64-apple-darwin10 %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s // FIXME: When we have a syntax for modules in C, use that. @import irgen; diff --git a/test/Modules/linkage-merge.m b/test/Modules/linkage-merge.m index e838ca10183dff2867241adb63799930bbc3002c..12ad32fa3d1847fd067a77e65734925c79c6d169 100644 --- a/test/Modules/linkage-merge.m +++ b/test/Modules/linkage-merge.m @@ -1,6 +1,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=linkage_merge_left %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -w %s -verify // Test redeclarations of functions where the original declaration is // still hidden. diff --git a/test/Modules/load_failure.c b/test/Modules/load_failure.c index 6c6d812bafa36ae8c05d2a677fcc6edd669bb87e..8b0d202ee8b5c9c0174dfeaf7b6c8b13c980caa8 100644 --- a/test/Modules/load_failure.c +++ b/test/Modules/load_failure.c @@ -8,10 +8,10 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -fdisable-module-hash -emit-module -fmodule-name=load_failure %S/Inputs/module.map -// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s +// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s // CHECK-NONEXISTENT: load_failure.c:2:9: fatal error: module 'load_nonexistent' not found -// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -fdisable-module-hash %s -DFAILURE 2> %t.out +// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs -fdisable-module-hash %s -DFAILURE 2> %t.out // RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t.out // FIXME: Clean up diagnostic text below and give it a location diff --git a/test/Modules/lookup.cpp b/test/Modules/lookup.cpp index efd88f47e35e411cab36ae270445d565a547371a..bfe0307a0b2e06a1bbe7339ca794657ae39f1e02 100644 --- a/test/Modules/lookup.cpp +++ b/test/Modules/lookup.cpp @@ -26,8 +26,8 @@ void f() { // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodules-cache-path=%t -fmodule-name=lookup_left_cxx %S/Inputs/module.map -verify // RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodules-cache-path=%t -fmodule-name=lookup_right_cxx %S/Inputs/module.map -verify -// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t %s -verify -// RUN: %clang_cc1 -fmodules -ast-print -x objective-c++ -fmodules-cache-path=%t %s | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -I %S/Inputs %s -verify +// RUN: %clang_cc1 -fmodules -ast-print -x objective-c++ -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix=CHECK-PRINT %s // FIXME: When we have a syntax for modules in C++, use that. // CHECK-PRINT: int *f0(int *); diff --git a/test/Modules/lookup.m b/test/Modules/lookup.m index 54c74913907d23bc30000f064d99c76a6f30c6d8..187e8763ca6398e100c007e46b6b9c18bebec9fe 100644 --- a/test/Modules/lookup.m +++ b/test/Modules/lookup.m @@ -1,8 +1,8 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -verify %s -// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodules-cache-path=%t %s | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs -verify %s +// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix=CHECK-PRINT %s @import lookup_left_objc; @import lookup_right_objc; diff --git a/test/Modules/macros.c b/test/Modules/macros.c index 541c95be58de76cb4c728f466fde19ac7141902c..954181372a6092e31b60ae80fae330c89050720d 100644 --- a/test/Modules/macros.c +++ b/test/Modules/macros.c @@ -3,8 +3,8 @@ // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_left %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros_right %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=macros %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t %s -// RUN: not %clang_cc1 -E -fmodules -x objective-c -fmodules-cache-path=%t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s +// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s +// RUN: not %clang_cc1 -E -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s | FileCheck -check-prefix CHECK-PREPROCESSED %s // FIXME: When we have a syntax for modules in C, use that. // These notes come from headers in modules, and are bogus. diff --git a/test/Modules/module-private.cpp b/test/Modules/module-private.cpp index 438dcab9841caef92cf23f3597be1ca44c4c0207..9213a0f20cbcad1d4ca4e41a55ae667add3bb13f 100644 --- a/test/Modules/module-private.cpp +++ b/test/Modules/module-private.cpp @@ -1,7 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -fmodule-name=module_private_left -emit-module %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -fmodule-name=module_private_right -emit-module %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t %s -verify +// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -I %S/Inputs %s -verify // FIXME: When we have a syntax for modules in C++, use that. @import module_private_left; diff --git a/test/Modules/objc-categories.m b/test/Modules/objc-categories.m index f08b13a78ab2a1d47fe3981acd00bdb3e3906eb7..a66ab8d631255db4e05dde752a0fd389ed06bd2e 100644 --- a/test/Modules/objc-categories.m +++ b/test/Modules/objc-categories.m @@ -4,7 +4,7 @@ // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify @import category_bottom; diff --git a/test/Modules/objc_redef.m b/test/Modules/objc_redef.m index f91124172f7632fa4d6177bc8d23d5f0bebe9222..28e47665f24f5fa46c9b6b0b9eb4a4276735f9c2 100644 --- a/test/Modules/objc_redef.m +++ b/test/Modules/objc_redef.m @@ -8,6 +8,6 @@ int test(id x) { // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=weird_objc %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify // expected-no-diagnostics diff --git a/test/Modules/redecl-namespaces.mm b/test/Modules/redecl-namespaces.mm index 93102c04bc3a2166dcb84f91c8ba4022bde2ac3e..203daa9a2bb01596702ef518289dfa279dbebc57 100644 --- a/test/Modules/redecl-namespaces.mm +++ b/test/Modules/redecl-namespaces.mm @@ -10,4 +10,4 @@ void test() { // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -emit-module -fmodule-name=redecl_namespaces_left %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c++ -fmodules-cache-path=%t -emit-module -fmodule-name=redecl_namespaces_right %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -w %s -verify diff --git a/test/Modules/redeclarations.m b/test/Modules/redeclarations.m index f210f37f3ab8b2fe75507c6413ed15df4414b9c0..11aca7597830d0f2e22bdddb719aa384a73e45c3 100644 --- a/test/Modules/redeclarations.m +++ b/test/Modules/redeclarations.m @@ -7,6 +7,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=redeclarations_right %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -verify +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify // expected-no-diagnostics diff --git a/test/Modules/redecls/main.m b/test/Modules/redecls/main.m index 9ec02b03f2cce9579412fd73cf759bedaa80717a..8236092956b3853e925b8b28241d0be3fd4a626a 100644 --- a/test/Modules/redecls/main.m +++ b/test/Modules/redecls/main.m @@ -1,8 +1,8 @@ // RUN: rm -rf %t.mcp // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=a %S/module.map -fmodules-cache-path=%t.mcp // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=b %S/module.map -fmodules-cache-path=%t.mcp -// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t1.pch -fmodules-cache-path=%t.mcp -// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t2.pch -include-pch %t1.pch -fmodules-cache-path=%t.mcp +// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t1.pch -fmodules-cache-path=%t.mcp -I %S +// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t2.pch -include-pch %t1.pch -fmodules-cache-path=%t.mcp -I %S // RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -fmodules-cache-path=%t.mcp -verify #ifndef HEADER1