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).
Details
Diff Detail
Event Timeline
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. | |
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. |
docs/clang-tidy/checks/zircon-human-readable-status.rst | ||
---|---|---|
6 | Please highlight zx_status_t and other identifiers with ``. |
Did you consider using forEachArgumentWithParam matcher?
I think you could match any zx_status_t argument for the formatter functions and bind on them.