From c5e0194d63dbb0e53d0e95c996e56be690de5250 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 29 Mar 2014 03:22:54 +0000 Subject: [PATCH] [HeaderSearch] Make sure we clear the mapped name from the LookupFileCacheInfo when we reset the start point. rdar://16462455 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205071 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/HeaderSearch.h | 5 +++++ lib/Lex/HeaderSearch.cpp | 2 +- .../Inputs/headermap-rel2/Product/someheader.h | 1 + .../Inputs/headermap-rel2/project-headers.hmap | Bin 0 -> 108 bytes .../system/usr/include/someheader.h | 1 + test/Preprocessor/headermap-rel2.c | 13 +++++++++++++ 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h create mode 100644 test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap create mode 100644 test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h create mode 100644 test/Preprocessor/headermap-rel2.c diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index 23be927715..c3af6335a0 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -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 LookupFileCache; diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index e9f6bb3ac0..f081024706 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -700,7 +700,7 @@ const FileEntry *HeaderSearch::LookupFile( // 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; diff --git a/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h b/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h new file mode 100644 index 0000000000..ab2a05dbbf --- /dev/null +++ b/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h @@ -0,0 +1 @@ +#define A 1 diff --git a/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap b/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap new file mode 100644 index 0000000000000000000000000000000000000000..a0770fb251242a3eec33dda98beab4f3d38adef8 GIT binary patch literal 108 zcmXR&%*|kAU|{e7Vi3&DdU3;?O;17dNI;^O?=)Qr@`l++@<42FQB{FKt<5`9!r E0L3N_r2qf` literal 0 HcmV?d00001 diff --git a/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h b/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h new file mode 100644 index 0000000000..ab2a05dbbf --- /dev/null +++ b/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h @@ -0,0 +1 @@ +#define A 1 diff --git a/test/Preprocessor/headermap-rel2.c b/test/Preprocessor/headermap-rel2.c new file mode 100644 index 0000000000..e29e5ee6ca --- /dev/null +++ b/test/Preprocessor/headermap-rel2.c @@ -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 +#include -- 2.40.0