From bc28bfef45fbac9a2d658f32da8f6f2a0a6267ef Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 20 Jan 2018 22:55:29 -0800 Subject: [PATCH] Cleanup --- src/clang_cursor.cc | 2 +- src/clang_cursor.h | 5 +++-- src/indexer.cc | 3 +-- src/messages/initialize.cc | 4 +++- src/project.cc | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/clang_cursor.cc b/src/clang_cursor.cc index 612b7475..44a29907 100644 --- a/src/clang_cursor.cc +++ b/src/clang_cursor.cc @@ -39,7 +39,7 @@ bool ClangType::is_fundamental() const { cx_type.kind <= CXType_LastBuiltin; } -CXCursor ClangType::get_declaration() const { +ClangCursor ClangType::get_declaration() const { return clang_getTypeDeclaration(cx_type); } diff --git a/src/clang_cursor.h b/src/clang_cursor.h index b39289dd..6ff9e878 100644 --- a/src/clang_cursor.h +++ b/src/clang_cursor.h @@ -14,6 +14,8 @@ using Usr = uint64_t; Range ResolveCXSourceRange(const CXSourceRange& range, CXFile* cx_file = nullptr); +class ClangCursor; + class ClangType { public: ClangType(); @@ -24,8 +26,7 @@ class ClangType { // Returns true if this is a fundamental type like int. bool is_fundamental() const; - // ClangCursor is not defined so we have to return CXCursor - CXCursor get_declaration() const; + ClangCursor get_declaration() const; std::string get_usr() const; Usr get_usr_hash() const; std::string get_spelling() const; diff --git a/src/indexer.cc b/src/indexer.cc index 7fe0fb9b..75ac11ba 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -414,8 +414,7 @@ optional ResolveToDeclarationType(IndexFile* db, } ClangCursor declaration = - ClangCursor(type.get_declaration()) - .template_specialization_to_template_definition(); + type.get_declaration().template_specialization_to_template_definition(); CXString cx_usr = clang_getCursorUSR(declaration.cx_cursor); const char* str_usr = clang_getCString(cx_usr); if (!str_usr || str_usr[0] == '\0') { diff --git a/src/messages/initialize.cc b/src/messages/initialize.cc index 6a63bcb7..0d0ecca9 100644 --- a/src/messages/initialize.cc +++ b/src/messages/initialize.cc @@ -77,7 +77,9 @@ struct InitializeHandler : BaseMessageHandler { } g_index_builtin_types = config->index.builtin_types; // TODO Remove enableComments - g_enable_comments = std::max(config->enableComments, config->index.comments); + if (config->index.comments > 0) + config->enableComments = config->index.comments; + g_enable_comments = config->enableComments; // Check client version. if (config->clientVersion.has_value() && diff --git a/src/project.cc b/src/project.cc index 50612fe1..cdbf7718 100644 --- a/src/project.cc +++ b/src/project.cc @@ -262,7 +262,7 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry( // Using -fparse-all-comments enables documententation in the indexer and in // code completion. - if (init_opts->enableComments > 1 && + if (init_opts->index.comments > 1 && !AnyStartsWith(result.args, "-fparse-all-comments")) { result.args.push_back("-fparse-all-comments"); }