[PATCH] D110656: [clang][Sema] Warn on uninitialized array elments

Chris Bieneman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 30 14:29:26 PDT 2021


beanz added a comment.

In D110656#3034083 <https://reviews.llvm.org/D110656#3034083>, @xbolva00 wrote:

> Why just no special case "= {0};" pattern and do not warn in that case?

This case did show up, but was not the majority of issues for LLVM (although might be the majority we care about). The related `= {nullptr};` pattern also shows a few times.

> If there are more patterns, take it from other side - pick patterns where you are sure that they are wrong and developer needs to fix them and emit warnings for them.

There are a bunch of places (particularly in LLVM instruction matching), where LLVM generates data structures with statically sized arrays that hold the maximum possible values, and rely on zero-initialized values to denote the end of the used space.

For the tablegen-genreated code wrapping in `pragma`s to disable the warning works, but there isn't really a good way that I can think of to not emit a warning for an array of 10 elements where we provide 6 in a general case while also warning on the actual potential bug.

In D110656#3034149 <https://reviews.llvm.org/D110656#3034149>, @xbolva00 wrote:

> If possible, @beanz could share list of new warnings from LLVM build here?

The big offenders were the tablegen-generated asm and register matchers and the target files under clang/lib/Basic/Targets. Those accounted for filling my scroll back buffer a few times over...

I'm running a new build now disabling the warning int he clang target files to see how that shapes up. Will share what I find.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110656/new/

https://reviews.llvm.org/D110656



More information about the cfe-commits mailing list