clang-tools 23.0.0git
FormatvStringCheck.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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_CLANG_TIDY_LLVM_FORMATVSTRINGCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_FORMATVSTRINGCHECK_H
11
12#include "../ClangTidyCheck.h"
13#include <vector>
14
16
17/// Validates llvm::formatv format strings against the provided arguments.
18///
19/// Checks that:
20/// - The number of format indices matches the number of arguments.
21/// - Every argument is used by the format string.
22/// - Automatic and explicit indices are not mixed.
23///
24/// For the user-facing documentation see:
25/// https://clang.llvm.org/extra/clang-tidy/checks/llvm/formatv-string.html
27public:
28 FormatvStringCheck(StringRef Name, ClangTidyContext *Context);
29 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
30 return LangOpts.CPlusPlus;
31 }
32 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
33 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35
36 std::optional<TraversalKind> getCheckTraversalKind() const override {
37 return TK_IgnoreUnlessSpelledInSource;
38 }
39
40private:
41 std::vector<StringRef> Functions;
42 const StringRef AdditionalFunctions;
43};
44
45} // namespace clang::tidy::llvm_check
46
47#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_FORMATVSTRINGCHECK_H
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
void registerMatchers(ast_matchers::MatchFinder *Finder) override
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
FormatvStringCheck(StringRef Name, ClangTidyContext *Context)
std::optional< TraversalKind > getCheckTraversalKind() const override
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
llvm::StringMap< ClangTidyValue > OptionMap