[PATCH] D36458: Fix crash when current lexer is nullptr

Ivan Donchevskii via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 08:33:57 PDT 2017


yvvan updated this revision to Diff 110978.
yvvan added a comment.

I have minimized the crash case and added simple test for it.


https://reviews.llvm.org/D36458

Files:
  lib/Parse/Parser.cpp
  test/Index/std-begin-error.cpp


Index: test/Index/std-begin-error.cpp
===================================================================
--- test/Index/std-begin-error.cpp
+++ test/Index/std-begin-error.cpp
@@ -0,0 +1,9 @@
+#ifndef RC_INVOKED
+#include <xmemory>
+_STD_BEGIN
+}
+#endif /* RC_INVOKED */
+
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -std=c++14 %S\std-begin-error.cpp 2> %t.err
+// RUN: not FileCheck < %t.err %s
+// CHECK: Failure: libclang crashed
Index: lib/Parse/Parser.cpp
===================================================================
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -516,8 +516,8 @@
 
   // Prime the lexer look-ahead.
   ConsumeToken();
-
-  PP.replayPreambleConditionalStack();
+  if (!PP.isCurrentLexer(nullptr))
+    PP.replayPreambleConditionalStack();
 }
 
 void Parser::LateTemplateParserCleanupCallback(void *P) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36458.110978.patch
Type: text/x-patch
Size: 876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170814/8e1038b6/attachment.bin>


More information about the cfe-commits mailing list