aaron.ballman added inline comments.

================
Comment at: clang-tidy/bugprone/IoFunctionsCheck.cpp:32
+                has(cxxMemberCallExpr(
+                    on(hasType(namedDecl(hasAnyName("istream")))),
+                    callee(cxxMethodDecl(hasName("get")).bind("DeclOfGet"))))),
----------------
`::std::istream`


================
Comment at: clang-tidy/bugprone/IoFunctionsCheck.cpp:47-49
+      "consider to cast the return value of %0 from type integer to type char, 
"
+      "possible loss of precision if an error has occurred or the end "
+      "of file has been reached");
----------------
This diagnostic confuses me, so perhaps you can explain the situation you want 
to diagnose a bit further.

FIO34-C is about situations where `sizeof(char) == sizeof(int)` and the call 
returns EOF/WEOF. In that case, there's no way to distinguish between an 
EOF/error and a valid character. Suggesting to explicitly cast to a character 
type doesn't add any safety to the code -- the user needs to insert calls to 
`feof()` or `ferror()` instead (to make it portable, anyway) and should store 
the character value in a sufficiently large integer type before doing the 
comparison against EOF.

Are you trying to catch a different kind of bug?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D42682/new/

https://reviews.llvm.org/D42682



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to