clang-tools 24.0.0git
ClangTidyFeatureModule.h
Go to the documentation of this file.
1//===--- ClangTidyFeatureModule.h - clang-tidy integration -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGTIDYFEATUREMODULE_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGTIDYFEATUREMODULE_H
11
12#include "FeatureModule.h"
13#include "TidyProvider.h"
14#include <memory>
15#include <mutex>
16#include <utility>
17
18namespace clang {
19namespace clangd {
20
21/// Runs clang-tidy checks as part of clangd's AST build.
23public:
24 /// Construct explicitly with the application's clang-tidy options provider.
25 /// Takes ownership of the provider; an empty provider disables checks.
26 explicit ClangTidyFeatureModule(TidyProvider OptionsProvider) {
27 setProvider(std::move(OptionsProvider));
28 }
29
30 /// Swap provider snapshots, e.g. to temporarily override the configuration
31 /// for benchmarking and restore it afterwards. Existing listeners retain
32 /// their snapshot.
33 void swapProvider(std::shared_ptr<const TidyProvider> &OptionsProvider);
34
35 std::unique_ptr<ASTListener> astListeners() override;
36
37private:
38 void setProvider(TidyProvider OptionsProvider);
39
40 std::mutex ProviderMu;
41 std::shared_ptr<const TidyProvider> Provider;
42};
43
44} // namespace clangd
45} // namespace clang
46
47#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGTIDYFEATUREMODULE_H
ClangTidyFeatureModule(TidyProvider OptionsProvider)
Construct explicitly with the application's clang-tidy options provider.
void swapProvider(std::shared_ptr< const TidyProvider > &OptionsProvider)
Swap provider snapshots, e.g.
std::unique_ptr< ASTListener > astListeners() override
Can be called asynchronously before building an AST.
A FeatureModule contributes a vertical feature to clangd.
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
Definition AST.cpp:44
llvm::unique_function< void(tidy::ClangTidyOptions &, llvm::StringRef) const > TidyProvider
A factory to modify a tidy::ClangTidyOptions.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//