[Modules] Don't parse any module map if modules are disabled.

Fixes rdar://15644663.

llvm-svn: 197165
This commit is contained in:
Argyrios Kyrtzidis 2013-12-12 16:08:33 +00:00
parent 3497069784
commit 9955dbca2f
5 changed files with 23 additions and 0 deletions

View File

@ -232,6 +232,8 @@ class HeaderSearch {
unsigned NumMultiIncludeFileOptzn;
unsigned NumFrameworkLookups, NumSubFrameworkLookups;
bool EnabledModules;
// HeaderSearch doesn't support default or copy construction.
HeaderSearch(const HeaderSearch&) LLVM_DELETED_FUNCTION;
void operator=(const HeaderSearch&) LLVM_DELETED_FUNCTION;
@ -458,6 +460,9 @@ public:
/// FileEntry, uniquing them through the 'HeaderMaps' datastructure.
const HeaderMap *CreateHeaderMap(const FileEntry *FE);
/// Returns true if modules are enabled.
bool enabledModules() const { return EnabledModules; }
/// \brief Retrieve the name of the module file that should be used to
/// load the given module.
///
@ -491,6 +496,7 @@ public:
/// \brief Determine whether there is a module map that may map the header
/// with the given file name to a (sub)module.
/// Always returns false if modules are disabled.
///
/// \param Filename The name of the file.
///

View File

@ -59,6 +59,8 @@ HeaderSearch::HeaderSearch(IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts,
NumIncluded = 0;
NumMultiIncludeFileOptzn = 0;
NumFrameworkLookups = NumSubFrameworkLookups = 0;
EnabledModules = LangOpts.Modules;
}
HeaderSearch::~HeaderSearch() {
@ -953,6 +955,9 @@ StringRef HeaderSearch::getUniqueFrameworkName(StringRef Framework) {
bool HeaderSearch::hasModuleMap(StringRef FileName,
const DirectoryEntry *Root,
bool IsSystem) {
if (!enabledModules())
return false;
SmallVector<const DirectoryEntry *, 2> FixUpDirectories;
StringRef DirName = FileName;

View File

@ -0,0 +1,8 @@
// This checks that we are not parsing module maps if modules are not enabled.
// RUN: not %clang_cc1 -fmodules -I %S/unnecessary-module-map-parsing -fsyntax-only %s 2>&1 | FileCheck %s
// RUN: %clang_cc1 -I %S/unnecessary-module-map-parsing -fsyntax-only %s
// CHECK: error: header 'unknown.h' not found
#include "a1.h"

View File

@ -0,0 +1 @@
void f() {}

View File

@ -0,0 +1,3 @@
module a {
header "unknown.h"
}