[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)
Yitzhak Mandelbaum via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 8 04:30:23 PDT 2023
================
@@ -43,7 +43,20 @@ const Environment *StmtToEnvMap::getEnvironment(const Stmt &S) const {
if (!CFCtx.isBlockReachable(*BlockIt->getSecond()))
return nullptr;
const auto &State = BlockToState[BlockIt->getSecond()->getBlockID()];
- assert(State);
+ if (!(State)) {
+ LLVM_DEBUG({
+ // State can be null when this block is unreachable from the block that
+ // called this method.
+ bool hasUnreachableEdgeFromPred = false;
+ for (auto B : BlockIt->getSecond()->preds())
+ if (!B) {
+ hasUnreachableEdgeFromPred = true;
+ break;
+ }
+ assert(hasUnreachableEdgeFromPred);
----------------
ymand wrote:
I agree on leaving it debug only (or removing it entirely).
https://github.com/llvm/llvm-project/pull/65732
More information about the cfe-commits
mailing list