- Non-null checking is triggered during prototype substitution from a template instantiation, if expressions in decltype contains nullptr chcking. Skip non-null checking in that case as the protype is not finalized yet. Also, the nullptr checking in decltype is only used for type inspection instead of codegen. Ignoring that is harmless.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 29705 Build 29704: arc lint + arc unit
Event Timeline
just explain what's the issue is and hope that help reviewers to get this fix quick.
- In Sema::DiagnoseAlwaysNonNullPointer, we issue warnings if a nonnull parameter is used in null checking. It need the function declaration to check parameter attributes. That usually works but fails if that function decl is not ready yet.
- In template instantiation, we first create the function prototype followed by instantiating the function body. When the function prototype is being formed, we may create binary or other expressions for semantic checking. But, in that phase, i.e. Sema::SubstFunctionDeclType, we don't have a fully specialized function prototype yet to check the parameter number and run into the assertion @ line 11596.
Hope that help to get the picture of this fix. Thanks.
clang/test/SemaTemplate/decltype.cpp | ||
---|---|---|
1 | test/SemaCXX/nonnull.cpp tests attribute((nonnull)). Placing this test there would be... odd. The test could use a more descriptive name, though. Just decltype is way too generic. early-func-template-decltype? Or PR-somthing-something, if there's a bug for this crasher. |
just search bugzilla and, fortunately, found this issue is reported 2+ years ago @ https://bugs.llvm.org/show_bug.cgi?id=30559. I will revise the test case to PR30559 and move it into test/SemaCXX/nonnull.cpp
test/SemaCXX/nonnull.cpp would be a better place to put this test.