From 7bd78a910a58fc1427779b6d3dfc46b2f836b74e 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 llvm-svn: 205071 --- clang/include/clang/Lex/HeaderSearch.h | 5 +++++ clang/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 + clang/test/Preprocessor/headermap-rel2.c | 13 +++++++++++++ 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 clang/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h create mode 100644 clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap create mode 100644 clang/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h create mode 100644 clang/test/Preprocessor/headermap-rel2.c diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h index 23be92771567..c3af6335a00e 100644 --- a/clang/include/clang/Lex/HeaderSearch.h +++ b/clang/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/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index e9f6bb3ac012..f08102470693 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/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/clang/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h b/clang/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h new file mode 100644 index 000000000000..ab2a05dbbf84 --- /dev/null +++ b/clang/test/Preprocessor/Inputs/headermap-rel2/Product/someheader.h @@ -0,0 +1 @@ +#define A 1 diff --git a/clang/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap b/clang/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/clang/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h b/clang/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h new file mode 100644 index 000000000000..ab2a05dbbf84 --- /dev/null +++ b/clang/test/Preprocessor/Inputs/headermap-rel2/system/usr/include/someheader.h @@ -0,0 +1 @@ +#define A 1 diff --git a/clang/test/Preprocessor/headermap-rel2.c b/clang/test/Preprocessor/headermap-rel2.c new file mode 100644 index 000000000000..e29e5ee6caf4 --- /dev/null +++ b/clang/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.34.1