Skip to content

Commit 6b75bba

Browse files
committed
[Tooling] Clear the PreambleSrcLocCache when preamble is discarded during reparsing
This ensures that diagnostics are not remapped to incorrect preamble locations after the second reparse with a remapped header file occurs. rdar://37502480 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327322 91177308-0d34-0410-b5e6-96231b3b80d8 (cherry picked from commit 07fe671aaad3e93b9f7178ae1309304a73a3b3bf) apple-llvm-split-commit: 1da4299dcc278446f356876e843423b55e4d9936 apple-llvm-split-dir: clang/
1 parent 6a2a58d commit 6b75bba

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,7 @@ ASTUnit::getMainBufferWithPrecompiledPreamble(
12501250
Preamble.reset();
12511251
PreambleDiagnostics.clear();
12521252
TopLevelDeclsInPreamble.clear();
1253+
PreambleSrcLocCache.clear();
12531254
PreambleRebuildCounter = 1;
12541255
}
12551256
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
asdf;
3+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//
2+
//
3+
asdf;
4+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
//
3+
//
4+
asdf;
5+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: CINDEXTEST_EDITING=1 LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-load-source-reparse 2 none -remap-file-0=%S/Inputs/reparse-issue.h,%S/Inputs/reparse-issue.h-0 -remap-file-1=%S/Inputs/reparse-issue.h,%S/Inputs/reparse-issue.h-1 -- %s 2>&1 | FileCheck %s
2+
#include "Inputs/reparse-issue.h"
3+
4+
// CHECK: reparse-issue.h:4:1:{1:1-1:1}: error: C++ requires a type specifier for all declarations

0 commit comments

Comments
 (0)