[PATCH] D41740: [clang-tidy] Adding a new bugprone check for streaming objects of type int8_t or uint8_t

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 23:28:50 PST 2018

JonasToth added inline comments.

Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:26
+                    hasDeclaration(cxxRecordDecl(hasName("std::basic_ostream")))))))),
+        hasArgument(1, expr(hasType(hasCanonicalType(
+                    anyOf(asString("signed char"),
You can use `bind` for the `expr` and get `Offender` from it.

Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:41
+        if (Name == "uint8_t") {
+            diag(Offender->getLocStart(), "streaming uint8_t");
+            break;
The duplicated `diag` can be removed. You can use placeholders in `diag` and make the if include both types.
See https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp#L246

I think having a list of possible typedefnames would be nice. Some projects might not use the standard ones (e.g. Qt?).

Comment at: docs/ReleaseNotes.rst:62
+  <http://clang.llvm.org/extra/clang-tidy/checks/bugprone-stream-int8_t.html>`_ check
 - New module `fuchsia` for Fuchsia style checks.
Eugene.Zelenko wrote:
> Please move to new checks section in alphabetical order and add one statement description (usually first statement from documentation).
Since the branch occured it might be better to rebase first. Then the Release Notes are empty.

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list