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;
/// 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.
///
/// \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.
///
NumIncluded = 0;
NumMultiIncludeFileOptzn = 0;
NumFrameworkLookups = NumSubFrameworkLookups = 0;
+
+ EnabledModules = LangOpts.Modules;
}
HeaderSearch::~HeaderSearch() {
bool HeaderSearch::hasModuleMap(StringRef FileName,
const DirectoryEntry *Root,
bool IsSystem) {
+ if (!enabledModules())
+ return false;
+
SmallVector<const DirectoryEntry *, 2> FixUpDirectories;
StringRef DirName = FileName;
--- /dev/null
+// 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"