@@ -396,18 +396,30 @@ class FactGenerator : public ConstStmtVisitor<FactGenerator> {
396
396
// initializations and destructions are processed in the correct sequence.
397
397
for (const CFGBlock *Block : *AC.getAnalysis <PostOrderCFGView>()) {
398
398
CurrentBlockFacts.clear ();
399
+ VisitedStmts.clear ();
399
400
for (unsigned I = 0 ; I < Block->size (); ++I) {
400
401
const CFGElement &Element = Block->Elements [I];
401
- if (std::optional<CFGStmt> CS = Element.getAs <CFGStmt>())
402
+ if (std::optional<CFGStmt> CS = Element.getAs <CFGStmt>()) {
403
+ DEBUG_WITH_TYPE (" PrintCFG" ,
404
+ llvm::dbgs ()
405
+ << " ======CFGStmt and ASTStmt========\n " );
406
+ DEBUG_WITH_TYPE (" PrintCFG" , CS->dump ());
407
+ DEBUG_WITH_TYPE (" PrintCFG" , CS->getStmt ()->dumpColor ());
402
408
Visit (CS->getStmt ());
403
- else if (std::optional<CFGAutomaticObjDtor> DtorOpt =
404
- Element.getAs <CFGAutomaticObjDtor>())
409
+ } else if (std::optional<CFGAutomaticObjDtor> DtorOpt =
410
+ Element.getAs <CFGAutomaticObjDtor>())
405
411
handleDestructor (*DtorOpt);
406
412
}
407
413
FactMgr.addBlockFacts (Block, CurrentBlockFacts);
408
414
}
409
415
}
410
416
417
+ void Visit (const Stmt *S) {
418
+ if (!S || VisitedStmts.insert (S).second )
419
+ return ;
420
+ Base::Visit (S);
421
+ }
422
+
411
423
void VisitDeclStmt (const DeclStmt *DS) {
412
424
for (const Decl *D : DS->decls ())
413
425
if (const auto *VD = dyn_cast<VarDecl>(D))
@@ -551,6 +563,7 @@ class FactGenerator : public ConstStmtVisitor<FactGenerator> {
551
563
FactManager &FactMgr;
552
564
AnalysisDeclContext &AC;
553
565
llvm::SmallVector<Fact *> CurrentBlockFacts;
566
+ llvm::DenseSet<const Stmt *> VisitedStmts;
554
567
};
555
568
556
569
// ========================================================================= //
0 commit comments