This is an archive of the discontinued LLVM Phabricator instance.

[-Wunsafe-buffer-usage] Group diagnostics by variable
ClosedPublic

Authored by jkorous on Jan 9 2023, 11:49 PM.

Details

Summary
  • Add notes to our diagnostics.
  • Change the way we present diagnostic information.
    • For declarations involved in unsafe operations emit a single warning at the variable declaration and attach a per-unsafe-operation note.
    • For unsafe operations that don't refer to a variable emit a per-operation warning.
  • Change wording of our diagnostics.

Diff Detail

Event Timeline

jkorous created this revision.Jan 9 2023, 11:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 11:49 PM
jkorous retitled this revision from [WIP][-Wunsafe-buffer-usage] Group diagnostics by variable to [-Wunsafe-buffer-usage] Group diagnostics by variable.Jan 10 2023, 10:14 AM
jkorous edited the summary of this revision. (Show Details)
NoQ accepted this revision.Jan 12 2023, 9:21 PM

LGTM! I like the new diagnostics a lot better!

clang/include/clang/Basic/DiagnosticSemaKinds.td
11780–11781

Folks asked me to do this in my initial patch, I guess we should preserve the tradition, though of course we're still way past the 80-column limit.

This revision is now accepted and ready to land.Jan 12 2023, 9:21 PM
aaron.ballman added inline comments.Jan 17 2023, 10:37 AM
clang/include/clang/Basic/DiagnosticSemaKinds.td
11780–11781

Errr, not certain where the confusion came in, but the 80-col limit still exists for these files (we are more relaxed in .td files though because clang-format used to really struggle with them).

So I would re-wrap this as:

def warn_unsafe_buffer_variable : Warning<
  "%0 is an %select{unsafe pointer used for buffer access|unsafe buffer that "
  "does not perform bounds checks}1">,
  InGroup<UnsafeBufferUsage>, DefaultIgnore;

and similar for the rest.

jkorous updated this revision to Diff 489936.Jan 17 2023, 1:50 PM
jkorous marked 2 inline comments as done.

Respect 80-char line limit in changes to DiagnosticSemaKinds.td.

This revision was landed with ongoing or failed builds.Jan 18 2023, 3:02 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 3:02 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript