[PATCH] D75323: Support relative dest paths in headermap files

Simon Que via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 1 19:13:01 PST 2020


sque updated this revision to Diff 247540.
sque marked an inline comment as done.
sque added a comment.

Changed to generate hmap file using hmaptool.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75323/new/

https://reviews.llvm.org/D75323

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Headers/Inputs/headermap_relpath/empty.hmap.json
  clang/test/Headers/Inputs/include/empty.h
  clang/test/Headers/headermap_relpath.cpp


Index: clang/test/Headers/headermap_relpath.cpp
===================================================================
--- /dev/null
+++ clang/test/Headers/headermap_relpath.cpp
@@ -0,0 +1,13 @@
+// Test relative include paths in headermap files
+// ========================================================================== //
+
+// Inputs/empty.hmap contains: "empty/empty.h" -> "Inputs/include/empty.h"
+// Must run in the same directory as this file, so that the relative path can be
+// found.
+
+// 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 <empty/empty.h>
+int main() { return 0; }
Index: clang/test/Headers/Inputs/include/empty.h
===================================================================
--- /dev/null
+++ clang/test/Headers/Inputs/include/empty.h
@@ -0,0 +1 @@
+
Index: clang/test/Headers/Inputs/headermap_relpath/empty.hmap.json
===================================================================
--- /dev/null
+++ clang/test/Headers/Inputs/headermap_relpath/empty.hmap.json
@@ -0,0 +1 @@
+{"mappings":{"empty/empty.h":"include/empty.h"}}
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;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75323.247540.patch
Type: text/x-patch
Size: 1699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200302/b40179e9/attachment.bin>


More information about the cfe-commits mailing list