clang 17.0.0git
|
#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/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>
Go to the source code of this file.
Namespaces | |
namespace | clang |
namespace | clang::reachable_code |
Functions | |
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) |
Returns true if the statement is expanded from a configuration macro. | |
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) |
Returns true if the statement represents a configuration value. | |
static bool | shouldTreatSuccessorsAsReachable (const CFGBlock *B, Preprocessor &PP) |
Returns true if we should always explore all successors of a block. | |
static unsigned | scanFromBlock (const CFGBlock *Start, llvm::BitVector &Reachable, Preprocessor *PP, bool IncludeSometimesUnreachableEdges) |
static unsigned | scanMaybeReachableFromBlock (const CFGBlock *Start, Preprocessor &PP, llvm::BitVector &Reachable) |
static bool | isValidDeadStmt (const Stmt *S) |
static int | SrcCmp (const std::pair< const CFGBlock *, const Stmt * > *p1, const std::pair< const CFGBlock *, const Stmt * > *p2) |
static SourceLocation | GetUnreachableLoc (const Stmt *S, SourceRange &R1, SourceRange &R2) |
unsigned | clang::reachable_code::ScanReachableFromBlock (const CFGBlock *Start, llvm::BitVector &Reachable) |
ScanReachableFromBlock - Mark all blocks reachable from Start. | |
void | clang::reachable_code::FindUnreachableCode (AnalysisDeclContext &AC, Preprocessor &PP, Callback &CB) |
|
static |
Definition at line 138 of file ReachableCode.cpp.
References clang::SourceLocation::isMacroID(), clang::Last, and SM.
Referenced by isExpandedFromConfigurationMacro().
|
static |
Definition at line 552 of file ReachableCode.cpp.
References clang::CXXFunctionalCastExpr::getBeginLoc(), clang::ArraySubscriptExpr::getLHS(), clang::BinaryOperator::getLHS(), clang::CStyleCastExpr::getLParenLoc(), clang::ObjCBridgedCastExpr::getLParenLoc(), clang::MemberExpr::getMemberLoc(), clang::UnaryOperator::getOperatorLoc(), clang::BinaryOperator::getOperatorLoc(), clang::AbstractConditionalOperator::getQuestionLoc(), clang::ArraySubscriptExpr::getRBracketLoc(), clang::ArraySubscriptExpr::getRHS(), clang::BinaryOperator::getRHS(), clang::Stmt::getSourceRange(), clang::CastExpr::getSubExpr(), and clang::UnaryOperator::getSubExpr().
|
static |
Definition at line 71 of file ReachableCode.cpp.
References clang::CFGBlock::back(), clang::C, clang::CFGBlock::empty(), and clang::CFGElement::getAs().
Definition at line 63 of file ReachableCode.cpp.
|
static |
Returns true if the statement represents a configuration value.
A configuration value is something usually determined at compile-time to conditionally always execute some branch. Such guards are for "sometimes unreachable" code. Such code is usually not interesting to report as unreachable, and may mask truly unreachable code within those blocks.
Definition at line 188 of file ReachableCode.cpp.
References clang::BinaryOperator::getLHS(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Stmt::getSourceRange(), clang::UnaryOperator::getSubExpr(), clang::Expr::IgnoreCasts(), clang::BinaryOperator::isComparisonOp(), isConfigurationValue(), isExpandedFromConfigurationMacro(), and clang::BinaryOperator::isLogicalOp().
|
static |
Definition at line 273 of file ReachableCode.cpp.
References isConfigurationValue().
Referenced by isConfigurationValue(), and shouldTreatSuccessorsAsReachable().
Definition at line 86 of file ReachableCode.cpp.
References clang::ParentMap::getParent().
Definition at line 36 of file ReachableCode.cpp.
References clang::DeclRefExpr::getDecl().
Referenced by isTrivialExpression().
|
static |
Returns true if the statement is expanded from a configuration macro.
Definition at line 149 of file ReachableCode.cpp.
References clang::Preprocessor::getImmediateMacroName(), clang::Preprocessor::getLangOpts(), clang::Preprocessor::getSourceManager(), getTopMostMacro(), clang::SourceLocation::isMacroID(), and SM.
Referenced by isConfigurationValue().
Definition at line 51 of file ReachableCode.cpp.
References clang::CFGBlock::getTerminatorStmt(), clang::Expr::IgnoreParenCasts(), and isTrivialExpression().
Definition at line 43 of file ReachableCode.cpp.
References clang::Expr::IgnoreParenCasts(), and isEnumConstant().
Referenced by isTrivialDoWhile().
Definition at line 456 of file ReachableCode.cpp.
|
static |
Definition at line 316 of file ReachableCode.cpp.
References clang::CFGBlock::getBlockID(), shouldTreatSuccessorsAsReachable(), clang::CFGBlock::succ_begin(), and clang::CFGBlock::succ_end().
Referenced by scanMaybeReachableFromBlock(), and clang::reachable_code::ScanReachableFromBlock().
|
static |
Definition at line 382 of file ReachableCode.cpp.
References scanFromBlock().
Referenced by clang::reachable_code::FindUnreachableCode().
|
static |
Returns true if we should always explore all successors of a block.
Definition at line 295 of file ReachableCode.cpp.
References clang::CFGBlock::getTerminatorCondition(), clang::CFGBlock::getTerminatorStmt(), and isConfigurationValue().
Referenced by scanFromBlock().