From e76a336f1959d48673f47c658acfbfa0ee2b6581 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 6 Feb 2018 23:55:02 -0800 Subject: [PATCH] Remove --debug in favor of LIBCLANG_DISABLE_CRASH_RECOVERY=1 ci/before_deploy.sh: Use the latest libclang.so --- ci/before_deploy.sh | 4 ++-- src/command_line.cc | 7 ------- src/indexer.cc | 18 +----------------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh index c5241dac..4f1b75b7 100755 --- a/ci/before_deploy.sh +++ b/ci/before_deploy.sh @@ -23,10 +23,10 @@ esac pkg=$(mktemp -d) mkdir "$pkg/$name" -rsync -rtLR bin "./${libclang[0]}" ./lib/clang+llvm-*/lib/clang/*/include "$pkg/$name" +rsync -rtLR bin "./${libclang[-1]}" ./lib/clang+llvm-*/lib/clang/*/include "$pkg/$name" cd "$pkg" -strip "$strip_option" "$name/bin/cquery" "$name/${libclang[0]}" +strip "$strip_option" "$name/bin/cquery" "$name/${libclang[-1]}" case $(uname -s) in Darwin) tar -cf filelist --format=mtree --options="!all,time,mode,type" "$name" diff --git a/src/command_line.cc b/src/command_line.cc index 5c4850da..dfe9f78c 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -51,7 +51,6 @@ // items per second completed and scales up/down number of running threads. std::string g_init_options; -bool g_debug; namespace { @@ -88,9 +87,6 @@ Mode: Run as a language server over stdin and stdout Other command line options: - --debug Disable libclang crash recovery so that in case of libclang or - indexer callback issue, the process will crash and we can - get a stack trace. --init Override client provided initialization options https://github.com/cquery-project/cquery/wiki/Initialization-options @@ -444,7 +440,6 @@ int main(int argc, char** argv) { &stdout_waiter); PlatformInit(); - g_debug = HasOption(options, "--debug"); IndexInit(); bool language_server = true; @@ -463,7 +458,6 @@ int main(int argc, char** argv) { } if (HasOption(options, "--test-unit")) { - g_debug = true; language_server = false; doctest::Context context; context.applyCommandLine(argc, argv); @@ -473,7 +467,6 @@ int main(int argc, char** argv) { } if (HasOption(options, "--test-index")) { - g_debug = true; language_server = false; if (!RunIndexTests(options["--test-index"], !HasOption(options, "--ci"))) return 1; diff --git a/src/indexer.cc b/src/indexer.cc index dcd4b165..3046b8a3 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -18,9 +18,6 @@ // TODO: See if we can use clang_indexLoc_getFileLocation to get a type ref on // |Foobar| in DISALLOW_COPY(Foobar) -// Defined in command_line.cc -extern bool g_debug; - #if CINDEX_VERSION >= 47 #define CINDEX_HAVE_PRETTY 1 #endif @@ -699,15 +696,6 @@ void UniqueAdd(std::vector& values, T value) { IdCache::IdCache(const std::string& primary_file) : primary_file(primary_file) {} -template -bool Contains(const std::vector& vec, const T& element) { - for (const T& entry : vec) { - if (entry == element) - return true; - } - return false; -} - void OnIndexDiagnostic(CXClientData client_data, CXDiagnosticSet diagnostics, void* reserved) { @@ -2193,10 +2181,6 @@ optional>> ParseWithTu( 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. int index_result = clang_indexTranslationUnit( index_action, ¶m, &callback, sizeof(IndexerCallbacks), @@ -2268,7 +2252,7 @@ void ConcatTypeAndName(std::string& type, const std::string& name) { void IndexInit() { clang_enableStackTraces(); - if (!g_debug) + if (!getenv("LIBCLANG_DISABLE_CRASH_RECOVERY")) clang_toggleCrashRecovery(1); }