diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index a6d1d82a3675..8fae9c933d33 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -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/clang/test/Modules/inferred-framework-case.m b/clang/test/Modules/inferred-framework-case.m new file mode 100644 index 000000000000..0443bedcaf86 --- /dev/null +++ b/clang/test/Modules/inferred-framework-case.m @@ -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;