[all-commits] [llvm/llvm-project] 8874ad: [clang] Fix -Wreturn-type false positive in @try s...
Nico Weber via All-commits
all-commits at lists.llvm.org
Sun Nov 28 09:57:09 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8874ada906f6a2ae0c4aa978581a0c9c26b89ffd
https://github.com/llvm/llvm-project/commit/8874ada906f6a2ae0c4aa978581a0c9c26b89ffd
Author: Nico Weber <thakis at chromium.org>
Date: 2021-11-28 (Sun, 28 Nov 2021)
Changed paths:
M clang/lib/Sema/AnalysisBasedWarnings.cpp
A clang/test/SemaObjC/return-noreturn.m
Log Message:
-----------
[clang] Fix -Wreturn-type false positive in @try statements
After 04f30795f16638, -Wreturn-type has an effect on functions that
contain @try/@catch statements. CheckFallThrough() was missing
a case for ObjCAtTryStmts, leading to a false positive.
(What about the other two places in CheckFallThrough() that handle
CXXTryStmt but not ObjCAtTryStmts?
- I think the last use of CXXTryStmt is dead in practice: 04c6851cd made it so
that calls never add edges to try bodies, and the CFG block for a try
statement is always an empty block containing just the try element itself as
terminator (the try body itself is part of the normal flow of the function
and not connected to the block for the try statement itself. The try statment
cfg block is only connected to the catch bodies, and only reachable from
throw expressions within the try body.)
- The first use of CXXTryStmt might be important. It looks similar to
the code that adds all cfg blocks for try statements as roots of
the reachability graph for the reachability warnings, but I can't
find a way to trigger it. So I'm omitting it for now. The CXXTryStmt
code path seems to only be hit by try statements that are function
bodies without a surrounding compound statements
(`f() try { ... } catch ...`), and those don't exist for ObjC
@try statements.
)
Fixes PR52473.
Differential Revfision: https://reviews.llvm.org/D114660
More information about the All-commits
mailing list