r212975 - Fix case-sensitivity of inferred framework modules

Ben Langmuir blangmuir at apple.com
Mon Jul 14 12:45:12 PDT 2014


Author: benlangmuir
Date: Mon Jul 14 14:45:12 2014
New Revision: 212975

URL: http://llvm.org/viewvc/llvm-project?rev=212975&view=rev
Log:
Fix case-sensitivity of inferred framework modules

Just because we can open a directory named "COcoa.framework" doesn't
mean we should provide a "COcoa" module on a case-insensitive filesystem.

Added:
    cfe/trunk/test/Modules/inferred-framework-case.m
Modified:
    cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=212975&r1=212974&r2=212975&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon Jul 14 14:45:12 2014
@@ -624,6 +624,12 @@ ModuleMap::inferFrameworkModule(StringRe
     StringRef FrameworkDirName
       = SourceMgr.getFileManager().getCanonicalName(FrameworkDir);
 
+    // In case this is a case-insensitive filesystem, make sure the canonical
+    // directory name matches ModuleName exactly. Modules are case-sensitive.
+    // FIXME: we should be able to give a fix-it hint for the correct spelling.
+    if (llvm::sys::path::stem(FrameworkDirName) != ModuleName)
+      return nullptr;
+
     bool canInfer = false;
     if (llvm::sys::path::has_parent_path(FrameworkDirName)) {
       // Figure out the parent path.

Added: cfe/trunk/test/Modules/inferred-framework-case.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/inferred-framework-case.m?rev=212975&view=auto
==============================================================================
--- cfe/trunk/test/Modules/inferred-framework-case.m (added)
+++ cfe/trunk/test/Modules/inferred-framework-case.m Mon Jul 14 14:45:12 2014
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify -DA
+
+ at import MOdule; // expected-error{{module 'MOdule' not found}}
+ at import Module;





More information about the cfe-commits mailing list