Index: clang/lib/Lex/HeaderSearch.cpp =================================================================== --- clang/lib/Lex/HeaderSearch.cpp +++ clang/lib/Lex/HeaderSearch.cpp @@ -415,7 +415,9 @@ FixupSearchPath(); return *Result; } - } else if (auto Res = HS.getFileMgr().getOptionalFileRef(Dest)) { + // If lookup failed, fall back to file lookup using relative path directly. + } + if (auto Res = HS.getFileMgr().getOptionalFileRef(Dest)) { FixupSearchPath(); return *Res; } Index: clang/test/Headers/Inputs/headermap_relpath/empty.hmap.json =================================================================== --- /dev/null +++ clang/test/Headers/Inputs/headermap_relpath/empty.hmap.json @@ -0,0 +1,5 @@ +{ + "mappings":{ + "empty/empty.h":"include/empty.h" + } +} Index: clang/test/Headers/Inputs/include/empty.h =================================================================== --- /dev/null +++ clang/test/Headers/Inputs/include/empty.h @@ -0,0 +1 @@ + Index: clang/test/Headers/headermap_relpath.cpp =================================================================== --- /dev/null +++ clang/test/Headers/headermap_relpath.cpp @@ -0,0 +1,9 @@ +// Test relative include paths in headermap files +// ========================================================================== // + +// RUN: rm -f %t.hmap +// RUN: %hmaptool write %S/Inputs/headermap_relpath/empty.hmap.json %t.hmap +// RUN: %clang_cc1 -fsyntax-only -I %t.hmap -I %S/Inputs %s + +#include +int main() { return 0; }