This is an archive of the discontinued LLVM Phabricator instance.

[Analysis][CFG] Fix CFG building for standalone `CaseStmt`s.
Needs ReviewPublic

Authored by courbet on Oct 6 2021, 12:59 AM.

Details

Reviewers
Szelethus
NoQ
Summary

One is supposed ot be able to create a CFG for any statement, as per the
comment on CFGBuilder::buildCFG:

"The AST can represent an arbitrary statement. Examples include a single
expression or a function body (compound statement)"

When building a CFG from a CaseStmt, we currently have a crash:

clang/lib/Analysis/CFG.cpp:4242: clang::CFGBlock *(anonymous
namespace)::CFGBuilder::VisitCaseStmt(clang::CaseStmt *): Assertion
`SwitchTerminatedBlock' failed.

Add a unit test to show this, and avoid updating the parent SwitchStmt
block when none exists.

Diff Detail

Event Timeline

courbet requested review of this revision.Oct 6 2021, 12:59 AM
courbet created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2021, 12:59 AM
courbet updated this revision to Diff 377457.Oct 6 2021, 1:01 AM

remove accidental paste