forked from OSchip/llvm-project
Improve CheckFallThrough analysis in the presense of the new C++ EH
support. WIP. llvm-svn: 93956
This commit is contained in:
parent
9074c3fe97
commit
06b602e540
|
|
@ -1496,6 +1496,7 @@ Sema::ControlFlowKind Sema::CheckFallThrough(AnalysisContext &AC) {
|
||||||
bool HasLiveReturn = false;
|
bool HasLiveReturn = false;
|
||||||
bool HasFakeEdge = false;
|
bool HasFakeEdge = false;
|
||||||
bool HasPlainEdge = false;
|
bool HasPlainEdge = false;
|
||||||
|
bool HasAbnormalEdge = false;
|
||||||
for (CFGBlock::pred_iterator I=cfg->getExit().pred_begin(),
|
for (CFGBlock::pred_iterator I=cfg->getExit().pred_begin(),
|
||||||
E = cfg->getExit().pred_end();
|
E = cfg->getExit().pred_end();
|
||||||
I != E;
|
I != E;
|
||||||
|
|
@ -1528,9 +1529,17 @@ Sema::ControlFlowKind Sema::CheckFallThrough(AnalysisContext &AC) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isa<CXXTryStmt>(S)) {
|
||||||
|
HasAbnormalEdge = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bool NoReturnEdge = false;
|
bool NoReturnEdge = false;
|
||||||
if (CallExpr *C = dyn_cast<CallExpr>(S)) {
|
if (CallExpr *C = dyn_cast<CallExpr>(S)) {
|
||||||
|
if (B.succ_begin()[0] != &cfg->getExit()) {
|
||||||
|
HasAbnormalEdge = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Expr *CEE = C->getCallee()->IgnoreParenCasts();
|
Expr *CEE = C->getCallee()->IgnoreParenCasts();
|
||||||
if (CEE->getType().getNoReturnAttr()) {
|
if (CEE->getType().getNoReturnAttr()) {
|
||||||
NoReturnEdge = true;
|
NoReturnEdge = true;
|
||||||
|
|
@ -1552,7 +1561,7 @@ Sema::ControlFlowKind Sema::CheckFallThrough(AnalysisContext &AC) {
|
||||||
return NeverFallThrough;
|
return NeverFallThrough;
|
||||||
return NeverFallThroughOrReturn;
|
return NeverFallThroughOrReturn;
|
||||||
}
|
}
|
||||||
if (HasFakeEdge || HasLiveReturn)
|
if (HasAbnormalEdge || HasFakeEdge || HasLiveReturn)
|
||||||
return MaybeFallThrough;
|
return MaybeFallThrough;
|
||||||
// This says AlwaysFallThrough for calls to functions that are not marked
|
// This says AlwaysFallThrough for calls to functions that are not marked
|
||||||
// noreturn, that don't return. If people would like this warning to be more
|
// noreturn, that don't return. If people would like this warning to be more
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue