[Tooling] Clear the PreambleSrcLocCache when preamble is discarded during reparsing
authorAlex Lorenz <arphaman@gmail.com>
Mon, 12 Mar 2018 19:36:29 +0000 (19:36 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Mon, 12 Mar 2018 19:36:29 +0000 (19:36 +0000)
This ensures that diagnostics are not remapped to incorrect preamble locations after
the second reparse with a remapped header file occurs.

rdar://37502480

llvm-svn: 327322

clang/lib/Frontend/ASTUnit.cpp
clang/test/Index/Inputs/reparse-issue.h [new file with mode: 0644]
clang/test/Index/Inputs/reparse-issue.h-0 [new file with mode: 0644]
clang/test/Index/Inputs/reparse-issue.h-1 [new file with mode: 0644]
clang/test/Index/reparsed-live-issue.cpp [new file with mode: 0644]

index 473da22..d73bc28 100644 (file)
@@ -1259,6 +1259,7 @@ ASTUnit::getMainBufferWithPrecompiledPreamble(
       Preamble.reset();
       PreambleDiagnostics.clear();
       TopLevelDeclsInPreamble.clear();
+      PreambleSrcLocCache.clear();
       PreambleRebuildCounter = 1;
     }
   }
diff --git a/clang/test/Index/Inputs/reparse-issue.h b/clang/test/Index/Inputs/reparse-issue.h
new file mode 100644 (file)
index 0000000..79f1d88
--- /dev/null
@@ -0,0 +1,3 @@
+
+asdf;
+
diff --git a/clang/test/Index/Inputs/reparse-issue.h-0 b/clang/test/Index/Inputs/reparse-issue.h-0
new file mode 100644 (file)
index 0000000..f004abf
--- /dev/null
@@ -0,0 +1,4 @@
+//
+//
+asdf;
+
diff --git a/clang/test/Index/Inputs/reparse-issue.h-1 b/clang/test/Index/Inputs/reparse-issue.h-1
new file mode 100644 (file)
index 0000000..9f9dde8
--- /dev/null
@@ -0,0 +1,5 @@
+//
+//
+//
+asdf;
+
diff --git a/clang/test/Index/reparsed-live-issue.cpp b/clang/test/Index/reparsed-live-issue.cpp
new file mode 100644 (file)
index 0000000..fcf22cd
--- /dev/null
@@ -0,0 +1,4 @@
+// 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
+#include "Inputs/reparse-issue.h"
+
+// CHECK: reparse-issue.h:4:1:{1:1-1:1}: error: C++ requires a type specifier for all declarations