From 8a2438411e851ea771e6d8a8046aae542fe6a5c9 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 4 Sep 2018 13:02:48 -0700 Subject: [PATCH] Add clang.excludeArgs and rename diagnostics.onType to onChange --- src/clang_complete.cc | 2 +- src/config.h | 17 ++++++++++------- src/project.cc | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/clang_complete.cc b/src/clang_complete.cc index 9bb37b02..2bf26e9f 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -600,7 +600,7 @@ void DiagnosticQueryMain(ClangCompleteManager *manager) { // Fetching the completion request blocks until we have a request. ClangCompleteManager::DiagnosticRequest request = manager->diagnostic_request_.Dequeue(); - if (!g_config->diagnostics.onType) + if (!g_config->diagnostics.onChange) continue; std::string path = request.document.uri.GetPath(); diff --git a/src/config.h b/src/config.h index da94e0e3..3a134b25 100644 --- a/src/config.h +++ b/src/config.h @@ -47,6 +47,9 @@ struct Config { SerializeFormat cacheFormat = SerializeFormat::Binary; struct Clang { + // Arguments that should be excluded, e.g. ["-fopenmp", "-Wall"] + std::vector excludeArgs; + // Additional arguments to pass to clang. std::vector extraArgs; @@ -137,11 +140,11 @@ struct Config { // xxx: at most every xxx milliseconds int frequencyMs = 0; - // If true, diagnostics will be reported in textDocument/didOpen. - bool onOpen = true; + // If true, diagnostics will be reported for textDocument/didChange. + bool onChange = true; - // If true, diagnostics from typing will be reported. - bool onType = true; + // If true, diagnostics will be reported for textDocument/didOpen. + bool onOpen = true; std::vector whitelist; } diagnostics; @@ -219,15 +222,15 @@ struct Config { int maxNum = 2000; } xref; }; -MAKE_REFLECT_STRUCT(Config::Clang, extraArgs, resourceDir); +MAKE_REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, resourceDir); MAKE_REFLECT_STRUCT(Config::ClientCapability, snippetSupport); MAKE_REFLECT_STRUCT(Config::CodeLens, localVariables); MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, dropOldRequests, detailedLabel, filterAndSort, includeBlacklist, includeMaxPathSize, includeSuffixWhitelist, includeWhitelist); -MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, frequencyMs, onOpen, - onType, whitelist) +MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, frequencyMs, onChange, + onOpen, whitelist) MAKE_REFLECT_STRUCT(Config::Highlight, lsRanges, blacklist, whitelist) MAKE_REFLECT_STRUCT(Config::Index, blacklist, comments, enabled, multiVersion, multiVersionBlacklist, multiVersionWhitelist, onDidChange, diff --git a/src/project.cc b/src/project.cc index 708cecd6..7a4b338f 100644 --- a/src/project.cc +++ b/src/project.cc @@ -20,6 +20,7 @@ using namespace ccls; #include #include #include +#include #include #include using namespace clang; @@ -84,7 +85,7 @@ struct ProjectProcessor { args.push_back(arg.substr(5)); } else if (arg == "%clang") { args.push_back(lang == LanguageId::Cpp ? "clang++" : "clang"); - } else { + } else if (!llvm::is_contained(g_config->clang.excludeArgs, arg)) { args.push_back(arg); } }