clang-tools 20.0.0git
TidyProvider.h
Go to the documentation of this file.
1//===--- TidyProvider.h - create options for running clang-tidy------------===//
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_TIDYPROVIDER_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TIDYPROVIDER_H
11
12#include "../clang-tidy/ClangTidyOptions.h"
14#include "llvm/ADT/FunctionExtras.h"
15#include "llvm/ADT/StringRef.h"
16
17namespace clang {
18namespace clangd {
19
20/// A factory to modify a \ref tidy::ClangTidyOptions.
22 llvm::unique_function<void(tidy::ClangTidyOptions &,
23 /*Filename=*/llvm::StringRef) const>;
24
25/// A factory to modify a \ref tidy::ClangTidyOptions that doesn't hold any
26/// state.
27using TidyProviderRef = llvm::function_ref<void(tidy::ClangTidyOptions &,
28 /*Filename=*/llvm::StringRef)>;
29
30TidyProvider combine(std::vector<TidyProvider> Providers);
31
32/// Provider that just sets the defaults.
34
35/// Provider that will enable a nice set of default checks if none are
36/// specified.
38
39/// Provider the enables a specific set of checks and warnings as errors.
40TidyProvider addTidyChecks(llvm::StringRef Checks,
41 llvm::StringRef WarningsAsErrors = {});
42
43/// Provider that will disable checks known to not work with clangd. \p
44/// ExtraBadChecks specifies any other checks that should be always
45/// disabled.
47disableUnusableChecks(llvm::ArrayRef<std::string> ExtraBadChecks = {});
48
49/// Provider that searches for .clang-tidy configuration files in the directory
50/// tree.
52
53// Provider that uses clangd configuration files.
55
56tidy::ClangTidyOptions getTidyOptionsForFile(TidyProviderRef Provider,
57 llvm::StringRef Filename);
58
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 '-'.
61bool isRegisteredTidyCheck(llvm::StringRef Check);
62
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.
65std::optional<bool> isFastTidyCheck(llvm::StringRef Check);
66
67} // namespace clangd
68} // namespace clang
69
70#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_TIDYPROVIDER_H
std::string Filename
Filename as a string.
llvm::function_ref< void(tidy::ClangTidyOptions &, llvm::StringRef)> TidyProviderRef
A factory to modify a tidy::ClangTidyOptions that doesn't hold any state.
Definition: TidyProvider.h:28
TidyProvider combine(std::vector< TidyProvider > Providers)
bool isRegisteredTidyCheck(llvm::StringRef Check)
Returns if Check is a registered clang-tidy check.
TidyProviderRef provideDefaultChecks()
Provider that will enable a nice set of default checks if none are specified.
TidyProviderRef provideEnvironment()
Provider that just sets the defaults.
std::optional< bool > isFastTidyCheck(llvm::StringRef Check)
Returns if Check is known-fast, known-slow, or its speed is unknown.
TidyProvider addTidyChecks(llvm::StringRef Checks, llvm::StringRef WarningsAsErrors)
Provider the enables a specific set of checks and warnings as errors.
TidyProvider provideClangTidyFiles(ThreadsafeFS &TFS)
Provider that searches for .clang-tidy configuration files in the directory tree.
tidy::ClangTidyOptions getTidyOptionsForFile(TidyProviderRef Provider, llvm::StringRef Filename)
TidyProvider disableUnusableChecks(llvm::ArrayRef< std::string > ExtraBadChecks)
Provider that will disable checks known to not work with clangd.
TidyProviderRef provideClangdConfig()
llvm::unique_function< void(tidy::ClangTidyOptions &, llvm::StringRef) const > TidyProvider
A factory to modify a tidy::ClangTidyOptions.
Definition: TidyProvider.h:23
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Contains options for clang-tidy.