This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Adding Fuchsia checker for human-readable logging
AbandonedPublic

Authored by juliehockett on Apr 9 2018, 5:26 PM.

Details

Summary

Adds a checker to the Fuchsia module to flag instances of attempting to log the system's numerical representation of the status, instead of the more human-friendly string representation. Matches formatting functions (the printf family and a set of user-specified formatting-like ones) that have a zx_status_t parameter and suggests a fixit to replace the zx_status_t parameter with a call to zx_status_get_string(param).

Diff Detail

Event Timeline

juliehockett created this revision.Apr 9 2018, 5:26 PM
JonasToth added inline comments.Apr 10 2018, 10:17 AM
clang-tidy/zircon/HumanReadableStatusCheck.cpp
68

Did you consider using forEachArgumentWithParam matcher?

I think you could match any zx_status_t argument for the formatter functions and bind on them.

103

Is this required as member function? You can make that static (or move into an unnamed namespace, not 100% sure about the ruling in llvm)

108

That does not consider \% and would be buggy for such fmt strings

112

I think this replacement strategy is not general enough.

http://www.cplusplus.com/reference/cstdio/printf/

%[flags][width][.precision][length]specifier

If we decide to implement an actual printf-fmt string replacer that could maybe land in utility.

I assume that %d is the format specification used for 99,99% of all relevant calls?! Maybe it is enough anyway, because the check matches on very specific %d arguments.
What about the other integer formats? Any chance they are used?

docs/ReleaseNotes.rst
202

Please add a short describing sentence.

204

This seems to be slipped through.

test/clang-tidy/zircon-human-readable-status.cpp
68

Please add test with escaped % and other crazy format strings.

How are advanced format strings treated? I think it is necessary to do better parsing.

Eugene.Zelenko added inline comments.
docs/clang-tidy/checks/zircon-human-readable-status.rst
6

Please highlight zx_status_t and other identifiers with ``.

juliehockett abandoned this revision.Jun 19 2018, 4:52 PM