@@ -1191,6 +1199,84 @@ void StreamChecker::evalSetFeofFerror(const
FnDescription *Desc,
C.addTransition(State);
}
+void StreamChecker::preFflush(const FnDescription *Desc, const CallEvent &Call,
+ CheckerContext &C) const {
+ ProgramStateRef St
@@ -1191,6 +1199,84 @@ void StreamChecker::evalSetFeofFerror(const
FnDescription *Desc,
C.addTransition(State);
}
+void StreamChecker::preFflush(const FnDescription *Desc, const CallEvent &Call,
+ CheckerContext &C) const {
+ ProgramStateRef St
alejandro-alvarez-sonarsource wrote:
@balazske would you agree with my proposal of keeping this logic in
`UnixAPIChecker`? I am also happy with adding more NULL checks to
`StreamChecker`, but I can understand your concerns about overreaching its
scope.
https://github.com/llvm/llvm-project/pul
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From a061464b75ac02c21e5d74fc4dff8d8afdbba66b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 20 Mar 2024 10:49:08 +0100
Subject: [PATCH 01/18]
@@ -1179,6 +1195,113 @@ void StreamChecker::evalUngetc(const FnDescription
*Desc, const CallEvent &Call,
C.addTransition(StateFailed);
}
+ProgramStateRef StreamChecker::ensureGetdelimBufferAndSizeCorrect(
+SVal LinePtrPtrSVal, SVal SizePtrSVal, const Expr *LinePtrPtrExp
@@ -1179,6 +1195,113 @@ void StreamChecker::evalUngetc(const FnDescription
*Desc, const CallEvent &Call,
C.addTransition(StateFailed);
}
+ProgramStateRef StreamChecker::ensureGetdelimBufferAndSizeCorrect(
+SVal LinePtrPtrSVal, SVal SizePtrSVal, const Expr *LinePtrPtrExp
alejandro-alvarez-sonarsource wrote:
Sorry for the force-push, but I have moved now the precondition checks to
`UnixAPIChecker` after uplifting its API (now it uses `PreCall` instead of
`PreStmt`). From my understanding, the previous implementation used a legacy
way of handling them.
The idea
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From a061464b75ac02c21e5d74fc4dff8d8afdbba66b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 20 Mar 2024 10:49:08 +0100
Subject: [PATCH 01/19]
@@ -1204,6 +1204,20 @@ void StreamChecker::evalGetdelim(const FnDescription
*Desc,
State->BindExpr(E.CE, C.getLocationContext(), RetVal);
StateNotFailed =
E.assumeBinOpNN(StateNotFailed, BO_GE, RetVal, E.getZeroVal(Call));
+// The buffer size `*n` must
@@ -1179,6 +1195,113 @@ void StreamChecker::evalUngetc(const FnDescription
*Desc, const CallEvent &Call,
C.addTransition(StateFailed);
}
+ProgramStateRef StreamChecker::ensureGetdelimBufferAndSizeCorrect(
+SVal LinePtrPtrSVal, SVal SizePtrSVal, const Expr *LinePtrPtrExp
@@ -1204,6 +1204,20 @@ void StreamChecker::evalGetdelim(const FnDescription
*Desc,
State->BindExpr(E.CE, C.getLocationContext(), RetVal);
StateNotFailed =
E.assumeBinOpNN(StateNotFailed, BO_GE, RetVal, E.getZeroVal(Call));
+// The buffer size `*n` must
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From a061464b75ac02c21e5d74fc4dff8d8afdbba66b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 20 Mar 2024 10:49:08 +0100
Subject: [PATCH 01/20]
https://github.com/alejandro-alvarez-sonarsource commented:
Applied the feedback.
By the way, when `StdLibraryFunctionsChecker` is refactored, I'd be happy to
give a hand if you need updating these checkers (UnixAPI and Stream).
https://github.com/llvm/llvm-project/pull/83027
__
@@ -1204,6 +1204,20 @@ void StreamChecker::evalGetdelim(const FnDescription
*Desc,
State->BindExpr(E.CE, C.getLocationContext(), RetVal);
StateNotFailed =
E.assumeBinOpNN(StateNotFailed, BO_GE, RetVal, E.getZeroVal(Call));
+// The buffer size `*n` must
@@ -1217,6 +1231,11 @@ void StreamChecker::evalGetdelim(const FnDescription
*Desc,
E.isStreamEof() ? ErrorFEof : ErrorFEof | ErrorFError;
StateFailed = E.setStreamState(
StateFailed, StreamState::getOpened(Desc, NewES, !NewES.isFEof()));
+ // On failure, the con
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From a061464b75ac02c21e5d74fc4dff8d8afdbba66b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 20 Mar 2024 10:49:08 +0100
Subject: [PATCH 01/22]
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void getline_null_file() {
+ char *buffer = NULL;
+ size_t n = 0;
+ getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be
NULL}}
+}
+
+void getdelim_null_file() {
+ ch
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void getline_null_file() {
+ char *buffer = NULL;
+ size_t n = 0;
+ getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be
NULL}}
+}
+
+void getdelim_null_file() {
+ ch
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void getline_null_file() {
+ char *buffer = NULL;
+ size_t n = 0;
+ getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be
NULL}}
+}
+
+void getdelim_null_file() {
+ ch
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void getline_null_file() {
+ char *buffer = NULL;
+ size_t n = 0;
+ getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be
NULL}}
+}
+
+void getdelim_null_file() {
+ ch
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From a061464b75ac02c21e5d74fc4dff8d8afdbba66b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 20 Mar 2024 10:49:08 +0100
Subject: [PATCH 01/23]
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void getline_null_file() {
+ char *buffer = NULL;
+ size_t n = 0;
+ getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be
NULL}}
+}
+
+void getdelim_null_file() {
+ ch
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From a061464b75ac02c21e5d74fc4dff8d8afdbba66b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 20 Mar 2024 10:49:08 +0100
Subject: [PATCH 01/24]
@@ -376,3 +377,75 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void getline_null_file() {
+ char *buffer = NULL;
+ size_t n = 0;
+ getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be
NULL}}
+}
+
+void getdelim_null_file() {
+ cha
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 18569fc14e2d9050acbc63c2367f9a1ec6f8577b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 20 Mar 2024 10:49:08 +0100
Subject: [PATCH 1/2] [c
alejandro-alvarez-sonarsource wrote:
Rebased and squashed into two commits that should be kept separate.
https://github.com/llvm/llvm-project/pull/83027
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/list
alejandro-alvarez-sonarsource wrote:
Well, the test now runs for 4 different platforms and the PR checks are all
green, so I guess we can merge.
https://github.com/llvm/llvm-project/pull/83281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
ht
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 997501888aacdbae59ace767e085922c9aa96a22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH] [clang
alejandro-alvarez-sonarsource wrote:
Rebased on top of main and solved conflicts.
https://github.com/llvm/llvm-project/pull/83027
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1158,6 +1173,123 @@ void StreamChecker::evalUngetc(const FnDescription
*Desc, const CallEvent &Call,
C.addTransition(StateFailed);
}
+ProgramStateRef
+StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr,
+CheckerContext &C, P
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 997501888aacdbae59ace767e085922c9aa96a22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH 1/2] [c
@@ -13,6 +13,9 @@
#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H
#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H
+#include "ProgramState_Fwd.h"
+#include "SVals.h"
+
alejandro-alvarez-sonarsource wrote:
Removed.
h
@@ -0,0 +1,327 @@
+// RUN: %clang_analyze_cc1
-analyzer-checker=core,alpha.unix.Stream,debug.ExprInspection -verify %s
+
+#include "Inputs/system-header-simulator.h"
+#include "Inputs/system-header-simulator-for-malloc.h"
+#include "Inputs/system-header-simulator-for-valist.h"
+
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 5c919832f9176d4b1af1312a4ee7cf30b788958a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH 1/2] [c
alejandro-alvarez-sonarsource wrote:
Rebased on top of main to solve conflicts.
https://github.com/llvm/llvm-project/pull/83027
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 5c919832f9176d4b1af1312a4ee7cf30b788958a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH 1/3] [c
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 5c919832f9176d4b1af1312a4ee7cf30b788958a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH 1/4] [c
@@ -1196,6 +1342,11 @@ void StreamChecker::evalGetdelim(const FnDescription
*Desc,
E.isStreamEof() ? ErrorFEof : ErrorFEof | ErrorFError;
StateFailed = E.setStreamState(
StateFailed, StreamState::getOpened(Desc, NewES, !NewES.isFEof()));
+ // On failure, the con
@@ -1183,6 +1315,20 @@ void StreamChecker::evalGetdelim(const FnDescription
*Desc,
State->BindExpr(E.CE, C.getLocationContext(), RetVal);
StateNotFailed =
E.assumeBinOpNN(StateNotFailed, BO_GE, RetVal, E.getZeroVal(Call));
+// The buffer size `*n` must
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 5c919832f9176d4b1af1312a4ee7cf30b788958a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH 1/6] [c
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 5c919832f9176d4b1af1312a4ee7cf30b788958a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH 1/7] [c
alejandro-alvarez-sonarsource wrote:
> : "If *n is non-zero, the application shall ensure that *lineptr either
> points to an object of size at least *n bytes, or is a null pointer."
Ah! I was following at the 2008 version, and there "[...], or is a null
pointer." is missing. I will update acc
@@ -1158,6 +1173,118 @@ void StreamChecker::evalUngetc(const FnDescription
*Desc, const CallEvent &Call,
C.addTransition(StateFailed);
}
+ProgramStateRef
+StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr,
+CheckerContext &C, P
@@ -234,6 +235,9 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/83027
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From 5c919832f9176d4b1af1312a4ee7cf30b788958a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH 01/14]
@@ -1158,6 +1173,118 @@ void StreamChecker::evalUngetc(const FnDescription
*Desc, const CallEvent &Call,
C.addTransition(StateFailed);
}
+ProgramStateRef
+StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr,
+CheckerContext &C, P
@@ -1158,6 +1173,118 @@ void StreamChecker::evalUngetc(const FnDescription
*Desc, const CallEvent &Call,
C.addTransition(StateFailed);
}
+ProgramStateRef
+StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr,
+CheckerContext &C, P
@@ -1158,6 +1173,118 @@ void StreamChecker::evalUngetc(const FnDescription
*Desc, const CallEvent &Call,
C.addTransition(StateFailed);
}
+ProgramStateRef
+StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr,
+CheckerContext &C, P
@@ -510,6 +517,14 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/83027
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
alejandro-alvarez-sonarsource wrote:
> Additionally, the checked preconditions look not exact. For example the POSIX
> documentation for `getdelim` says: "If *n is non-zero, the application shall
> ensure that *lineptr either points to an object of size at least *n bytes, or
> is a null pointe
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 1/4] [c
https://github.com/alejandro-alvarez-sonarsource edited
https://github.com/llvm/llvm-project/pull/82476
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 1/5] [c
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 1/5] [c
https://github.com/alejandro-alvarez-sonarsource edited
https://github.com/llvm/llvm-project/pull/82476
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
alejandro-alvarez-sonarsource wrote:
I have reduced the scope of the PR, and changed the title and the description
accordingly.
https://github.com/llvm/llvm-project/pull/82476
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm
https://github.com/alejandro-alvarez-sonarsource created
https://github.com/llvm/llvm-project/pull/83027
1. `lineptr`, `n` and `stream` can not be `NULL`
2. if `*lineptr` is `NULL`, `*n` must be 0
This patch models `getline` specific preconditions, constraints the size to be
greater than the
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 1/7] [c
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void test_fscanf_eof() {
+ FILE *F1 = tmpfile();
+ if (!F1)
+return;
+
+ int a;
+ unsigned b;
+ int ret = fscanf(F1, "%d %u", &a, &b);
+ char c = fgetc(F1); // expected-warning {{Rea
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void test_fscanf_eof() {
+ FILE *F1 = tmpfile();
+ if (!F1)
+return;
+
+ int a;
+ unsigned b;
+ int ret = fscanf(F1, "%d %u", &a, &b);
+ char c = fgetc(F1); // expected-warning {{Rea
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void test_fscanf_eof() {
+ FILE *F1 = tmpfile();
+ if (!F1)
+return;
+
+ int a;
+ unsigned b;
+ int ret = fscanf(F1, "%d %u", &a, &b);
+ char c = fgetc(F1); // expected-warning {{Rea
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void test_fscanf_eof() {
+ FILE *F1 = tmpfile();
+ if (!F1)
+return;
+
+ int a;
+ unsigned b;
+ int ret = fscanf(F1, "%d %u", &a, &b);
+ char c = fgetc(F1); // expected-warning {{Rea
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From efd1411ff7fa93a84cb3d385cb55aa411af9e9ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH] [clang
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void test_fscanf_eof() {
alejandro-alvarez-sonarsource wrote:
Dropped.
https://github.com/llvm/llvm-project/pull/82476
___
cfe-co
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 1/8] [c
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 1/9] [c
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 01/10]
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 01/11]
@@ -65,12 +65,24 @@ void check_fseek(void) {
fclose(fp);
}
+void check_fseeko(void) {
alejandro-alvarez-sonarsource wrote:
Added
https://github.com/llvm/llvm-project/pull/82476
___
cfe-commits mailing list
cfe-co
@@ -5,7 +5,7 @@
// suppressed.
#pragma clang system_header
-typedef struct __sFILE {
alejandro-alvarez-sonarsource wrote:
I had to modify this line after adding `vfscanf` (and now `vfprintf`) to
`system-header-simulator-for-valist.h`
The reason is that they
https://github.com/alejandro-alvarez-sonarsource edited
https://github.com/llvm/llvm-project/pull/82476
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83027
From efd1411ff7fa93a84cb3d385cb55aa411af9e9ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 14:46:01 +0100
Subject: [PATCH 1/2] [c
https://github.com/alejandro-alvarez-sonarsource created
https://github.com/llvm/llvm-project/pull/83138
`getdelim` and `getline` may free, allocate, or re-allocate the input buffer,
ensuring its size is enough to hold the incoming line, the delimiter, and the
null terminator.
`*lineptr` must
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83138
From ad17cfb588500d095b4e402bd2f2197772f89b12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 21 Feb 2024 16:08:04 +0100
Subject: [PATCH 1/2] [c
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a886005893585ce060415619e1fa6164ba4e1729 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 01/11]
alejandro-alvarez-sonarsource wrote:
Rebased on top of main to solve a conflict.
https://github.com/llvm/llvm-project/pull/82476
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/alejandro-alvarez-sonarsource created
https://github.com/llvm/llvm-project/pull/83281
…vfprintf (#82476)"
`va_list` is a platform-specific type. On some, it is a struct instead of a
pointer to a struct, so `lookupFn` was ignoring calls to `vfprintf` and
`vfscanf`.
`stream.
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83281
From a9419bc3ffa3d383a9373f0a116795162632dd40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 28 Feb 2024 16:49:35 +0100
Subject: [PATCH] Reappl
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/83281
From a9419bc3ffa3d383a9373f0a116795162632dd40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Wed, 28 Feb 2024 16:49:35 +0100
Subject: [PATCH 1/2] Re
alejandro-alvarez-sonarsource wrote:
@balazske @steakhal I broke some tests on aarch64 since there
`__builtin_valist` is a struct and not a pointer to struct, so `lookupFn` was
not matching `vfprintf` nor `vfscanf`, and the NULL pointer dereference
triggered on the `fclose`. I have fixed that
https://github.com/alejandro-alvarez-sonarsource created
https://github.com/llvm/llvm-project/pull/81855
Now calling `open` with the `O_CREAT` flag and no mode parameter will raise an
issue in any system that defines `O_CREAT`.
The value for this flag is obtained after the full source code has
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/81855
From 702ab6679c3b030c42e8d18acd10f438b4880eeb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Thu, 15 Feb 2024 13:22:40 +0100
Subject: [PATCH] [analy
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/81855
From 702ab6679c3b030c42e8d18acd10f438b4880eeb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Thu, 15 Feb 2024 13:22:40 +0100
Subject: [PATCH 1/2] [a
alejandro-alvarez-sonarsource wrote:
Thanks! I have added a new test file where the values are those of
[FreeRTOS](https://www.freertos.org/Documentation/api-ref/POSIX/fcntl_8h.html)
https://github.com/llvm/llvm-project/pull/81855
___
cfe-commits mail
https://github.com/alejandro-alvarez-sonarsource created
https://github.com/llvm/llvm-project/pull/82476
1. Model `getc`, `vfscanf`, `putc`, `vfprintf`.
2. `fscanf` invalidates all arguments after the format string.
Also, add tests for `ftello` and `fseeko`.
From a21881d82fe3674b344d4a3807e9d2
https://github.com/alejandro-alvarez-sonarsource edited
https://github.com/llvm/llvm-project/pull/82476
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
alejandro-alvarez-sonarsource wrote:
> How does this relate to the other PR #79470 (why comes this new patch when
> there is another for the same problem)? I think it is better to first commit
> #79470, then add remaining functions `getc`, `putc`, `vfscanf`, `vfprintf`.
> These should be added
@@ -339,3 +363,107 @@ void fflush_on_open_failed_stream(void) {
}
fclose(F);
}
+
+void test_fscanf_eof() {
+ FILE *F1 = tmpfile();
+ if (!F1)
+return;
+
+ int a;
+ unsigned b;
+ int ret = fscanf(F1, "%d %u", &a, &b);
+ char c = fgetc(F1); // expected-warning {{Rea
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/82476
From a21881d82fe3674b344d4a3807e9d2590c98ce93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Tue, 14 Nov 2023 09:28:45 +0100
Subject: [PATCH 1/3] [c
@@ -763,6 +779,11 @@ void StreamChecker::evalFreadFwrite(const FnDescription
*Desc,
return;
}
+ // At read, invalidate the buffer in any case of error or success,
+ // except if EOF was already present.
+ if (IsFread && (OldSS->ErrorState != ErrorFEof))
+State =
https://github.com/alejandro-alvarez-sonarsource edited
https://github.com/llvm/llvm-project/pull/79470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/alejandro-alvarez-sonarsource edited
https://github.com/llvm/llvm-project/pull/79470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -763,6 +779,11 @@ void StreamChecker::evalFreadFwrite(const FnDescription
*Desc,
return;
}
+ // At read, invalidate the buffer in any case of error or success,
+ // except if EOF was already present.
+ if (IsFread && (OldSS->ErrorState != ErrorFEof))
+State =
@@ -763,6 +779,11 @@ void StreamChecker::evalFreadFwrite(const FnDescription
*Desc,
return;
}
+ // At read, invalidate the buffer in any case of error or success,
+ // except if EOF was already present.
+ if (IsFread && (OldSS->ErrorState != ErrorFEof))
+State =
@@ -763,6 +779,11 @@ void StreamChecker::evalFreadFwrite(const FnDescription
*Desc,
return;
}
+ // At read, invalidate the buffer in any case of error or success,
+ // except if EOF was already present.
+ if (IsFread && (OldSS->ErrorState != ErrorFEof))
+State =
alejandro-alvarez-sonarsource wrote:
Ping (@cor3ntin, @Endilll ?)
https://github.com/llvm/llvm-project/pull/96509
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/alejandro-alvarez-sonarsource updated
https://github.com/llvm/llvm-project/pull/96509
From 96b0c2c18c197a1ce03d31b01c14d1b18348e9ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
Date: Thu, 1 Jun 2023 16:30:54 +0200
Subject: [PATCH 1/2] [Se
@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc,
NamedDecl *D,
getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
}
QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
- if (T.i
https://github.com/alejandro-alvarez-sonarsource created
https://github.com/llvm/llvm-project/pull/108021
A constructor may have failed to be used due to a broken templated dependent
parameter. The `InitializationSequence` itself can succeed.
Due to the assumption that it is in a failed state,
https://github.com/alejandro-alvarez-sonarsource edited
https://github.com/llvm/llvm-project/pull/108021
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
1 - 100 of 184 matches
Mail list logo