1 //===--- TidyProvider.h - create options for running clang-tidy------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TIDYPROVIDER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TIDYPROVIDER_H
12 #include "../clang-tidy/ClangTidyOptions.h"
13 #include "support/ThreadsafeFS.h"
14 #include "llvm/ADT/FunctionExtras.h"
15 #include "llvm/ADT/StringRef.h"
20 /// A factory to modify a \ref tidy::ClangTidyOptions.
22 llvm::unique_function
<void(tidy::ClangTidyOptions
&,
23 /*Filename=*/llvm::StringRef
) const>;
25 /// A factory to modify a \ref tidy::ClangTidyOptions that doesn't hold any
27 using TidyProviderRef
= llvm::function_ref
<void(tidy::ClangTidyOptions
&,
28 /*Filename=*/llvm::StringRef
)>;
30 TidyProvider
combine(std::vector
<TidyProvider
> Providers
);
32 /// Provider that just sets the defaults.
33 TidyProvider
provideEnvironment();
35 /// Provider that will enable a nice set of default checks if none are
37 TidyProvider
provideDefaultChecks();
39 /// Provider the enables a specific set of checks and warnings as errors.
40 TidyProvider
addTidyChecks(llvm::StringRef Checks
,
41 llvm::StringRef WarningsAsErrors
= {});
43 /// Provider that will disable checks known to not work with clangd. \p
44 /// ExtraBadChecks specifies any other checks that should be always
47 disableUnusableChecks(llvm::ArrayRef
<std::string
> ExtraBadChecks
= {});
49 /// Provider that searches for .clang-tidy configuration files in the directory
51 TidyProvider
provideClangTidyFiles(ThreadsafeFS
&);
53 // Provider that uses clangd configuration files.
54 TidyProvider
provideClangdConfig();
56 tidy::ClangTidyOptions
getTidyOptionsForFile(TidyProviderRef Provider
,
57 llvm::StringRef Filename
);
59 /// Returns if \p Check is a registered clang-tidy check
60 /// \pre \p must not be empty, must not contain '*' or ',' or start with '-'.
61 bool isRegisteredTidyCheck(llvm::StringRef Check
);
63 /// Returns if \p Check is known-fast, known-slow, or its speed is unknown.
64 /// By default, only fast checks will run in clangd.
65 std::optional
<bool> isFastTidyCheck(llvm::StringRef Check
);
70 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_TIDYPROVIDER_H