--debug disables libclang crash recovery

This commit is contained in:
Fangrui Song 2018-01-24 23:58:16 -08:00
parent db1f707027
commit 403c892838
2 changed files with 9 additions and 0 deletions

View File

@ -2017,6 +2017,10 @@ optional<std::vector<std::unique_ptr<IndexFile>>> ParseWithTu(
CXIndexAction index_action = clang_IndexAction_create(index->cx_index); CXIndexAction index_action = clang_IndexAction_create(index->cx_index);
// NOTE: libclang re-enables crash recovery whenever a new index is created.
if (g_debug)
clang_toggleCrashRecovery(0);
// |index_result| is a CXErrorCode instance. // |index_result| is a CXErrorCode instance.
int index_result = clang_indexTranslationUnit( int index_result = clang_indexTranslationUnit(
index_action, &param, &callback, sizeof(IndexerCallbacks), index_action, &param, &callback, sizeof(IndexerCallbacks),
@ -2133,6 +2137,7 @@ void ClangSanityCheck() {
const unsigned kIndexOpts = 0; const unsigned kIndexOpts = 0;
CXIndexAction index_action = clang_IndexAction_create(index); CXIndexAction index_action = clang_IndexAction_create(index);
int index_param = 0; int index_param = 0;
clang_toggleCrashRecovery(0);
clang_indexTranslationUnit(index_action, &index_param, &callback, clang_indexTranslationUnit(index_action, &index_param, &callback,
sizeof(IndexerCallbacks), kIndexOpts, tu); sizeof(IndexerCallbacks), kIndexOpts, tu);
clang_IndexAction_dispose(index_action); clang_IndexAction_dispose(index_action);

View File

@ -108,6 +108,10 @@ TEST_SUITE("FindIncludeLine") {
} }
optional<char> ReadCharFromStdinBlocking() { optional<char> ReadCharFromStdinBlocking() {
// We do not use std::cin because it does not read bytes once stuck in
// cin.bad(). We can call cin.clear() but C++ iostream has other annoyance like
// std::{cin,cout} is tied by default, which causes undesired cout flush for
// cin operations.
int c = getchar(); int c = getchar();
if (c >= 0) if (c >= 0)
return c; return c;