clang-tools 20.0.0git
ElseAfterReturnCheck.h
Go to the documentation of this file.
1//===--- ElseAfterReturnCheck.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_READABILITY_ELSEAFTERRETURNCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_ELSEAFTERRETURNCHECK_H
11
12#include "../ClangTidyCheck.h"
13#include "llvm/ADT/DenseMap.h"
14
16
17/// Flags the usages of `else` after `return`.
18///
19/// http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
21public:
22 ElseAfterReturnCheck(StringRef Name, ClangTidyContext *Context);
23
24 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
25 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
26 Preprocessor *ModuleExpanderPP) override;
27 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
28 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
29 std::optional<TraversalKind> getCheckTraversalKind() const override {
30 return TK_IgnoreUnlessSpelledInSource;
31 }
32
34 llvm::DenseMap<FileID, SmallVector<SourceRange, 1>>;
35
36private:
37 const bool WarnOnUnfixable;
38 const bool WarnOnConditionVariables;
39 ConditionalBranchMap PPConditionals;
40};
41
42} // namespace clang::tidy::readability
43
44#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_ELSEAFTERRETURNCHECK_H
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Flags the usages of else after return.
llvm::DenseMap< FileID, SmallVector< SourceRange, 1 > > ConditionalBranchMap
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
Override this to register PPCallbacks in the preprocessor.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
std::optional< TraversalKind > getCheckTraversalKind() const override
llvm::StringMap< ClangTidyValue > OptionMap