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) { 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 +_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