r230308 - Don't load Framework module.map files when searching subdirectories

Ben Langmuir blangmuir at apple.com
Mon Feb 23 20:58:16 PST 2015


Author: benlangmuir
Date: Mon Feb 23 22:58:15 2015
New Revision: 230308

URL: http://llvm.org/viewvc/llvm-project?rev=230308&view=rev
Log:
Don't load Framework module.map files when searching subdirectories

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.

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

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=230308&r1=230307&r2=230308&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Mon Feb 23 22:58:15 2015
@@ -1353,8 +1353,10 @@ void HeaderSearch::loadSubdirectoryModul
   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);

Modified: cfe/trunk/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h?rev=230308&r1=230307&r2=230308&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h Mon Feb 23 22:58:15 2015
@@ -1 +1,2 @@
+ at import Module; // Don't cause redefinition error.
 void will_be_found2(void);

Modified: cfe/trunk/test/Modules/modulemap-locations.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/modulemap-locations.m?rev=230308&r1=230307&r2=230308&view=diff
==============================================================================
--- cfe/trunk/test/Modules/modulemap-locations.m (original)
+++ cfe/trunk/test/Modules/modulemap-locations.m Mon Feb 23 22:58:15 2015
@@ -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;

Modified: cfe/trunk/test/Modules/self-import-header.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/self-import-header.m?rev=230308&r1=230307&r2=230308&view=diff
==============================================================================
--- cfe/trunk/test/Modules/self-import-header.m (original)
+++ cfe/trunk/test/Modules/self-import-header.m Mon Feb 23 22:58:15 2015
@@ -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;





More information about the cfe-commits mailing list