r197165 - [Modules] Don't parse any module map if modules are disabled.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Dec 12 08:08:33 PST 2013
Author: akirtzidis
Date: Thu Dec 12 10:08:33 2013
New Revision: 197165
URL: http://llvm.org/viewvc/llvm-project?rev=197165&view=rev
Log:
[Modules] Don't parse any module map if modules are disabled.
Fixes rdar://15644663.
Added:
cfe/trunk/test/Modules/unnecessary-module-map-parsing/
cfe/trunk/test/Modules/unnecessary-module-map-parsing.c
cfe/trunk/test/Modules/unnecessary-module-map-parsing/a1.h
cfe/trunk/test/Modules/unnecessary-module-map-parsing/module.map
Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Lex/HeaderSearch.cpp
Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=197165&r1=197164&r2=197165&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Thu Dec 12 10:08:33 2013
@@ -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.
///
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=197165&r1=197164&r2=197165&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Dec 12 10:08:33 2013
@@ -59,6 +59,8 @@ HeaderSearch::HeaderSearch(IntrusiveRefC
NumIncluded = 0;
NumMultiIncludeFileOptzn = 0;
NumFrameworkLookups = NumSubFrameworkLookups = 0;
+
+ EnabledModules = LangOpts.Modules;
}
HeaderSearch::~HeaderSearch() {
@@ -953,6 +955,9 @@ StringRef HeaderSearch::getUniqueFramewo
bool HeaderSearch::hasModuleMap(StringRef FileName,
const DirectoryEntry *Root,
bool IsSystem) {
+ if (!enabledModules())
+ return false;
+
SmallVector<const DirectoryEntry *, 2> FixUpDirectories;
StringRef DirName = FileName;
Added: cfe/trunk/test/Modules/unnecessary-module-map-parsing.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/unnecessary-module-map-parsing.c?rev=197165&view=auto
==============================================================================
--- cfe/trunk/test/Modules/unnecessary-module-map-parsing.c (added)
+++ cfe/trunk/test/Modules/unnecessary-module-map-parsing.c Thu Dec 12 10:08:33 2013
@@ -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"
Added: cfe/trunk/test/Modules/unnecessary-module-map-parsing/a1.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/unnecessary-module-map-parsing/a1.h?rev=197165&view=auto
==============================================================================
--- cfe/trunk/test/Modules/unnecessary-module-map-parsing/a1.h (added)
+++ cfe/trunk/test/Modules/unnecessary-module-map-parsing/a1.h Thu Dec 12 10:08:33 2013
@@ -0,0 +1 @@
+void f() {}
Added: cfe/trunk/test/Modules/unnecessary-module-map-parsing/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/unnecessary-module-map-parsing/module.map?rev=197165&view=auto
==============================================================================
--- cfe/trunk/test/Modules/unnecessary-module-map-parsing/module.map (added)
+++ cfe/trunk/test/Modules/unnecessary-module-map-parsing/module.map Thu Dec 12 10:08:33 2013
@@ -0,0 +1,3 @@
+module a {
+ header "unknown.h"
+}
More information about the cfe-commits
mailing list