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 597338abbd
commit d2344265f5
3 changed files with 13 additions and 9 deletions

View File

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

View File

@ -47,6 +47,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;
@ -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<std::string> 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,

View File

@ -20,6 +20,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;
@ -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);
}
}