Skip to content

Commit f1533db

Browse files
committed
[arc-codemotion] Do not call virtual methods in constructors.
Moved the setting to the run section of arc-code motion. In this case I think it is safe to do this, but calling a virtual function is generally a code smell, so no reason to keep it in the code base unless we need to. Caught by the clang static analyzer.
1 parent 8f6028d commit f1533db

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/SILOptimizer/Transforms/ARCCodeMotion.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ class CodeMotionContext {
242242
};
243243

244244
bool CodeMotionContext::run() {
245+
MultiIteration = requireIteration();
246+
245247
// Initialize the data flow.
246248
initializeCodeMotionDataFlow();
247249

@@ -332,9 +334,7 @@ class RetainCodeMotionContext : public CodeMotionContext {
332334
RetainCodeMotionContext(llvm::SpecificBumpPtrAllocator<BlockState> &BPA,
333335
SILFunction *F, PostOrderFunctionInfo *PO,
334336
AliasAnalysis *AA, RCIdentityFunctionInfo *RCFI)
335-
: CodeMotionContext(BPA, F, PO, AA, RCFI) {
336-
MultiIteration = requireIteration();
337-
}
337+
: CodeMotionContext(BPA, F, PO, AA, RCFI) {}
338338

339339
/// virtual destructor.
340340
~RetainCodeMotionContext() override {}
@@ -684,10 +684,8 @@ class ReleaseCodeMotionContext : public CodeMotionContext {
684684
AliasAnalysis *AA, RCIdentityFunctionInfo *RCFI,
685685
bool FreezeEpilogueReleases,
686686
ConsumedArgToEpilogueReleaseMatcher &ERM)
687-
: CodeMotionContext(BPA, F, PO, AA, RCFI),
688-
FreezeEpilogueReleases(FreezeEpilogueReleases), ERM(ERM) {
689-
MultiIteration = requireIteration();
690-
}
687+
: CodeMotionContext(BPA, F, PO, AA, RCFI),
688+
FreezeEpilogueReleases(FreezeEpilogueReleases), ERM(ERM) {}
691689

692690
/// virtual destructor.
693691
~ReleaseCodeMotionContext() override {}

0 commit comments

Comments
 (0)