[-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream
authorziqingluo-90 <ziqing@udel.edu>
Tue, 14 Mar 2023 00:17:30 +0000 (17:17 -0700)
committerziqingluo-90 <ziqing@udel.edu>
Tue, 14 Mar 2023 00:22:22 +0000 (17:22 -0700)
commit148dc8a2a80f6b4ab80914c153279205a78315ed
tree702287664b78c4f7b8483dd18c7e1f05fedd0835
parent93a455375c0fa1dd014a3b4571b22e307d15bbf7
[-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream

The -Wunsafe-buffer-usage analysis outputs diagnostics in the order of
pointer values to associated `VarDecl`s. This creates non-determinism
in the order of diagnostics in output since the order cannot be
guaranteed in pointer values. However, our fix-it tests were written
under the assumption that diagnostics are output in source location
order.  This results in non-deterministic failures in our tests.  This
patch fixes the problem by keeping analysis results sorted by source
locations.

Reviewed by: jkorous, NoQ

Differential revision: https://reviews.llvm.org/D145993
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp