forked from OSchip/llvm-project
Fix null dereference in CFGBlock::FilterEdge that was reported in PR 9412.
llvm-svn: 127176
This commit is contained in:
parent
df61694417
commit
897947434e
|
@ -2927,15 +2927,15 @@ unsigned CFG::getNumBlkExprs() {
|
|||
bool CFGBlock::FilterEdge(const CFGBlock::FilterOptions &F,
|
||||
const CFGBlock *From, const CFGBlock *To) {
|
||||
|
||||
if (F.IgnoreDefaultsWithCoveredEnums) {
|
||||
if (To && F.IgnoreDefaultsWithCoveredEnums) {
|
||||
// If the 'To' has no label or is labeled but the label isn't a
|
||||
// CaseStmt then filter this edge.
|
||||
if (const SwitchStmt *S =
|
||||
dyn_cast_or_null<SwitchStmt>(From->getTerminator().getStmt())) {
|
||||
dyn_cast_or_null<SwitchStmt>(From->getTerminator().getStmt())) {
|
||||
if (S->isAllEnumCasesCovered()) {
|
||||
const Stmt *L = To->getLabel();
|
||||
if (!L || !isa<CaseStmt>(L))
|
||||
return true;
|
||||
const Stmt *L = To->getLabel();
|
||||
if (!L || !isa<CaseStmt>(L))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,3 +52,18 @@ void test_typedefs() {
|
|||
PR9380_Ty test2[20];
|
||||
}
|
||||
|
||||
// PR9412 - Handle CFG traversal with null successors.
|
||||
enum PR9412_MatchType { PR9412_Exact };
|
||||
|
||||
template <PR9412_MatchType type> int PR9412_t() {
|
||||
switch (type) {
|
||||
case PR9412_Exact:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} // expected-warning {{control reaches end of non-void function}}
|
||||
|
||||
void PR9412_f() {
|
||||
PR9412_t<PR9412_Exact>(); // expected-note {{in instantiation of function template specialization 'PR9412_t<0>' requested here}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue