clang-tools  14.0.0git
MtUnsafeCheck.h
Go to the documentation of this file.
1 //===--- MtUnsafeCheck.h - clang-tidy ---------------------------*- 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_CLANG_TIDY_CONCURRENCY_MTUNSAFECHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CONCURRENCY_MTUNSAFECHECK_H
11 
12 #include "../ClangTidyCheck.h"
13 
14 namespace clang {
15 namespace tidy {
16 namespace concurrency {
17 
18 /// Checks that non-thread-safe functions are not used.
19 ///
20 /// For the user-facing documentation see:
21 /// http://clang.llvm.org/extra/clang-tidy/checks/threads-mt-unsafe.html
22 class MtUnsafeCheck : public ClangTidyCheck {
23 public:
24  MtUnsafeCheck(StringRef Name, ClangTidyContext *Context);
25  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
26  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
27  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
28 
29  enum class FunctionSet {
30  Posix,
31  Glibc,
32  Any,
33  };
34 
35 private:
36  const FunctionSet FuncSet;
37 };
38 
39 } // namespace concurrency
40 } // namespace tidy
41 } // namespace clang
42 
43 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CONCURRENCY_MTUNSAFECHECK_H
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition: ClangTidyOptions.h:115
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:54
clang::tidy::concurrency::MtUnsafeCheck::FunctionSet::Any
@ Any
clang::tidy::concurrency::MtUnsafeCheck::MtUnsafeCheck
MtUnsafeCheck(StringRef Name, ClangTidyContext *Context)
Definition: MtUnsafeCheck.cpp:292
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:71
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::concurrency::MtUnsafeCheck
Checks that non-thread-safe functions are not used.
Definition: MtUnsafeCheck.h:22
clang::tidy::concurrency::MtUnsafeCheck::FunctionSet::Posix
@ Posix
clang::tidy::concurrency::MtUnsafeCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: MtUnsafeCheck.cpp:307
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::concurrency::MtUnsafeCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition: MtUnsafeCheck.cpp:296
clang::tidy::concurrency::MtUnsafeCheck::FunctionSet
FunctionSet
Definition: MtUnsafeCheck.h:29
clang::tidy::concurrency::MtUnsafeCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: MtUnsafeCheck.cpp:300
clang::tidy::concurrency::MtUnsafeCheck::FunctionSet::Glibc
@ Glibc