[PATCH] D156053: [Clang] Fix crash in CIndex, when visiting a static_assert without message

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 23 07:22:02 PDT 2023


cor3ntin added inline comments.


================
Comment at: clang/tools/libclang/CIndex.cpp:1297
     return true;
-  if (auto *Message = dyn_cast<StringLiteral>(D->getMessage()))
+  if (auto *Message = dyn_cast_if_present<StringLiteral>(D->getMessage()))
     if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
----------------
It's probably better to cast to `Expr` and visit it unconditionally. But it could always be null, so `dyn_cast_if_present` is probably correct.
`dyn_cast_if_present<Expr>` should be what we want then


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156053



More information about the cfe-commits mailing list