[Clang] Control-flow analysis around expansion statements could be better
Nobody has claimed this yet.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Concretely, consider (https://godbolt.org/z/e75Kx1WMr)
int f() {
template for (int x : {1}) {
return 4;
}
}
which currently results in a warning
<source>:5:1: warning: non-void function does not return a value [-Wreturn-type]
5 | }
| ^
despite the fact that we do in fact always return here, as the expansion statement effectively expands to
int f() {
{
{
int x = 1;
return 4;
}
}
}
which we don’t warn about. Presumably, the fix is that we should probably be walking the CXXExpansionStmtInstantiation of an expansion statement rather than the pattern.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Godbolt example linked in the issue and trace Clang's control-flow analysis for the expansion statement. Compare how analysis treats the CXXExpansionStmtInstantiation with how it treats the pattern. Done means the shown function is recognized as always returning and no longer produces the -Wreturn-type warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100