r205071 - [HeaderSearch] Make sure we clear the mapped name from the LookupFileCacheInfo when we reset the start point.

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Mar 28 20:22:54 PDT 2014


Author: akirtzidis
Date: Fri Mar 28 22:22:54 2014
New Revision: 205071

URL: http://llvm.org/viewvc/llvm-project?rev=205071&view=rev
Log:
[HeaderSearch] Make sure we clear the mapped name from the LookupFileCacheInfo when we reset the start point.

rdar://16462455

Added:
    cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/
    cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/Product/
    cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h
    cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
    cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/system/
    cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/system/usr/
    cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/
    cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h
    cfe/trunk/test/Preprocessor/headermap-rel2.c
Modified:
    cfe/trunk/include/clang/Lex/HeaderSearch.h
    cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=205071&r1=205070&r2=205071&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Fri Mar 28 22:22:54 2014
@@ -203,6 +203,11 @@ class HeaderSearch {
 
     /// Default constructor -- Initialize all members with zero.
     LookupFileCacheInfo(): StartIdx(0), HitIdx(0), MappedName(nullptr) {}
+
+    void reset(unsigned StartIdx) {
+      this->StartIdx = StartIdx;
+      this->MappedName = nullptr;
+    }
   };
   llvm::StringMap<LookupFileCacheInfo, llvm::BumpPtrAllocator> LookupFileCache;
 

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=205071&r1=205070&r2=205071&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri Mar 28 22:22:54 2014
@@ -700,7 +700,7 @@ const FileEntry *HeaderSearch::LookupFil
     // Otherwise, this is the first query, or the previous query didn't match
     // our search start.  We will fill in our found location below, so prime the
     // start point value.
-    CacheLookup.StartIdx = i+1;
+    CacheLookup.reset(/*StartIdx=*/i+1);
   }
 
   SmallString<64> MappedName;

Added: cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h?rev=205071&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h (added)
+++ cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h Fri Mar 28 22:22:54 2014
@@ -0,0 +1 @@
+#define A 1

Added: cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap?rev=205071&view=auto
==============================================================================
Binary files cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap (added) and cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap Fri Mar 28 22:22:54 2014 differ

Added: cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h?rev=205071&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h (added)
+++ cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h Fri Mar 28 22:22:54 2014
@@ -0,0 +1 @@
+#define A 1

Added: cfe/trunk/test/Preprocessor/headermap-rel2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/headermap-rel2.c?rev=205071&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/headermap-rel2.c (added)
+++ cfe/trunk/test/Preprocessor/headermap-rel2.c Fri Mar 28 22:22:54 2014
@@ -0,0 +1,13 @@
+// This uses a headermap with this entry:
+//   someheader.h -> Product/someheader.h
+
+// RUN: %clang_cc1 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H 2> %t.out
+// RUN: FileCheck %s -input-file %t.out
+
+// CHECK: Product/someheader.h
+// CHECK: system/usr/include/someheader.h
+// CHECK: system/usr/include/someheader.h
+
+#include "someheader.h"
+#include <someheader.h>
+#include <someheader.h>





More information about the cfe-commits mailing list