]> granicus.if.org Git - clang/commitdiff
Don't load Framework module.map files when searching subdirectories
authorBen Langmuir <blangmuir@apple.com>
Tue, 24 Feb 2015 04:58:15 +0000 (04:58 +0000)
committerBen Langmuir <blangmuir@apple.com>
Tue, 24 Feb 2015 04:58:15 +0000 (04:58 +0000)
This would cause frameworks to have spurious "redefinition" errors if
they had both a (legacy) "module.map" and a (new) "module.modulemap" file and we
happened to do a sub-directory search in that directory using a
non-framework include path (e.g. -Ifoo/ -Ffoo/).  For migration
purposes it's very handy that the compiler will prefer the new spelling
of the filename and not look at the old one if it doesn't need to.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230308 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/HeaderSearch.cpp
test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h
test/Modules/modulemap-locations.m
test/Modules/self-import-header.m

index d6b255fb014e05ab285ed3e953b57138292c1162..b94cdbd1cbf6115815a57837abf487053146a646 100644 (file)
@@ -1353,8 +1353,10 @@ void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
   llvm::sys::path::native(SearchDir.getDir()->getName(), DirNative);
   for (llvm::sys::fs::directory_iterator Dir(DirNative.str(), EC), DirEnd;
        Dir != DirEnd && !EC; Dir.increment(EC)) {
-    loadModuleMapFile(Dir->path(), SearchDir.isSystemHeaderDirectory(),
-                      SearchDir.isFramework());
+    bool IsFramework = llvm::sys::path::extension(Dir->path()) == ".framework";
+    if (IsFramework == SearchDir.isFramework())
+      loadModuleMapFile(Dir->path(), SearchDir.isSystemHeaderDirectory(),
+                        SearchDir.isFramework());
   }
 
   SearchDir.setSearchedAllModuleMaps(true);
index 9dabfc089a1541f9d1faedfd28fa30be418cb3db..aa47ef47c484d3f53a807aa8b50470b0afc9734b 100644 (file)
@@ -1 +1,2 @@
+@import Module; // Don't cause redefinition error.
 void will_be_found2(void);
index 9acdcd63436bd20ca5aed887a57f767559bc666d..949c4786263d56ca759795ea04375fab5200a4c0 100644 (file)
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t 
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/ModuleMapLocations/Module_ModuleMap -I %S/Inputs/ModuleMapLocations/Both -F %S/Inputs/ModuleMapLocations -x objective-c -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/ModuleMapLocations/Module_ModuleMap -I %S/Inputs/ModuleMapLocations/Both -F %S/Inputs/ModuleMapLocations -I %S/Inputs/ModuleMapLocations -F %S/Inputs -x objective-c -fsyntax-only %s -verify
 
 // regular
 @import module_modulemap;
index 4dccd94050dc8f4a66ecf8fced8d9c2b212a761f..9b4bd5dee5201cf51dc9194bfcde0771f268ea90 100644 (file)
@@ -3,6 +3,7 @@
 // RUN: rm -rf %t
 // RUN: %clang -fsyntax-only -isysroot %S/Inputs/System/usr/include -fmodules -fmodules-cache-path=%t \
 // RUN:    -target x86_64-darwin \
-// RUN:    -F %S -I %S/Inputs/self-import-header %s -D__need_wint_t -Werror=implicit-function-declaration
+// RUN:    -F %S -F %S/Inputs/self-import-header -I %S/Inputs/self-import-header \
+// RUN:    %s -D__need_wint_t -Werror=implicit-function-declaration
 
 @import af;