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

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 20:00:44 PST 2018


Eugene.Zelenko added inline comments.


================
Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:1
+//===--- StreamInt8Check.cpp - clang-tidy----------------------------------===//
+//
----------------
Please add real description, use space after it and shorten to 80 symbols.


================
Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:25
+        hasArgument(0, expr(hasType(qualType(hasCanonicalType(
+                    hasDeclaration(cxxRecordDecl(hasName("std::basic_ostream")))))))),
+        hasArgument(1, expr(hasType(hasCanonicalType(
----------------
May be match should be configurable, so other streams could be analyzed too? How about LLVM's raw_ostream?


================
Comment at: clang-tidy/bugprone/StreamInt8Check.cpp:36
+    const auto *MatchedExpr = Result.Nodes.getNodeAs<CXXOperatorCallExpr>("oper");
+    const auto *Offender = MatchedExpr->getArg(1);
+
----------------
Please don't use auto in cases where return type could not be easily deduced. See [[http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html|modernize-use-auto]]. Same for //auto Underlying//.


================
Comment at: clang-tidy/bugprone/StreamInt8Check.h:1
+//===--- StreamInt8Check.h - clang-tidy-----------------------*- C++ -*-===//
+//
----------------
Please add real description and use space after it.


================
Comment at: clang-tidy/bugprone/StreamInt8Check.h:19
+
+/// FIXME: Write a short description.
+///
----------------
Please write real description here.


================
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.
----------------
Please move to new checks section in alphabetical order and add one statement description (usually first statement from documentation).


================
Comment at: test/clang-tidy/bugprone-stream-int8.cpp:32
+
+void awesome_f2(std::ostream& os, uint8_t i) {
+    using UC = unsigned char;
----------------
Please use meaningful name or main.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41740





More information about the cfe-commits mailing list