[llvm] llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h: 2 * pointless copy (#94385) (PR #94410)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 11:54:11 PDT 2024


dwblaikie wrote:

I found the code at least ( https://github.com/danmar/cppcheck/blob/e0ce6483a006bf709d4485cb204c19f14656cf1b/lib/checkother.cpp#L1220 - and found a bugfix for the check from a couple of years ago, for `std::string_view` (which is a similar/same size - two pointers) https://github.com/danmar/cppcheck/pull/3817/files#diff-73c7189eeb09cde9a3e544f18ad317cc595f7a316fe720d781e35b7235be71b1 )

I think this check is poorly implemented - the bugfix for std::string_view was to detect if it was a view-like type, for instance. But that's not the property that makes the thing cheap to copy - the property is its size, and the fact it doesn't have a non-trivial copy ctor. And that property would apply equally to this code/the std::array inside it.

Hmm, nope, the code does seem to have a size check (`else if (!var->valueType() || ValueFlow::getSizeOf(*var->valueType(), *mSettings) <= 2 * mSettings->platform.sizeof_pointer)`) - I would've expected that this type would satisfy that requirement... so I wonder why the warning is still firing.

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


More information about the llvm-commits mailing list