This is an archive of the discontinued LLVM Phabricator instance.

[clang][tablegen] adds human documentation to `WarningOption`
ClosedPublic

Authored by cjdb on Jun 1 2022, 3:19 PM.

Details

Summary

Building on D126796, this commit adds the infrastructure for being able
to print out descriptions of what each warning does.

Diff Detail

Event Timeline

cjdb created this revision.Jun 1 2022, 3:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 3:19 PM
cjdb requested review of this revision.Jun 1 2022, 3:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 3:19 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Can you post some examples of the output from this option so we can see what the end results look like more easily?

cjdb added a comment.Jun 2 2022, 3:23 PM

Can you post some examples of the output from this option so we can see what the end results look like more easily?

Right now this doesn't do anything at all, except feed the documentation from tablegen to Clang. It's just taking the text (represented by ...) from code Documentation [{...}], trimming any surrounding spaces, and putting that into DIAG_ENTRY.

e.g.

code Documentation [{
  Hello, world!

  Goodbye, world!
}]

would be forwarded as "Hello, world!\n\n Goodbye, world!"

Can you post some examples of the output from this option so we can see what the end results look like more easily?

Right now this doesn't do anything at all, except feed the documentation from tablegen to Clang. It's just taking the text (represented by ...) from code Documentation [{...}], trimming any surrounding spaces, and putting that into DIAG_ENTRY.

e.g.

code Documentation [{
  Hello, world!

  Goodbye, world!
}]

would be forwarded as "Hello, world!\n\n Goodbye, world!"

Thanks, that helps me to visualize what's going on. Any thoughts on how we could test this functionality, or are we going to assume that the testing comes from its usage when we actually make use of the new information threaded in?

clang/lib/Basic/DiagnosticIDs.cpp
628
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
1550–1553

Isn't this functionally equivalent? (It means we're using a raw empty string rather than a normal empty string, but that shouldn't matter.)

cjdb updated this revision to Diff 435255.Jun 8 2022, 10:58 AM
cjdb marked 2 inline comments as done.

applies feedback

cjdb added a comment.Jun 8 2022, 11:03 AM

Can you post some examples of the output from this option so we can see what the end results look like more easily?

Right now this doesn't do anything at all, except feed the documentation from tablegen to Clang. It's just taking the text (represented by ...) from code Documentation [{...}], trimming any surrounding spaces, and putting that into DIAG_ENTRY.

e.g.

code Documentation [{
  Hello, world!

  Goodbye, world!
}]

would be forwarded as "Hello, world!\n\n Goodbye, world!"

Thanks, that helps me to visualize what's going on. Any thoughts on how we could test this functionality, or are we going to assume that the testing comes from its usage when we actually make use of the new information threaded in?

Good question. Unless this functionality already has tests (and I'm gathering it doesn't), I think we can rely on Clang being the test. (Though we should consider ourselves on notice for adding robust unit tests at some point.)

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
1550–1553

Wow, I can no longer say I've never done if (condition) return true; else return false; 😂

aaron.ballman accepted this revision.Jun 9 2022, 10:01 AM

Good question. Unless this functionality already has tests (and I'm gathering it doesn't), I think we can rely on Clang being the test. (Though we should consider ourselves on notice for adding robust unit tests at some point.)

I don't know of tests for it, so I'm okay with that approach. LGTM!

This revision is now accepted and ready to land.Jun 9 2022, 10:01 AM
This revision was landed with ongoing or failed builds.Jun 10 2022, 10:23 AM
This revision was automatically updated to reflect the committed changes.