Skip to content

Commit 2eac6ae

Browse files
committed
slight refactor and format
1 parent 2f329e7 commit 2eac6ae

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

clang/lib/Analysis/LifetimeSafety.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,11 @@ class FactManager {
384384
llvm::BumpPtrAllocator FactAllocator;
385385
};
386386

387-
class FactGenerator : public ConstStmtVisitor<FactGenerator> {
388-
using Base = ConstStmtVisitor<FactGenerator>;
387+
class FactGeneratorVisitor : public ConstStmtVisitor<FactGeneratorVisitor> {
388+
using Base = ConstStmtVisitor<FactGeneratorVisitor>;
389389

390390
public:
391-
FactGenerator(FactManager &FactMgr) : FactMgr(FactMgr) {}
391+
FactGeneratorVisitor(FactManager &FactMgr) : FactMgr(FactMgr) {}
392392

393393
void startBlock(const CFGBlock *Block) {
394394
CurrentBlock = Block;
@@ -544,11 +544,13 @@ class FactGenerator : public ConstStmtVisitor<FactGenerator> {
544544
llvm::SmallVector<Fact *> CurrentBlockFacts;
545545
};
546546

547-
class FactGeneratorDriver : public RecursiveASTVisitor<FactGeneratorDriver> {
547+
class FactGenerator : public RecursiveASTVisitor<FactGenerator> {
548548
public:
549-
FactGeneratorDriver(FactGenerator &FG, AnalysisDeclContext &AC)
550-
: FG(FG), AC(AC) {}
549+
FactGenerator(FactManager &FactMgr, AnalysisDeclContext &AC)
550+
: FG(FactMgr), AC(AC) {}
551+
551552
bool shouldTraversePostOrder() const { return true; }
553+
552554
void run() {
553555
llvm::TimeTraceScope TimeProfile("FactGenerator");
554556
// Iterate through the CFG blocks in reverse post-order to ensure that
@@ -579,16 +581,17 @@ class FactGeneratorDriver : public RecursiveASTVisitor<FactGeneratorDriver> {
579581

580582
private:
581583
struct FactGeneratorBlockRAII {
582-
FactGeneratorBlockRAII(FactGenerator &FG, const CFGBlock *Block) : FG(FG) {
584+
FactGeneratorBlockRAII(FactGeneratorVisitor &FG, const CFGBlock *Block)
585+
: FG(FG) {
583586
FG.startBlock(Block);
584587
}
585588
~FactGeneratorBlockRAII() { FG.endBlock(); }
586589

587590
private:
588-
FactGenerator FG;
591+
FactGeneratorVisitor &FG;
589592
};
590593

591-
FactGenerator &FG;
594+
FactGeneratorVisitor FG;
592595
AnalysisDeclContext &AC;
593596
llvm::DenseSet<const Stmt *> VisitedStmts;
594597
};
@@ -1136,9 +1139,8 @@ void LifetimeSafetyAnalysis::run() {
11361139
DEBUG_WITH_TYPE("PrintCFG", Cfg.dump(AC.getASTContext().getLangOpts(),
11371140
/*ShowColors=*/true));
11381141

1139-
FactGenerator Generator(*FactMgr);
1140-
FactGeneratorDriver Driver(Generator, AC);
1141-
Driver.run();
1142+
FactGenerator FG(*FactMgr, AC);
1143+
FG.run();
11421144
DEBUG_WITH_TYPE("LifetimeFacts", FactMgr->dump(Cfg, AC));
11431145

11441146
/// TODO(opt): Consider optimizing individual blocks before running the

0 commit comments

Comments
 (0)