================
@@ -13681,12 +13681,13 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
     }
 
     Init = Result.getAs<Expr>();
+    assert(Init && "Init must not be null");
+
     IsParenListInit = !InitSeq.steps().empty() &&
                       InitSeq.step_begin()->Kind ==
                           InitializationSequence::SK_ParenthesizedListInit;
     QualType VDeclType = VDecl->getType();
-    if (Init && !Init->getType().isNull() &&
-        !Init->getType()->isDependentType() && !VDeclType->isDependentType() &&
+    if (!Init->getType()->isDependentType() && !VDeclType->isDependentType() &&
----------------
tahonermann wrote:

I'm uncertain about this change. On the one hand, the assignment to `Init` 
looks to me like it must produce a non-null result due to the prior check to 
`Result.isInvalid()`. However, the following uses of `Init` were already 
guarded by a check for a non-null value, so the static analysis tool should not 
have complained about those.

Was the static analysis tool perhaps complaining about later uses of `Init`? 
Note that the assignment at line 13683 above is conditional (on 
`!VDecl->isInvalidDecl()`) and therefore might not suffice to ensure a definite 
non-null value. I haven't checked exhaustively if that is the case though.

https://github.com/llvm/llvm-project/pull/94368
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to