#include "clang/Analysis/Analyses/ReachableCode.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/ParentMap.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/StmtCXX.h"
#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
#include <optional>
usingnamespaceclang;
static bool isEnumConstant(const Expr *Ex) { … }
static bool isTrivialExpression(const Expr *Ex) { … }
static bool isTrivialDoWhile(const CFGBlock *B, const Stmt *S) { … }
static bool isBuiltinUnreachable(const Stmt *S) { … }
static bool isBuiltinAssumeFalse(const CFGBlock *B, const Stmt *S,
ASTContext &C) { … }
static bool isDeadReturn(const CFGBlock *B, const Stmt *S) { … }
static SourceLocation getTopMostMacro(SourceLocation Loc, SourceManager &SM) { … }
static bool isExpandedFromConfigurationMacro(const Stmt *S,
Preprocessor &PP,
bool IgnoreYES_NO = false) { … }
static bool isConfigurationValue(const ValueDecl *D, Preprocessor &PP);
static bool isConfigurationValue(const Stmt *S,
Preprocessor &PP,
SourceRange *SilenceableCondVal = nullptr,
bool IncludeIntegers = true,
bool WrappedInParens = false) { … }
static bool isConfigurationValue(const ValueDecl *D, Preprocessor &PP) { … }
static bool shouldTreatSuccessorsAsReachable(const CFGBlock *B,
Preprocessor &PP) { … }
static unsigned scanFromBlock(const CFGBlock *Start,
llvm::BitVector &Reachable,
Preprocessor *PP,
bool IncludeSometimesUnreachableEdges) { … }
static unsigned scanMaybeReachableFromBlock(const CFGBlock *Start,
Preprocessor &PP,
llvm::BitVector &Reachable) { … }
namespace {
class DeadCodeScan { … };
}
void DeadCodeScan::enqueue(const CFGBlock *block) { … }
bool DeadCodeScan::isDeadCodeRoot(const clang::CFGBlock *Block) { … }
static bool isInCoroutineStmt(const Stmt *DeadStmt, const CFGBlock *Block) { … }
static bool isValidDeadStmt(const Stmt *S, const clang::CFGBlock *Block) { … }
const Stmt *DeadCodeScan::findDeadCode(const clang::CFGBlock *Block) { … }
static int SrcCmp(const std::pair<const CFGBlock *, const Stmt *> *p1,
const std::pair<const CFGBlock *, const Stmt *> *p2) { … }
unsigned DeadCodeScan::scanBackwards(const clang::CFGBlock *Start,
clang::reachable_code::Callback &CB) { … }
static SourceLocation GetUnreachableLoc(const Stmt *S,
SourceRange &R1,
SourceRange &R2) { … }
void DeadCodeScan::reportDeadCode(const CFGBlock *B,
const Stmt *S,
clang::reachable_code::Callback &CB) { … }
namespace clang { namespace reachable_code {
void Callback::anchor() { … }
unsigned ScanReachableFromBlock(const CFGBlock *Start,
llvm::BitVector &Reachable) { … }
void FindUnreachableCode(AnalysisDeclContext &AC, Preprocessor &PP,
Callback &CB) { … }
}}