Skip to content

Commit ecb03db

Browse files
committed
Default evaluation flag to false
1 parent 7ca3012 commit ecb03db

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5181,7 +5181,7 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) {
51815181
return false;
51825182

51835183
if (const DeclStmt *CondDecl = IS->getConditionVariableDeclStmt())
5184-
if (!visitDeclStmt(CondDecl, /*EvaluateConditionDecl=*/false))
5184+
if (!visitDeclStmt(CondDecl))
51855185
return false;
51865186

51875187
// Compile condition.
@@ -5258,7 +5258,7 @@ bool Compiler<Emitter>::visitWhileStmt(const WhileStmt *S) {
52585258
{
52595259
LocalScope<Emitter> CondScope(this);
52605260
if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt())
5261-
if (!visitDeclStmt(CondDecl, /*EvaluateConditionDecl=*/false))
5261+
if (!visitDeclStmt(CondDecl))
52625262
return false;
52635263

52645264
if (!this->visitBool(Cond))
@@ -5340,7 +5340,7 @@ bool Compiler<Emitter>::visitForStmt(const ForStmt *S) {
53405340
{
53415341
LocalScope<Emitter> CondScope(this);
53425342
if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt())
5343-
if (!visitDeclStmt(CondDecl, /*EvaluateConditionDecl=*/false))
5343+
if (!visitDeclStmt(CondDecl))
53445344
return false;
53455345

53465346
if (Cond) {
@@ -5468,7 +5468,7 @@ bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
54685468
return false;
54695469

54705470
if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt())
5471-
if (!visitDeclStmt(CondDecl, /*EvaluateConditionDecl=*/false))
5471+
if (!visitDeclStmt(CondDecl))
54725472
return false;
54735473

54745474
// Initialize condition variable.

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
213213

214214
// Statements.
215215
bool visitCompoundStmt(const CompoundStmt *S);
216-
bool visitDeclStmt(const DeclStmt *DS, bool EvaluateConditionDecl);
216+
bool visitDeclStmt(const DeclStmt *DS, bool EvaluateConditionDecl = false);
217217
bool visitReturnStmt(const ReturnStmt *RS);
218218
bool visitIfStmt(const IfStmt *IS);
219219
bool visitWhileStmt(const WhileStmt *S);

clang/lib/AST/ExprConstant.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5222,7 +5222,7 @@ static bool EvaluateDecompositionDeclInit(EvalInfo &Info,
52225222
const DecompositionDecl *DD);
52235223

52245224
static bool EvaluateDecl(EvalInfo &Info, const Decl *D,
5225-
bool EvaluateConditionDecl) {
5225+
bool EvaluateConditionDecl = false) {
52265226
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
52275227
if (!EvaluateVarDecl(Info, VD))
52285228
return false;
@@ -5260,8 +5260,7 @@ static bool EvaluateCond(EvalInfo &Info, const VarDecl *CondDecl,
52605260
if (Cond->isValueDependent())
52615261
return false;
52625262
FullExpressionRAII Scope(Info);
5263-
if (CondDecl &&
5264-
!EvaluateDecl(Info, CondDecl, /*EvaluateConditionDecl=*/false))
5263+
if (CondDecl && !EvaluateDecl(Info, CondDecl))
52655264
return false;
52665265
if (!EvaluateAsBooleanCondition(Cond, Result, Info))
52675266
return false;
@@ -5342,8 +5341,7 @@ static EvalStmtResult EvaluateSwitch(StmtResult &Result, EvalInfo &Info,
53425341

53435342
FullExpressionRAII CondScope(Info);
53445343
if (SS->getConditionVariable() &&
5345-
!EvaluateDecl(Info, SS->getConditionVariable(),
5346-
/*EvaluateConditionDecl=*/false))
5344+
!EvaluateDecl(Info, SS->getConditionVariable()))
53475345
return ESR_Failed;
53485346
if (SS->getCond()->isValueDependent()) {
53495347
// We don't know what the value is, and which branch should jump to.

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
894894
EmitStmt(S.getInit());
895895

896896
if (S.getConditionVariable())
897-
EmitDecl(*S.getConditionVariable(), /*EvaluateConditionDecl=*/false);
897+
EmitDecl(*S.getConditionVariable());
898898

899899
// If the condition constant folds and can be elided, try to avoid emitting
900900
// the condition and the dead arm of the if/else.
@@ -1100,7 +1100,7 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
11001100
RunCleanupsScope ConditionScope(*this);
11011101

11021102
if (S.getConditionVariable())
1103-
EmitDecl(*S.getConditionVariable(), /*EvaluateConditionDecl=*/false);
1103+
EmitDecl(*S.getConditionVariable());
11041104

11051105
// Evaluate the conditional in the while header. C99 6.8.5.1: The
11061106
// evaluation of the controlling expression takes place before each
@@ -1319,7 +1319,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
13191319
// If the for statement has a condition scope, emit the local variable
13201320
// declaration.
13211321
if (S.getConditionVariable()) {
1322-
EmitDecl(*S.getConditionVariable(), /*EvaluateConditionDecl=*/false);
1322+
EmitDecl(*S.getConditionVariable());
13231323

13241324
// We have entered the condition variable's scope, so we're now able to
13251325
// jump to the continue block.
@@ -1679,7 +1679,7 @@ void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
16791679
EmitStopPoint(&S);
16801680

16811681
for (const auto *I : S.decls())
1682-
EmitDecl(*I);
1682+
EmitDecl(*I, /*EvaluateConditionDecl=*/true);
16831683
}
16841684

16851685
void CodeGenFunction::EmitBreakStmt(const BreakStmt &S) {
@@ -2244,7 +2244,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
22442244
// Emit the condition variable if needed inside the entire cleanup scope
22452245
// used by this special case for constant folded switches.
22462246
if (S.getConditionVariable())
2247-
EmitDecl(*S.getConditionVariable(), /*EvaluateConditionDecl=*/false);
2247+
EmitDecl(*S.getConditionVariable());
22482248

22492249
if (auto *DD =
22502250
dyn_cast_if_present<DecompositionDecl>(S.getConditionVariable()))
@@ -2278,7 +2278,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
22782278
EmitStmt(S.getInit());
22792279

22802280
if (S.getConditionVariable())
2281-
EmitDecl(*S.getConditionVariable(), /*EvaluateConditionDecl=*/false);
2281+
EmitDecl(*S.getConditionVariable());
22822282
llvm::Value *CondV = EmitScalarExpr(S.getCond());
22832283

22842284
if (auto *DD =

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3377,7 +3377,7 @@ class CodeGenFunction : public CodeGenTypeCache {
33773377
/// EmitDecl - Emit a declaration.
33783378
///
33793379
/// This function can be called with a null (unreachable) insert point.
3380-
void EmitDecl(const Decl &D, bool EvaluateConditionDecl = true);
3380+
void EmitDecl(const Decl &D, bool EvaluateConditionDecl = false);
33813381

33823382
/// EmitVarDecl - Emit a local variable declaration.
33833383
///

0 commit comments

Comments
 (0)