Add clang.excludeArgs and rename diagnostics.onType to onChange

This commit is contained in:
Fangrui Song 2018-09-04 13:02:48 -07:00
parent 0a51424c5c
commit 56da577df9
3 changed files with 13 additions and 9 deletions

View File

@ -612,7 +612,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();

View File

@ -59,6 +59,9 @@ struct Config {
SerializeFormat cacheFormat = SerializeFormat::Binary;
struct Clang {
// Arguments that should be excluded, e.g. ["-fopenmp", "-Wall"]
std::vector<std::string> excludeArgs;
// Additional arguments to pass to clang.
std::vector<std::string> extraArgs;
@ -149,11 +152,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<std::string> whitelist;
} diagnostics;
@ -231,15 +234,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,

View File

@ -32,6 +32,7 @@ using namespace ccls;
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Tooling/CompilationDatabase.h>
#include <llvm/ADT/ArrayRef.h>
#include <llvm/ADT/STLExtras.h>
#include <llvm/ADT/StringSet.h>
#include <llvm/Support/LineIterator.h>
using namespace clang;
@ -96,7 +97,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);
}
}