clang API Documentation
#include "clang/Analysis/Analyses/ReachableCode.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/ParentMap.h"
#include "clang/Analysis/AnalysisContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
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 | 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) |
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) |
void | clang::reachable_code::FindUnreachableCode (AnalysisDeclContext &AC, Preprocessor &PP, Callback &CB) |
static SourceLocation getTopMostMacro | ( | SourceLocation | Loc, |
SourceManager & | SM | ||
) | [static] |
Definition at line 115 of file ReachableCode.cpp.
References clang::SourceManager::getImmediateMacroCallerLoc(), clang::SourceLocation::isMacroID(), and clang::LangAS::Last.
Referenced by isExpandedFromConfigurationMacro().
static SourceLocation GetUnreachableLoc | ( | const Stmt * | S, |
SourceRange & | R1, | ||
SourceRange & | R2 | ||
) | [static] |
Definition at line 504 of file ReachableCode.cpp.
References clang::ArraySubscriptExpr::getLHS(), clang::BinaryOperator::getLHS(), clang::Stmt::getLocStart(), clang::CXXFunctionalCastExpr::getLocStart(), clang::ObjCBridgedCastExpr::getLParenLoc(), clang::CStyleCastExpr::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::Stmt::getStmtClass(), clang::UnaryOperator::getSubExpr(), clang::CastExpr::getSubExpr(), and S.
static bool isConfigurationValue | ( | const ValueDecl * | D, |
Preprocessor & | PP | ||
) | [static] |
Definition at line 230 of file ReachableCode.cpp.
Referenced by isConfigurationValue(), and shouldTreatSuccessorsAsReachable().
static bool isConfigurationValue | ( | const Stmt * | S, |
Preprocessor & | PP, | ||
SourceRange * | SilenceableCondVal = nullptr , |
||
bool | IncludeIntegers = true , |
||
bool | WrappedInParens = false |
||
) | [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 159 of file ReachableCode.cpp.
References clang::BinaryOperator::getLHS(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Stmt::getSourceRange(), clang::Stmt::getStmtClass(), clang::UnaryOperator::getSubExpr(), clang::BinaryOperator::isComparisonOp(), isConfigurationValue(), clang::FunctionDecl::isConstexpr(), isExpandedFromConfigurationMacro(), clang::BinaryOperator::isLogicalOp(), S, and clang::UO_LNot.
static bool isDeadReturn | ( | const CFGBlock * | B, |
const Stmt * | S | ||
) | [static] |
Definition at line 61 of file ReachableCode.cpp.
References Current, clang::ParentMap::getParent(), clang::CFGBlock::getTerminator(), clang::CFGTerminator::isTemporaryDtorsBranch(), clang::CFGBlock::pred_size(), clang::CFGBlock::rbegin(), clang::CFGBlock::rend(), clang::CFGBlock::succ_begin(), and clang::CFGBlock::succ_size().
static bool isEnumConstant | ( | const Expr * | Ex | ) | [static] |
Definition at line 34 of file ReachableCode.cpp.
References clang::DeclRefExpr::getDecl().
Referenced by isTrivialExpression().
static bool isExpandedFromConfigurationMacro | ( | const Stmt * | S, |
Preprocessor & | PP, | ||
bool | IgnoreYES_NO = false |
||
) | [static] |
Returns true if the statement is expanded from a configuration macro.
Definition at line 126 of file ReachableCode.cpp.
References clang::Preprocessor::getImmediateMacroName(), clang::Stmt::getLocStart(), clang::Preprocessor::getSourceManager(), getTopMostMacro(), clang::SourceLocation::isMacroID(), and SM.
Referenced by isConfigurationValue().
static bool isTrivialDoWhile | ( | const CFGBlock * | B, |
const Stmt * | S | ||
) | [static] |
Definition at line 49 of file ReachableCode.cpp.
References clang::CFGBlock::getTerminator(), clang::Expr::IgnoreParenCasts(), and isTrivialExpression().
static bool isTrivialExpression | ( | const Expr * | Ex | ) | [static] |
Definition at line 41 of file ReachableCode.cpp.
References clang::Expr::IgnoreParenCasts(), and isEnumConstant().
Referenced by isTrivialDoWhile().
static bool isValidDeadStmt | ( | const Stmt * | S | ) | [static] |
Definition at line 406 of file ReachableCode.cpp.
References clang::BO_Comma, clang::Stmt::getLocStart(), and clang::SourceLocation::isInvalid().
static unsigned scanFromBlock | ( | const CFGBlock * | Start, |
llvm::BitVector & | Reachable, | ||
Preprocessor * | PP, | ||
bool | IncludeSometimesUnreachableEdges | ||
) | [static] |
Definition at line 267 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 unsigned scanMaybeReachableFromBlock | ( | const CFGBlock * | Start, |
Preprocessor & | PP, | ||
llvm::BitVector & | Reachable | ||
) | [static] |
Definition at line 333 of file ReachableCode.cpp.
References scanFromBlock().
Referenced by clang::reachable_code::FindUnreachableCode().
static bool shouldTreatSuccessorsAsReachable | ( | const CFGBlock * | B, |
Preprocessor & | PP | ||
) | [static] |
Returns true if we should always explore all successors of a block.
Definition at line 252 of file ReachableCode.cpp.
References clang::CFGBlock::getTerminator(), clang::CFGBlock::getTerminatorCondition(), and isConfigurationValue().
Referenced by scanFromBlock().