[PATCH] D35068: [analyzer] Detect usages of unsafe I/O functions

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 28 16:09:59 PST 2019


NoQ accepted this revision.
NoQ added a comment.

Ok! I hope that the C11 check would do the trick, let's see how it goes :)

In D35068#1364947 <https://reviews.llvm.org/D35068#1364947>, @xazax.hun wrote:

> What do we want to validate here? The lack of crashes? Or evaluate false positive ratio?


This checker is opt-in, but it still has a notion of a useless positive, and it is something that can often be improved upon. Crashes are also a great thing to look for :)

In D35068#1364948 <https://reviews.llvm.org/D35068#1364948>, @xazax.hun wrote:

> To add an analogy, Clang Tidy will not require C++ Core Guidelines related checks to be evaluated on projects that are not following the guidelines as the results are meaningless for those projects.


On the contrary, figuring out if the project follows C++ Core Guidelines is pretty hard. Well, it's often pretty easy to demonstrate that it doesn't (: But, i mean, the intention.



================
Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:597-598
+
+  if(!BR.getContext().getLangOpts().C11)
+    return;
+
----------------
xazax.hun wrote:
> koldaniel wrote:
> > NoQ wrote:
> > > Note that you cannot easily figure out if the code is intended to get compiled only under C11 and above - maybe it's accidentally compiled under C11 for this user, but is otherwise intended to keep working under older standards.
> > It is a possible scenario, how should I check if the checks should warn (safe functions are available) if not by using this method?
> This is the same approach some check takes in clang tidy. I think it is still better to not warn for non C11 users than warn for everybody. If a project is not interested in this check but they are interested in having C11 builds, they can turn this check off. (Or it can be off by default in the first place).
Hmm, i guess in many cases such clients may suppress the warning through preprocessing. This will keep the checker warning in C11 builds but would also avoid miscompiles in builds for the older standards.


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

https://reviews.llvm.org/D35068





More information about the cfe-commits mailing list