summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-08-29 20:37:28 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-08-29 20:37:28 +0000
commite5c0994ddfcf64bbc7e65ebb68890e98141b84d9 (patch)
tree24cc6e0a6cfe5c838f51e883c5e1b374acfa2e26 /clang/lib/Analysis
parentfe47ed67fcca1ab5bcb0feb65c6b608137d91140 (diff)
downloadbcm5719-llvm-e5c0994ddfcf64bbc7e65ebb68890e98141b84d9.tar.gz
bcm5719-llvm-e5c0994ddfcf64bbc7e65ebb68890e98141b84d9.zip
[CFG] Fix CFG for statement-expressions in return values.
We're building the CFG from bottom to top, so when the return-value expression has a non-trivial CFG on its own, we need to continue building from the entry to the return-value expression CFG rather than from the block to which we've just appended the return statement. Fixes a false positive warning "control may reach end of non-void function". llvm-svn: 370406
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/CFG.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index e4ed0f86b91..fb835d43680 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2994,9 +2994,8 @@ CFGBlock *CFGBuilder::VisitReturnStmt(Stmt *S) {
// Visit children
if (ReturnStmt *RS = dyn_cast<ReturnStmt>(S)) {
- Expr *O = RS->getRetValue();
- if (O)
- Visit(O, AddStmtChoice::AlwaysAdd, /*ExternallyDestructed=*/true);
+ if (Expr *O = RS->getRetValue())
+ return Visit(O, AddStmtChoice::AlwaysAdd, /*ExternallyDestructed=*/true);
return Block;
} else { // co_return
return VisitChildren(S);
OpenPOWER on IntegriCloud