[PATCH] D61707: [Preprocessor] Fix crash emitting note with framework location for "file not found" error.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 27 12:14:33 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rC361779: [Preprocessor] Fix crash emitting note with framework location for "file not… (authored by vsapsai, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D61707?vs=200864&id=201559#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61707

Files:
  include/clang/Lex/HeaderSearch.h
  lib/Lex/HeaderSearch.cpp
  test/Preprocessor/Inputs/include-header-missing-in-framework/TestFramework.hmap.json
  test/Preprocessor/include-header-missing-in-framework-with-headermap.c


Index: include/clang/Lex/HeaderSearch.h
===================================================================
--- include/clang/Lex/HeaderSearch.h
+++ include/clang/Lex/HeaderSearch.h
@@ -392,8 +392,9 @@
   /// true.
   ///
   /// \param IsFrameworkFound If non-null, will be set to true if a framework is
-  /// found in any of searched SearchDirs. Doesn't guarantee the requested file
-  /// is found.
+  /// found in any of searched SearchDirs. Will be set to false if a framework
+  /// is found only through header maps. Doesn't guarantee the requested file is
+  /// found.
   const FileEntry *LookupFile(
       StringRef Filename, SourceLocation IncludeLoc, bool isAngled,
       const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir,
Index: test/Preprocessor/include-header-missing-in-framework-with-headermap.c
===================================================================
--- test/Preprocessor/include-header-missing-in-framework-with-headermap.c
+++ test/Preprocessor/include-header-missing-in-framework-with-headermap.c
@@ -0,0 +1,20 @@
+// RUN: rm -f %t.hmap
+// RUN: %hmaptool write %S/Inputs/include-header-missing-in-framework/TestFramework.hmap.json %t.hmap
+// RUN: %clang_cc1 -fsyntax-only -F %S/Inputs -I %t.hmap -verify %s -DLATE_REMAPPING
+// RUN: %clang_cc1 -fsyntax-only -I %t.hmap -F %S/Inputs -verify %s
+
+// The test is similar to 'include-header-missing-in-framework.c' but covers
+// the case when a header is remapped to a framework-like path with a .hmap
+// file. And we can find the framework but not the header.
+
+#ifdef LATE_REMAPPING
+// Framework is found before remapping.
+#include <TestFramework/BeforeRemapping.h>
+// expected-error at -1 {{'TestFramework/BeforeRemapping.h' file not found}}
+// expected-note at -2 {{did not find header 'BeforeRemapping.h' in framework 'TestFramework' (loaded from}}
+
+#else
+// Framework is found after remapping.
+#include "RemappedHeader.h"
+// expected-error at -1 {{'RemappedHeader.h' file not found}}
+#endif // LATE_REMAPPING
Index: test/Preprocessor/Inputs/include-header-missing-in-framework/TestFramework.hmap.json
===================================================================
--- test/Preprocessor/Inputs/include-header-missing-in-framework/TestFramework.hmap.json
+++ test/Preprocessor/Inputs/include-header-missing-in-framework/TestFramework.hmap.json
@@ -0,0 +1,7 @@
+{
+  "mappings" :
+    {
+     "RemappedHeader.h" : "TestFramework/RemappedHeader.h",
+     "TestFramework/BeforeRemapping.h" : "TestFramework/AfterRemapping.h"
+    }
+}
Index: lib/Lex/HeaderSearch.cpp
===================================================================
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -869,7 +869,10 @@
         *IsMapped = true;
     }
     if (IsFrameworkFound)
-      *IsFrameworkFound |= IsFrameworkFoundInDir;
+      // Because we keep a filename remapped for subsequent search directory
+      // lookups, ignore IsFrameworkFoundInDir after the first remapping and not
+      // just for remapping in a current search directory.
+      *IsFrameworkFound |= (IsFrameworkFoundInDir && !CacheLookup.MappedName);
     if (!FE) continue;
 
     CurDir = &SearchDirs[i];


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61707.201559.patch
Type: text/x-patch
Size: 3190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190527/9d6f5ab3/attachment.bin>


More information about the cfe-commits mailing list