Skip to content

Commit 419fb2a

Browse files
committed
[clang] Changed IsInsideCondition field to private
1 parent 2a06e37 commit 419fb2a

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

clang/include/clang/AST/Expr.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,18 @@ struct SubobjectAdjustment {
109109
/// required.
110110
class Expr : public ValueStmt {
111111
QualType TR;
112+
bool IsInsideCondition;
112113

113114
public:
114115
Expr() = delete;
115116
Expr(const Expr&) = delete;
116117
Expr(Expr &&) = delete;
117118
Expr &operator=(const Expr&) = delete;
118119
Expr &operator=(Expr&&) = delete;
119-
bool isCondition;
120120

121121
protected:
122122
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK)
123-
: ValueStmt(SC), isCondition(false) {
123+
: ValueStmt(SC), IsInsideCondition(false) {
124124
ExprBits.Dependent = 0;
125125
ExprBits.ValueKind = VK;
126126
ExprBits.ObjectKind = OK;
@@ -451,6 +451,16 @@ class Expr : public ValueStmt {
451451
return (OK == OK_Ordinary || OK == OK_BitField);
452452
}
453453

454+
bool isInsideCondition() const {
455+
return IsInsideCondition;
456+
}
457+
458+
/// setValueKind - Mark this expression to be inside a condition.
459+
/// necessary for `warn_assignment_bool_context` diagnostic
460+
void setIsInsideCondition() {
461+
IsInsideCondition = true;
462+
}
463+
454464
/// setValueKind - Set the value kind produced by this expression.
455465
void setValueKind(ExprValueKind Cat) { ExprBits.ValueKind = Cat; }
456466

clang/lib/Sema/Sema.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ void Sema::DiagnoseAssignmentBoolContext(Expr *E, QualType Ty) {
704704
}
705705

706706
// Condition-assignment warnings are already handled by `DiagnoseAssignmentAsCondition()`
707-
if (E->isCondition)
707+
if (E->isInsideCondition())
708708
return;
709709

710710
if (BinaryOperator *Op = dyn_cast<BinaryOperator>(E)) {

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20288,7 +20288,7 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) {
2028820288
ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E,
2028920289
bool IsConstexpr) {
2029020290
DiagnoseAssignmentAsCondition(E);
20291-
E->isCondition = true;
20291+
E->setIsInsideCondition();
2029220292

2029320293
if (ParenExpr *parenE = dyn_cast<ParenExpr>(E))
2029420294
DiagnoseEqualityWithExtraParens(parenE);

0 commit comments

Comments
 (0)