diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -819,9 +819,19 @@ bool IncluderIsSystemHeader = Includer ? getFileInfo(Includer).DirInfo != SrcMgr::C_User : BuildSystemModule; - if (Optional FE = getFileAndSuggestModule( - TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader, - RequestingModule, SuggestedModule)) { + + Optional FE = getFileAndSuggestModule( + TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader, + RequestingModule, SuggestedModule); + + // If this is a system header, we should also search from the current + // working directory and not the directory of the module map. + if (!FE && IncluderIsSystemHeader) + FE = getFileAndSuggestModule( + Filename, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader, + RequestingModule, SuggestedModule); + + if (FE) { if (!Includer) { assert(First && "only first includer can have no file"); return FE;