Disable serialization of clang_parseTranslationUnit2FullArgv

This commit is contained in:
Jacob Dufault 2017-11-29 20:23:34 -08:00
parent f4acde7588
commit 38ff70ebc3

View File

@ -17,8 +17,12 @@ namespace {
// We need to serialize requests to clang_parseTranslationUnit2FullArgv and // We need to serialize requests to clang_parseTranslationUnit2FullArgv and
// clang_reparseTranslationUnit. See // clang_reparseTranslationUnit. See
// https://github.com/jacobdufault/cquery/issues/43#issuecomment-347614504. // https://github.com/jacobdufault/cquery/issues/43#issuecomment-347614504.
std::mutex g_parse_translation_unit_mutex; //
std::mutex g_reparse_translation_unit_mutex; // NOTE: This is disabled because it effectively serializes indexing, as a huge
// chunk of indexing time is spent inside of these functions.
//
// std::mutex g_parse_translation_unit_mutex;
// std::mutex g_reparse_translation_unit_mutex;
void EmitDiagnostics(std::string path, CXTranslationUnit tu) { void EmitDiagnostics(std::string path, CXTranslationUnit tu) {
std::string output = "Fatal errors while trying to parse " + path + "\n"; std::string output = "Fatal errors while trying to parse " + path + "\n";
@ -86,7 +90,7 @@ std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Create(
CXTranslationUnit cx_tu; CXTranslationUnit cx_tu;
CXErrorCode error_code; CXErrorCode error_code;
{ {
std::lock_guard<std::mutex> lock(g_parse_translation_unit_mutex); // std::lock_guard<std::mutex> lock(g_parse_translation_unit_mutex);
error_code = clang_parseTranslationUnit2FullArgv( error_code = clang_parseTranslationUnit2FullArgv(
index->cx_index, filepath.c_str(), args.data(), (int)args.size(), index->cx_index, filepath.c_str(), args.data(), (int)args.size(),
unsaved_files.data(), (unsigned)unsaved_files.size(), flags, &cx_tu); unsaved_files.data(), (unsigned)unsaved_files.size(), flags, &cx_tu);
@ -125,7 +129,7 @@ std::unique_ptr<ClangTranslationUnit> ClangTranslationUnit::Reparse(
std::vector<CXUnsavedFile>& unsaved) { std::vector<CXUnsavedFile>& unsaved) {
int error_code; int error_code;
{ {
std::lock_guard<std::mutex> lock(g_reparse_translation_unit_mutex); // std::lock_guard<std::mutex> lock(g_reparse_translation_unit_mutex);
error_code = clang_reparseTranslationUnit( error_code = clang_reparseTranslationUnit(
tu->cx_tu, (unsigned)unsaved.size(), unsaved.data(), tu->cx_tu, (unsigned)unsaved.size(), unsaved.data(),
clang_defaultReparseOptions(tu->cx_tu)); clang_defaultReparseOptions(tu->cx_tu));