[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 20 02:54:40 PDT 2021


Szelethus added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:380-391
+    if (BT == &BT_UseAfterClose)
+      Message = "Stream closed here";
+    else if (BT == &BT_UseAfterOpenFailed)
+      Message = "Assuming opening the stream fails here";
+    else if (BT == &BT_IndeterminatePosition)
+      Message = "Assuming this stream operation fails";
+    else if (BT == &BT_StreamEof)
----------------
I have ambivalent feelings on this. I see what you are shooting for: display a specific `NoteTag` only for a specific `BugType`, though I wonder whether whether some of these notes would be nice for more than one. The only test case that changed seems to support my theory, or at least I like it better.


================
Comment at: clang/test/Analysis/stream-note.c:36-41
-  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  FILE *F = fopen("file", "r");
   if (!F)
     // expected-note at -1 {{'F' is non-null}}
     // expected-note at -2 {{Taking false branch}}
     return;
-  F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
----------------
I think I preferred this, honestly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262



More information about the cfe-commits mailing list