Skip to content
Snippets Groups Projects
Commit e637e4fc authored by Ben Langmuir's avatar Ben Langmuir
Browse files

Require a module.map file to load a module

Removes some old code that allowed a module to be loaded from a pcm file
even if the module.map could not be found.  Also update a number of
tests that relied on the old behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199852 91177308-0d34-0410-b5e6-96231b3b80d8
parent 0bdb5479
No related branches found
No related tags found
No related merge requests found
Showing with 31 additions and 44 deletions
...@@ -1129,11 +1129,15 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, ...@@ -1129,11 +1129,15 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
} else { } else {
// Search for a module with the given name. // Search for a module with the given name.
Module = PP->getHeaderSearchInfo().lookupModule(ModuleName); Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
std::string ModuleFileName; if (!Module) {
if (Module) { getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(Module); << ModuleName
} else << SourceRange(ImportLoc, ModuleNameLoc);
ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(ModuleName); ModuleBuildFailed = true;
return ModuleLoadResult();
}
std::string ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(Module);
// If we don't already have an ASTReader, create one now. // If we don't already have an ASTReader, create one now.
if (!ModuleManager) { if (!ModuleManager) {
...@@ -1180,17 +1184,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, ...@@ -1180,17 +1184,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
case ASTReader::OutOfDate: case ASTReader::OutOfDate:
case ASTReader::Missing: { case ASTReader::Missing: {
// The module file is missing or out-of-date. Build it. // The module file is missing or out-of-date. Build it.
assert(Module && "missing module file");
// 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();
}
// Check whether there is a cycle in the module graph. // Check whether there is a cycle in the module graph.
ModuleBuildStack ModPath = getSourceManager().getModuleBuildStack(); ModuleBuildStack ModPath = getSourceManager().getModuleBuildStack();
ModuleBuildStack::iterator Pos = ModPath.begin(), PosEnd = ModPath.end(); ModuleBuildStack::iterator Pos = ModPath.begin(), PosEnd = ModPath.end();
...@@ -1267,13 +1261,6 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, ...@@ -1267,13 +1261,6 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
ModuleBuildFailed = true; ModuleBuildFailed = true;
return ModuleLoadResult(); 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. // Cache the result of this top-level module lookup for later.
Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first; Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;
......
...@@ -24,5 +24,5 @@ char *test_bar() { ...@@ -24,5 +24,5 @@ char *test_bar() {
// RUN: rm -rf %t // 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 -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
// RUN: rm -rf %t // 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 -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. // FIXME: When we have a syntax for modules in C, use that.
@import diag_pragma; @import diag_pragma;
......
...@@ -3,7 +3,7 @@ ...@@ -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_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_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-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 // 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. // FIXME: When we have a syntax for modules in C, use that.
......
...@@ -3,7 +3,7 @@ ...@@ -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_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_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-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. // FIXME: When we have a syntax for modules in C, use that.
@import diamond_bottom; @import diamond_bottom;
......
// RUN: rm -rf %t // 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 -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. // FIXME: When we have a syntax for modules in C, use that.
@import irgen; @import irgen;
......
// RUN: rm -rf %t // 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 -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 // Test redeclarations of functions where the original declaration is
// still hidden. // still hidden.
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
// RUN: rm -rf %t // 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: %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 // 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 // RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t.out
// FIXME: Clean up diagnostic text below and give it a location // FIXME: Clean up diagnostic text below and give it a location
......
...@@ -26,8 +26,8 @@ void f() { ...@@ -26,8 +26,8 @@ void f() {
// RUN: rm -rf %t // 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_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++ -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 -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 %s | FileCheck -check-prefix=CHECK-PRINT %s // 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. // FIXME: When we have a syntax for modules in C++, use that.
// CHECK-PRINT: int *f0(int *); // CHECK-PRINT: int *f0(int *);
......
// RUN: rm -rf %t // 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_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 -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 -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 %s | FileCheck -check-prefix=CHECK-PRINT %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_left_objc;
@import lookup_right_objc; @import lookup_right_objc;
......
...@@ -3,8 +3,8 @@ ...@@ -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_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_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 -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: %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 %s | FileCheck -check-prefix CHECK-PREPROCESSED %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. // FIXME: When we have a syntax for modules in C, use that.
// These notes come from headers in modules, and are bogus. // These notes come from headers in modules, and are bogus.
......
// RUN: rm -rf %t // 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_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 -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. // FIXME: When we have a syntax for modules in C++, use that.
@import module_private_left; @import module_private_left;
......
...@@ -4,7 +4,7 @@ ...@@ -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_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_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 -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; @import category_bottom;
......
...@@ -8,6 +8,6 @@ int test(id x) { ...@@ -8,6 +8,6 @@ int test(id x) {
// RUN: rm -rf %t // 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_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 -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 // expected-no-diagnostics
...@@ -10,4 +10,4 @@ void test() { ...@@ -10,4 +10,4 @@ void test() {
// RUN: rm -rf %t // 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_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 -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
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
// RUN: rm -rf %t // 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_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 -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 // expected-no-diagnostics
// RUN: rm -rf %t.mcp // 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=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 -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 %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 // 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 // RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -fmodules-cache-path=%t.mcp -verify
#ifndef HEADER1 #ifndef HEADER1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment