Skip to content

Commit 9d88990

Browse files
committed
[clang][Interp][NFC] Remove visit{Global,Local,This}Initializer
They were only called once, or not at all.
1 parent fb12863 commit 9d88990

File tree

2 files changed

+23
-41
lines changed

2 files changed

+23
-41
lines changed

clang/lib/AST/Interp/Compiler.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3583,7 +3583,19 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Topleve
35833583
return checkDecl() && this->emitInitGlobal(*VarT, GlobalIndex, VD);
35843584
}
35853585

3586-
return checkDecl() && this->visitGlobalInitializer(Init, GlobalIndex);
3586+
if (!checkDecl())
3587+
return false;
3588+
3589+
if (!this->emitGetPtrGlobal(GlobalIndex, Init))
3590+
return false;
3591+
3592+
if (!visitInitializer(Init))
3593+
return false;
3594+
3595+
if (!this->emitFinishInit(Init))
3596+
return false;
3597+
3598+
return this->emitPopPtr(Init);
35873599
};
35883600

35893601
// We've already seen and initialized this global.
@@ -3627,7 +3639,16 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Topleve
36273639
if (!Init)
36283640
return true;
36293641

3630-
return this->visitLocalInitializer(Init, *Offset);
3642+
if (!this->emitGetPtrLocal(*Offset, Init))
3643+
return false;
3644+
3645+
if (!visitInitializer(Init))
3646+
return false;
3647+
3648+
if (!this->emitFinishInit(Init))
3649+
return false;
3650+
3651+
return this->emitPopPtr(Init);
36313652
}
36323653
return false;
36333654
}

clang/lib/AST/Interp/Compiler.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -278,45 +278,6 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
278278
/// Visits an expression and converts it to a boolean.
279279
bool visitBool(const Expr *E);
280280

281-
/// Visits an initializer for a local.
282-
bool visitLocalInitializer(const Expr *Init, unsigned I) {
283-
if (!this->emitGetPtrLocal(I, Init))
284-
return false;
285-
286-
if (!visitInitializer(Init))
287-
return false;
288-
289-
if (!this->emitFinishInit(Init))
290-
return false;
291-
292-
return this->emitPopPtr(Init);
293-
}
294-
295-
/// Visits an initializer for a global.
296-
bool visitGlobalInitializer(const Expr *Init, unsigned I) {
297-
if (!this->emitGetPtrGlobal(I, Init))
298-
return false;
299-
300-
if (!visitInitializer(Init))
301-
return false;
302-
303-
if (!this->emitFinishInit(Init))
304-
return false;
305-
306-
return this->emitPopPtr(Init);
307-
}
308-
309-
/// Visits a delegated initializer.
310-
bool visitThisInitializer(const Expr *I) {
311-
if (!this->emitThis(I))
312-
return false;
313-
314-
if (!visitInitializer(I))
315-
return false;
316-
317-
return this->emitFinishInitPop(I);
318-
}
319-
320281
bool visitInitList(ArrayRef<const Expr *> Inits, const Expr *ArrayFiller,
321282
const Expr *E);
322283
bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init);

0 commit comments

Comments
 (0)