llvm::DenseMap<const Stmt *, const CFGBlock *>
31llvm::DenseMap<const Stmt *, const CFGBlock *> StmtToBlock;
33 if(
Block==
nullptr)
52 if(
Block!=
nullptr)
53 if(
const Stmt*TerminatorCond =
Block->getTerminatorCondition())
54StmtToBlock.insert({TerminatorCond,
Block});
69 if(
Block!=
nullptr)
70 if(
const Stmt*TerminatorStmt =
Block->getTerminatorStmt())
71StmtToBlock.insert({TerminatorStmt,
Block});
80BlocksToVisit.push_back(&Cfg.
getEntry());
81 while(!BlocksToVisit.empty()) {
83BlocksToVisit.pop_back();
85 if(BlockReachable[
Block->getBlockID()])
88BlockReachable[
Block->getBlockID()] =
true;
92BlocksToVisit.push_back(Succ);
95 returnBlockReachable;
98staticllvm::DenseSet<const CFGBlock *>
101llvm::DenseSet<const CFGBlock *> Result;
103 autoCheckChildExprs = [&Result, &StmtToBlock](
const Stmt*S,
105 for(
const Stmt*Child : S->children()) {
106 if(!isa_and_nonnull<Expr>(Child))
109 if(ChildBlock !=
Block)
110Result.insert(ChildBlock);
115 if(
Block==
nullptr)
119 if(
autoS = Element.getAs<
CFGStmt>())
120CheckChildExprs(S->getStmt(),
Block);
122 if(
const Stmt*TerminatorCond =
Block->getTerminatorCondition())
123CheckChildExprs(TerminatorCond,
Block);
131StmtToBlockMap::StmtToBlockMap(
const CFG&Cfg)
137 if(!
Func.doesThisDeclarationHaveABody())
138 returnllvm::createStringError(
139std::make_error_code(std::errc::invalid_argument),
140 "Cannot analyze function without a body");
147 if(
D.isTemplated())
148 returnllvm::createStringError(
149std::make_error_code(std::errc::invalid_argument),
150 "Cannot analyze templated declarations");
154 if(!
C.getLangOpts().CPlusPlus ||
C.getLangOpts().ObjC)
155 returnllvm::createStringError(
156std::make_error_code(std::errc::invalid_argument),
157 "Can only analyze C++");
160Options.PruneTriviallyFalseEdges =
true;
161Options.AddImplicitDtors =
true;
162Options.AddTemporaryDtors =
true;
163Options.AddInitializers =
true;
164Options.AddCXXDefaultInitExprInCtors =
true;
165Options.AddLifetime =
true;
168Options.setAllAlwaysAdd();
172 returnllvm::createStringError(
173std::make_error_code(std::errc::invalid_argument),
174 "CFG::buildCFG failed");
180llvm::DenseSet<const CFGBlock *> ContainsExprConsumedInDifferentBlock =
183 return AdornedCFG(
D, std::move(Cfg), std::move(StmtToBlock),
184std::move(BlockReachable),
185std::move(ContainsExprConsumedInDifferentBlock));
Defines the clang::ASTContext interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a single basic block in a source-level CFG.
Represents a top-level expression in a basic block.
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
static std::unique_ptr< CFG > buildCFG(const Decl *D, Stmt *AST, ASTContext *C, const BuildOptions &BO)
Builds a CFG from an AST.
unsigned getNumBlockIDs() const
Returns the total number of BlockIDs allocated (which start at 0).
Decl - This represents one declaration (or definition), e.g.
Represents a function declaration or definition.
Stmt - This represents one statement.
Holds CFG with additional information derived from it that is needed to perform dataflow analysis.
static llvm::Expected< AdornedCFG > build(const FunctionDecl &Func)
Builds an AdornedCFG from a FunctionDecl.
const CFGBlock * lookup(const Stmt &S) const
static llvm::DenseSet< const CFGBlock * > buildContainsExprConsumedInDifferentBlock(const CFG &Cfg, const internal::StmtToBlockMap &StmtToBlock)
static llvm::DenseMap< const Stmt *, const CFGBlock * > buildStmtToBasicBlockMap(const CFG &Cfg)
Returns a map from statements to basic blocks that contain them.
static llvm::BitVector findReachableBlocks(const CFG &Cfg)
The JSON file list parser is used to communicate input to InstallAPI.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4