[PATCH] D42682: [clang-tidy] Add misc-io-functions-misused checker

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 31 04:05:02 PST 2018


alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang-tidy/misc/IoFunctionsMisusedCheck.cpp:33
+              has(cxxMemberCallExpr(
+                  on(hasType(namedDecl(matchesName("istream")))),
+                  callee(cxxMethodDecl(hasName("get")).bind("Decl"))))),
----------------
`matchesName` can be pretty expensive and should generally be avoided. What set of types should be matched here? Can they all be listed here (using hasAnyName)?


================
Comment at: clang-tidy/misc/IoFunctionsMisusedCheck.cpp:43-46
+  const auto *FuncDeclInStd =
+      Result.Nodes.getNodeAs<FunctionDecl>("FuncDeclInStd");
+  const auto *FuncDeclInGlobal =
+      Result.Nodes.getNodeAs<FunctionDecl>("FuncDeclInGlobal");
----------------
It looks like the code doesn't need to distinguish between these two. They can be bound to the same ID then.


================
Comment at: clang-tidy/misc/IoFunctionsMisusedCheck.h:19
+
+/// This checker warns for cases when the return value of certain standard
+/// iostream C functions (fgetwc, getwc, getwchar, istream::get()) return int
----------------
s/checker/check/


================
Comment at: docs/clang-tidy/checks/misc-io-functions-misused.rst:26-27
+	char c;
+c = is.get();                   // Warning about incorrectly stored int value
+        c = ownnamespace::get() // Won't warn
+	
----------------
The formatting is off.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42682





More information about the cfe-commits mailing list