[clang] [analyzer] Fix crash in PaddingChecker on dependent field types (PR #232986)

Manuel Sainz de Baranda y Goñi via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 17 07:13:27 PDT 2026


================
@@ -0,0 +1,7 @@
+// RUN: %clang_analyze_cc1 -std=c++20 -analyzer-checker=optin.performance -verify %s
----------------
redcode wrote:

> Have you used AI, and read the policies around that?

I have not used AI.

> What alternatives have you considered?

To be honest, I picked the field-level check because it was the direct fix for the crash, as it happens while laying out a field whose type is dependent, and `IsTrickyField` is already the place that skips records whose fields can't be laid out. The `isDependentType()` bail-out at the top of `shouldSkipDecl` already exists but was not catching this; I hadn't chased down why at the time. I didn't really weigh the traversal-level option before opening the PR.

> I presume the checker already have at least one test file. I think we should squeeze this into one of those tests and suffix the line with `// no-crash` to illustrate that this used to crash.

I could add it to `clang/test/Analysis/padding_cpp.cpp` but I would need to bump it to C++20, since the repro needs abbreviated function templates. Is it OK?

https://github.com/llvm/llvm-project/pull/232986


More information about the cfe-commits mailing list