[PATCH] D122285: [analyzer] Add path note tags to standard library function summaries.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 22:00:23 PDT 2022


NoQ created this revision.
NoQ added reviewers: t-rasmud, Szelethus, martong, steakhal, ASDenysPetrov, balazske, gamesh411.
Herald added subscribers: manas, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
NoQ requested review of this revision.

This is a solution to the issue with `getenv()` (https://github.com/llvm/llvm-project/issues/53276) but I covered a few more functions just because I could.

The patch is straightforward except the tiny fix in `BugReporterVisitors.cpp` that suppresses a default note for "Assuming pointer value is null" when a note tag from the checker is present. This is probably the right thing to do but also definitely not a complete solution to the problem of different sources of path notes being unaware of each other, which is a large and annoying issue that we have to deal with. Note tags really help there because they're nicely introspectable. The problem is demonstrated by the newly added `getenv()` test; I did not investigate why doesn't the original buggy report have the same note but I agree that this might be interesting to figure out.

The notes are currently optional but I think we should eventually implement all of them and then make them mandatory.

The notes are prunable, i.e. they won't bring-in entire stack frames worth of notes just because they're there, but they will be always visible regardless of whether the value is of interest to the bug report. I think this is debatable, the arguably better solution is to make them non-prunable but conditional to the value being tracked back to the call, which would probably need a better tracking infrastructure.


Repository:
  rC Clang

https://reviews.llvm.org/D122285

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-path-notes.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122285.417491.patch
Type: text/x-patch
Size: 19049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220323/ea9fc63a/attachment-0001.bin>


More information about the cfe-commits mailing list