void appendStmt(Stmt* Statement, BumpVectorContext &C, bool asLValue) {
Stmts.push_back(CFGElement(Statement, asLValue), C);
- }
- void StartScope(Stmt* S, BumpVectorContext &C) {
- Stmts.push_back(CFGElement(S, CFGElement::StartScope), C);
- }
- void EndScope(Stmt* S, BumpVectorContext &C) {
- Stmts.push_back(CFGElement(S, CFGElement::EndScope), C);
}
};
/// constructed CFG belongs to the caller.
static CFG* buildCFG(const Decl *D, Stmt* AST, ASTContext *C,
bool pruneTriviallyFalseEdges = true,
- bool AddEHEdges = false,
- bool AddScopes = false /* NOT FULLY IMPLEMENTED.
- NOT READY FOR GENERAL USE. */);
+ bool AddEHEdges = false);
/// createBlock - Create a new block in the CFG. The CFG owns the block;
/// the caller should not directly free it.
// buildCFG - Used by external clients to construct the CFG.
CFG* buildCFG(const Decl *D, Stmt *Statement, ASTContext *C,
- bool pruneTriviallyFalseEdges, bool AddEHEdges,
- bool AddScopes);
+ bool pruneTriviallyFalseEdges, bool AddEHEdges);
private:
// Visitors to walk an AST and construct the CFG.
return Block;
}
- CFGBlock *StartScope(Stmt *S, CFGBlock *B) {
- if (!AddScopes)
- return B;
-
- if (B == 0)
- B = createBlock();
- B->StartScope(S, cfg->getBumpVectorContext());
- return B;
- }
-
- void EndScope(Stmt *S) {
- if (!AddScopes)
- return;
-
- if (Block == 0)
- Block = createBlock();
- Block->EndScope(S, cfg->getBumpVectorContext());
- }
-
void autoCreateBlock() { if (!Block) Block = createBlock(); }
CFGBlock *createBlock(bool add_successor = true);
// True iff EH edges on CallExprs should be added to the CFG.
bool AddEHEdges;
-
- // True iff scope start and scope end notes should be added to the CFG.
- bool AddScopes;
};
// FIXME: Add support for dependent-sized array types in C++?
/// NULL.
CFG* CFGBuilder::buildCFG(const Decl *D, Stmt* Statement, ASTContext* C,
bool pruneTriviallyFalseEdges,
- bool addehedges, bool AddScopes) {
+ bool addehedges) {
AddEHEdges = addehedges;
PruneTriviallyFalseEdges = pruneTriviallyFalseEdges;
if (!Statement)
return NULL;
- this->AddScopes = AddScopes;
badCFG = false;
// Create an empty block that will serve as the exit block for the CFG. Since
CFGBlock* CFGBuilder::VisitCompoundStmt(CompoundStmt* C) {
- EndScope(C);
-
CFGBlock* LastBlock = Block;
for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
return NULL;
}
- LastBlock = StartScope(C, LastBlock);
-
return LastBlock;
}
/// CFG is returned to the caller.
CFG* CFG::buildCFG(const Decl *D, Stmt* Statement, ASTContext *C,
bool PruneTriviallyFalse,
- bool AddEHEdges, bool AddScopes) {
+ bool AddEHEdges) {
CFGBuilder Builder;
return Builder.buildCFG(D, Statement, C, PruneTriviallyFalse,
- AddEHEdges, AddScopes);
+ AddEHEdges);
}
//===----------------------------------------------------------------------===//
static void print_stmt(llvm::raw_ostream &OS, StmtPrinterHelper* Helper,
const CFGElement &E) {
-
- if (E.asStartScope()) {
- OS << "start scope\n";
- return;
- }
- if (E.asEndScope()) {
- OS << "end scope\n";
- return;
- }
-
Stmt *S = E;
if (Helper) {