[clang] Fix analyzer crash on 'StructuralValue' (PR #79764)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 02:54:52 PST 2024


================
@@ -40,8 +40,12 @@ static const Expr *ignoreTransparentExprs(const Expr *E) {
 
   switch (E->getStmtClass()) {
   case Stmt::OpaqueValueExprClass:
-    E = cast<OpaqueValueExpr>(E)->getSourceExpr();
-    break;
+    if (const clang::Expr *SE = cast<OpaqueValueExpr>(E)->getSourceExpr()) {
+      E = SE;
+      break;
+    } else {
+      return E;
+    }
----------------
steakhal wrote:

```suggestion
    if (const auto *SE = cast<OpaqueValueExpr>(E)->getSourceExpr()) {
      E = SE;
      break;
    }
    return E;
```
Fix `else-after-break`.
Use `auto` after `cast<>`.

https://github.com/llvm/llvm-project/pull/79764


More information about the cfe-commits mailing list