[PATCH] D156274: [NFC] Avoid potential dereferencing of nullptr.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 26 11:32:01 PDT 2023


efriedma added inline comments.


================
Comment at: clang/lib/AST/ItaniumMangle.cpp:1659
       mangleCXXDtorType(Dtor_Complete);
+    assert(ND);
     writeAbiTags(ND, AdditionalAbiTags);
----------------
aaron.ballman wrote:
> This seems incorrect -- if the declaration name is a destructor, then `ND` should always be null, right?
Seems okay to me?  ND is the destructor declaration.


================
Comment at: clang/lib/CodeGen/CGObjCMac.cpp:1806
     // Complex types.
+    assert(contBB);
     CGF.EmitBlock(contBB);
----------------
aaron.ballman wrote:
> Hmmm, is assert the correct approach here? It seems to me that a Complex rvalue will trigger this assertion. I think this deserves some additional thinking rather than silencing the static analysis warning. CC @efriedma @rjmccall who might have ideas.
Yes, if a complex value hit this codepath with a null contBB, it would just crash, so the analysis is flagging a real issue.

I'm not sure how to write ObjC code to actually trigger this codepath, though.  Probably involves a `_Complex _BitInt(128)` or something like that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156274/new/

https://reviews.llvm.org/D156274



More information about the cfe-commits mailing list