]> granicus.if.org Git - clang/commitdiff
Fix case-sensitivity of inferred framework modules
authorBen Langmuir <blangmuir@apple.com>
Mon, 14 Jul 2014 19:45:12 +0000 (19:45 +0000)
committerBen Langmuir <blangmuir@apple.com>
Mon, 14 Jul 2014 19:45:12 +0000 (19:45 +0000)
Just because we can open a directory named "COcoa.framework" doesn't
mean we should provide a "COcoa" module on a case-insensitive filesystem.

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

lib/Lex/ModuleMap.cpp
test/Modules/inferred-framework-case.m [new file with mode: 0644]

index a6d1d82a36756d5799af71e86452c2496c5c97c2..8fae9c933d336ea82e5667fe7eafaf570d571001 100644 (file)
@@ -624,6 +624,12 @@ ModuleMap::inferFrameworkModule(StringRef ModuleName,
     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.
diff --git a/test/Modules/inferred-framework-case.m b/test/Modules/inferred-framework-case.m
new file mode 100644 (file)
index 0000000..0443bed
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify -DA
+
+@import MOdule; // expected-error{{module 'MOdule' not found}}
+@import Module;