Skip to content

Commit

Permalink
Verify if an expr contains errors before checking invertibility (#1154)
Browse files Browse the repository at this point in the history
The community has introduced a new annotation called "contains-errors" on AST
nodes that contain semantic errors. As a result, after the upgrade of Checked C
sources to LLVM 12 we need to check if an expr contains errors before operating
on the expr. One such place is in InverseUtil::IsInvertible where we need to
check if the input modifying expr contains errors.

* Added containsErrors checks to InverUtil::Inverse
  • Loading branch information
Mandeep Singh Grang committed Aug 12, 2021
1 parent 363760d commit 35fbbde
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions clang/lib/AST/ExprUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void ExprUtil::EnsureEqualBitWidths(llvm::APSInt &A, llvm::APSInt &B) {
}

bool InverseUtil::IsInvertible(Sema &S, Expr *LValue, Expr *E) {
if (!E)
if (!E || E->containsErrors())
return false;

E = E->IgnoreParens();
Expand Down Expand Up @@ -628,7 +628,10 @@ bool InverseUtil::IsCastExprInvertible(Sema &S, Expr *LValue, CastExpr *E) {
}

Expr *InverseUtil::Inverse(Sema &S, Expr *LValue, Expr *F, Expr *E) {
if (!F)
if (!F || F->containsErrors())
return nullptr;

if (!E || E->containsErrors())
return nullptr;

E = E->IgnoreParens();
Expand Down

0 comments on commit 35fbbde

Please sign in to comment.