clang-tools  14.0.0git
ComparisonInTempFailureRetryCheck.h
Go to the documentation of this file.
1 //===--- ComparisonInTempFailureRetryCheck.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_ANDROID_COMPARISONINTEMPFAILURERETRYCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_COMPARISONINTEMPFAILURERETRYCHECK_H
11 
12 #include "../ClangTidyCheck.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/ADT/StringRef.h"
15 #include <string>
16 
17 namespace clang {
18 namespace tidy {
19 namespace android {
20 
21 /// Attempts to catch calls to TEMP_FAILURE_RETRY with a top-level comparison
22 /// operation, like `TEMP_FAILURE_RETRY(read(...) != N)`. In these cases, the
23 /// comparison should go outside of the TEMP_FAILURE_RETRY.
24 ///
25 /// TEMP_FAILURE_RETRY is a macro provided by both glibc and Bionic.
27 public:
29  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
30  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
31  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
32 
33 private:
34  const std::string RawRetryList;
35  SmallVector<StringRef, 5> RetryMacros;
36 };
37 
38 } // namespace android
39 } // namespace tidy
40 } // namespace clang
41 
42 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_COMPARISONINTEMPFAILURERETRYCHECK_H
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition: ClangTidyOptions.h:115
clang::tidy::android::ComparisonInTempFailureRetryCheck
Attempts to catch calls to TEMP_FAILURE_RETRY with a top-level comparison operation,...
Definition: ComparisonInTempFailureRetryCheck.h:26
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:54
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::android::ComparisonInTempFailureRetryCheck::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: ComparisonInTempFailureRetryCheck.cpp:28
clang::tidy::android::ComparisonInTempFailureRetryCheck::ComparisonInTempFailureRetryCheck
ComparisonInTempFailureRetryCheck(StringRef Name, ClangTidyContext *Context)
Definition: ComparisonInTempFailureRetryCheck.cpp:21
clang::tidy::android::ComparisonInTempFailureRetryCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: ComparisonInTempFailureRetryCheck.cpp:33
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::android::ComparisonInTempFailureRetryCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: ComparisonInTempFailureRetryCheck.cpp:56