summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdServer.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2019-01-22 09:39:05 +0000
committerHaojian Wu <hokein@google.com>2019-01-22 09:39:05 +0000
commit1ca0c58c8152ecfb2a47f91080b64eae7710dadb (patch)
treecf967fe3f5caa6c4745dbf4a404a55b015d85cc5 /clang-tools-extra/clangd/ClangdServer.cpp
parentbd374b27cc33567b0a0522ee511fc1ea9f0bb1df (diff)
downloadbcm5719-llvm-1ca0c58c8152ecfb2a47f91080b64eae7710dadb.tar.gz
bcm5719-llvm-1ca0c58c8152ecfb2a47f91080b64eae7710dadb.zip
[clangd] Support clang-tidy configuration in clangd.
Summary: This patch adds some basic supports for clang-tidy configurations in clangd: - clangd will respect .clang-tidy configurations for each file - we don't aim to support all clang-tidy options in clangd, only a small subset of condfigurations (options related to which checks will be enabled) are supported. - add a `clang-tidy-checks` CLI option that can override options from .clang-tidy file Reviewers: ilya-biryukov, sammccall Reviewed By: sammccall Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55256 llvm-svn: 351792
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
-rw-r--r--clang-tools-extra/clangd/ClangdServer.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index d70321da15c..5f494210ac3 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -105,6 +105,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
DynamicIdx(Opts.BuildDynamicSymbolIndex
? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
: nullptr),
+ ClangTidyOptProvider(Opts.ClangTidyOptProvider),
WorkspaceRoot(Opts.WorkspaceRoot),
PCHs(std::make_shared<PCHContainerOperations>()),
// Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -140,13 +141,16 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
+ tidy::ClangTidyOptions Options = tidy::ClangTidyOptions::getDefaults();
+ if (ClangTidyOptProvider)
+ Options = ClangTidyOptProvider->getOptions(File);
// FIXME: some build systems like Bazel will take time to preparing
// environment to build the file, it would be nice if we could emit a
// "PreparingBuild" status to inform users, it is non-trivial given the
// current implementation.
- WorkScheduler.update(File,
- ParseInputs{getCompileCommand(File),
- FSProvider.getFileSystem(), Contents.str()},
+ WorkScheduler.update(File, ParseInputs{getCompileCommand(File),
+ FSProvider.getFileSystem(),
+ Contents.str(), Options},
WantDiags);
}
OpenPOWER on IntegriCloud