#include "ElseAfterReturnCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Tooling/FixIt.h"
#include "llvm/ADT/SmallVector.h"
usingnamespaceclang::ast_matchers;
namespace clang::tidy::readability {
namespace {
class PPConditionalCollector : public PPCallbacks { … };
}
static const char InterruptingStr[] = …;
static const char WarningMessage[] = …;
static const char WarnOnUnfixableStr[] = …;
static const char WarnOnConditionVariablesStr[] = …;
static const DeclRefExpr *findUsage(const Stmt *Node, int64_t DeclIdentifier) { … }
static const DeclRefExpr *
findUsageRange(const Stmt *Node,
const llvm::ArrayRef<int64_t> &DeclIdentifiers) { … }
static const DeclRefExpr *checkInitDeclUsageInElse(const IfStmt *If) { … }
static const DeclRefExpr *checkConditionVarUsageInElse(const IfStmt *If) { … }
static bool containsDeclInScope(const Stmt *Node) { … }
static void removeElseAndBrackets(DiagnosticBuilder &Diag, ASTContext &Context,
const Stmt *Else, SourceLocation ElseLoc) { … }
ElseAfterReturnCheck::ElseAfterReturnCheck(StringRef Name,
ClangTidyContext *Context)
: … { … }
void ElseAfterReturnCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { … }
void ElseAfterReturnCheck::registerPPCallbacks(const SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) { … }
void ElseAfterReturnCheck::registerMatchers(MatchFinder *Finder) { … }
static bool hasPreprocessorBranchEndBetweenLocations(
const ElseAfterReturnCheck::ConditionalBranchMap &ConditionalBranchMap,
const SourceManager &SM, SourceLocation StartLoc, SourceLocation EndLoc) { … }
static StringRef getControlFlowString(const Stmt &Stmt) { … }
void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) { … }
}