[PATCH] D107921: [Modules] Fix bug where header resolution in modules doesn't work when compiling with relative paths.
akhuang updated this revision to Diff 366344. akhuang added a comment. undo previous change Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D107921/new/ https://reviews.llvm.org/D107921 Files: clang/lib/Lex/HeaderSearch.cpp Index: clang/lib/Lex/HeaderSearch.cpp === --- clang/lib/Lex/HeaderSearch.cpp +++ 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; Index: clang/lib/Lex/HeaderSearch.cpp === --- clang/lib/Lex/HeaderSearch.cpp +++ 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; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D107921: [Modules] Fix bug where header resolution in modules doesn't work when compiling with relative paths.
akhuang updated this revision to Diff 366153. akhuang added a comment. add case for include_nexts; I don't entirely understand this part of the code so not sure if it's what we want, but it seems to make building with -no-canonical-prefixes happier Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D107921/new/ https://reviews.llvm.org/D107921 Files: clang/lib/Lex/HeaderSearch.cpp Index: clang/lib/Lex/HeaderSearch.cpp === --- clang/lib/Lex/HeaderSearch.cpp +++ clang/lib/Lex/HeaderSearch.cpp @@ -819,9 +819,24 @@ 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) { +// If this was an #include_next "/file", fail. +if (!FromDir) + return None; + +FE = getFileAndSuggestModule( +Filename, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader, +RequestingModule, SuggestedModule); + } + + if (FE) { if (!Includer) { assert(First && "only first includer can have no file"); return FE; Index: clang/lib/Lex/HeaderSearch.cpp === --- clang/lib/Lex/HeaderSearch.cpp +++ clang/lib/Lex/HeaderSearch.cpp @@ -819,9 +819,24 @@ 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) { +// If this was an #include_next "/file", fail. +if (!FromDir) + return None; + +FE = getFileAndSuggestModule( +Filename, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader, +RequestingModule, SuggestedModule); + } + + if (FE) { if (!Includer) { assert(First && "only first includer can have no file"); return FE; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D107921: [Modules] Fix bug where header resolution in modules doesn't work when compiling with relative paths.
akhuang created this revision. akhuang requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Currently when searching for header files (with relative paths) we concatenate the path to the module map with the header filename. However when searching for system headers it seems like we should start from the current directory and not the path to the module map. No test added because I'm not sure there's a way to use relative paths to system headers in the lit tests. Bug: https://bugs.llvm.org/show_bug.cgi?id=47209 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D107921 Files: clang/lib/Lex/HeaderSearch.cpp Index: clang/lib/Lex/HeaderSearch.cpp === --- clang/lib/Lex/HeaderSearch.cpp +++ 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; Index: clang/lib/Lex/HeaderSearch.cpp === --- clang/lib/Lex/HeaderSearch.cpp +++ 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; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits