[clang] Suppress safe constant pointer arithmetic under -Wno-unsafe-buffer-usage-in-static-sized-array (#212322)
Previously, the opt-out flag only suppressed subscript access warnings
on static arrays, but did not suppress pointer arithmetic warnings,
leaving many false positives.
With this change:
If the flag is enabled, pointer arithmetic is suppressed ONLY if the
compiler can statically prove that the offset is a non-negative constant
strictly within the bounds of the array (offset < size). All dynamic
pointer arithmetic, one-past-the-end calculations, and out-of-bounds
constants continue to emit warnings.
Partially addresses #87284.
_Disclosure: An AI coding assistant (Google Gemini) was used to draft
the initial implementation but the final logic in this PR was rewritten
by hand._