[PATCH] D132017: [clang][analyzer] Add errno modeling to StreamChecker
    Balázs Benics via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Wed Aug 17 02:58:20 PDT 2022
    
    
  
steakhal added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:283-284
 
+  mutable bool EofInitialized = false;
+  mutable int EofVal = -1;
+
----------------
Have you considered using `llvm::Optional<int>` for this?
================
Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:537
+                  errno_modeling::getNoteTagForStdSuccess(
+                      C, cast<NamedDecl>(Call.getDecl())->getNameAsString()));
   C.addTransition(StateNull);
----------------
I believe, `getDecl()` might return null, e.g. for calling a function pointer.
================
Comment at: clang/test/Analysis/stream-errno.c:12-13
+  // expected-note at -1{{Assuming that function 'fopen' is successful, in this case the value 'errno' may be undefined after the call and should not be used}}
+  // expected-note at +4{{'F' is null}}
+  // expected-note at +3{{Taking true branch}}
+  // expected-note at +2{{'F' is non-null}}
----------------
So these two lines correspond to the following `clang_analyzer_eval()`.
It took me a while to make sense of the two independent note streams at once.
Please consider splitting this and similar cases to have a single stream of notes.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132017/new/
https://reviews.llvm.org/D132017
    
    
More information about the cfe-commits
mailing list