https://github.com/benshi001 closed
https://github.com/llvm/llvm-project/pull/72627
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/balazske approved this pull request.
https://github.com/llvm/llvm-project/pull/72627
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/benshi001 updated
https://github.com/llvm/llvm-project/pull/72627
>From 5c3cb2cfbb91ac462633aa223ebeecc1d7790138 Mon Sep 17 00:00:00 2001
From: Ben Shi
Date: Fri, 17 Nov 2023 17:22:10 +0800
Subject: [PATCH] [clang][analyzer] Support `fgetc` in StreamChecker
---
.../StaticAn
https://github.com/benshi001 updated
https://github.com/llvm/llvm-project/pull/72627
>From 81973987254f037f1682b7f0cd7a970177051f04 Mon Sep 17 00:00:00 2001
From: Ben Shi
Date: Fri, 17 Nov 2023 17:22:10 +0800
Subject: [PATCH] [clang][analyzer] Support `fgetc` in StreamChecker
---
.../StaticAn
@@ -768,26 +772,65 @@ void StreamChecker::evalFputc(const FnDescription *Desc,
const CallEvent &Call,
assertStreamStateOpened(OldSS);
+ // `fgetc` returns the read character on success, otherwise returns EOF.
// `fputc` returns the written character on success, otherwi
@@ -101,6 +101,30 @@ void error_fwrite(void) {
Ret = fwrite(0, 1, 10, F); // expected-warning {{Stream might be already
closed}}
}
+void error_fgetc(void) {
+ FILE *F = tmpfile();
+ if (!F)
+return;
+ int Ret = fgetc(F);
+ if (0 <= Ret && Ret <= 255) {
+clang_an
@@ -259,14 +283,33 @@ void error_indeterminate_clearerr(void) {
fclose(F);
}
+void error_indeterminate_fgetc(void) {
+ FILE *F = fopen("file", "r+");
+ if (!F)
+return;
+ int rc = fseek(F, 0, SEEK_SET);
+ if (rc) {
+if (feof(F)) {
+ clang_analyzer_warnIfReac
@@ -303,3 +346,29 @@ void error_indeterminate_feof2(void) {
}
fclose(F);
}
+
+void error_indeterminate_feof3(void) {
balazske wrote:
This test seems to be not necessary (previous tests cover these conditions),
otherwise a more meaningful name should be ch
https://github.com/balazske requested changes to this pull request.
https://github.com/llvm/llvm-project/pull/72627
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -303,3 +346,29 @@ void error_indeterminate_feof2(void) {
}
fclose(F);
}
+
+void error_indeterminate_feof3(void) {
+ FILE *F = fopen("file", "r+");
+ if (!F)
+return;
+ if (fgetc(F) == EOF) {
+if (feof(F)) {
+ // error is feof, should be non-indeterminate
@@ -259,14 +283,33 @@ void error_indeterminate_clearerr(void) {
fclose(F);
}
+void error_indeterminate_fgetc(void) {
+ FILE *F = fopen("file", "r+");
+ if (!F)
+return;
+ int rc = fseek(F, 0, SEEK_SET);
+ if (rc) {
+if (feof(F)) {
balazske wrote:
@@ -101,6 +101,30 @@ void error_fwrite(void) {
Ret = fwrite(0, 1, 10, F); // expected-warning {{Stream might be already
closed}}
}
+void error_fgetc(void) {
+ FILE *F = tmpfile();
+ if (!F)
+return;
+ int Ret = fgetc(F);
+ if (0 <= Ret && Ret <= 255) {
+clang_an
https://github.com/balazske edited
https://github.com/llvm/llvm-project/pull/72627
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/benshi001 updated
https://github.com/llvm/llvm-project/pull/72627
>From 3032cafc2ad43baeeea14de318cd82026b96d035 Mon Sep 17 00:00:00 2001
From: Ben Shi
Date: Fri, 17 Nov 2023 17:22:10 +0800
Subject: [PATCH] [clang][analyzer] Support `fgetc` in StreamChecker
---
.../StaticAn
@@ -768,26 +772,56 @@ void StreamChecker::evalFputc(const FnDescription *Desc,
const CallEvent &Call,
assertStreamStateOpened(OldSS);
+ // `fgetc` returns the read character on success, otherwise returns EOF.
// `fputc` returns the written character on success, otherwi
https://github.com/benshi001 updated
https://github.com/llvm/llvm-project/pull/72627
>From d3ce61fecbe922f09ad1228a3305f484e8e1dcfc Mon Sep 17 00:00:00 2001
From: Ben Shi
Date: Fri, 17 Nov 2023 17:22:10 +0800
Subject: [PATCH] [clang][analyzer] Support `fgetc` in StreamChecker
---
.../StaticAn
llvmbot wrote:
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-static-analyzer-1
Author: Ben Shi (benshi001)
Changes
---
Full diff: https://github.com/llvm/llvm-project/pull/72627.diff
4 Files Affected:
- (modified) clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp (+52-18)
-
https://github.com/benshi001 created
https://github.com/llvm/llvm-project/pull/72627
None
>From 87563994d96519bef69cb14c284a9a1273ab343c Mon Sep 17 00:00:00 2001
From: Ben Shi
Date: Fri, 17 Nov 2023 17:22:10 +0800
Subject: [PATCH] [clang][analyzer] Support `fgetc` in StreamChecker
---
.../St
18 matches
Mail list logo