r204368 - Prevent lookup of subframework modules by name without parent framework

Ben Langmuir blangmuir at apple.com
Thu Mar 20 11:27:27 PDT 2014


Author: benlangmuir
Date: Thu Mar 20 13:27:26 2014
New Revision: 204368

URL: http://llvm.org/viewvc/llvm-project?rev=204368&view=rev
Log:
Prevent lookup of subframework modules by name without parent framework

We were 'allowing' the following import
@import Sub;

where Sub is a subframework of Foo and we had a -F path inside
Foo.framework/Frameworks and no module map file for Sub. This would
later hit assertion failures in debug builds.

Now we should correctly diagnose this as a module not found error.

Added:
    cfe/trunk/test/Modules/subframework-from-intermediate-path.m
Modified:
    cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=204368&r1=204367&r2=204368&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Mar 20 13:27:26 2014
@@ -1223,30 +1223,9 @@ Module *HeaderSearch::loadFrameworkModul
     return ModMap.findModule(Name);
   }
 
-  // Figure out the top-level framework directory and the submodule path from
-  // that top-level framework to the requested framework.
-  SmallVector<std::string, 2> SubmodulePath;
-  SubmodulePath.push_back(Name);
-  const DirectoryEntry *TopFrameworkDir
-    = ::getTopFrameworkDir(FileMgr, Dir->getName(), SubmodulePath);
 
-
-  // Try to infer a module map from the top-level framework directory.
-  Module *Result = ModMap.inferFrameworkModule(SubmodulePath.back(), 
-                                               TopFrameworkDir,
-                                               IsSystem,
-                                               /*Parent=*/0);
-  if (!Result)
-    return 0;
-  
-  // Follow the submodule path to find the requested (sub)framework module
-  // within the top-level framework module.
-  SubmodulePath.pop_back();
-  while (!SubmodulePath.empty() && Result) {
-    Result = ModMap.lookupModuleQualified(SubmodulePath.back(), Result);
-    SubmodulePath.pop_back();
-  }
-  return Result;
+  // Try to infer a module map from the framework directory.
+  return ModMap.inferFrameworkModule(Name, Dir, IsSystem, /*Parent=*/0);
 }
 
 

Added: cfe/trunk/test/Modules/subframework-from-intermediate-path.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/subframework-from-intermediate-path.m?rev=204368&view=auto
==============================================================================
--- cfe/trunk/test/Modules/subframework-from-intermediate-path.m (added)
+++ cfe/trunk/test/Modules/subframework-from-intermediate-path.m Thu Mar 20 13:27:26 2014
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
+
+ at import DependsOnModule;
+ at import SubFramework; // expected-error{{module 'SubFramework' not found}}





More information about the cfe-commits mailing list