sque updated this revision to Diff 247177.
sque edited the summary of this revision.
sque added a comment.

Added test


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/empty.hmap
  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,11 @@
+// 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: cd %S; %clang_cc1 -I %S/Inputs/empty.hmap %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/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/headermap_relpath.cpp
===================================================================
--- /dev/null
+++ clang/test/Headers/headermap_relpath.cpp
@@ -0,0 +1,11 @@
+// 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: cd %S; %clang_cc1 -I %S/Inputs/empty.hmap %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/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;
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to