[llvm] [clang-tools-extra] [clang] [clang][Analyzer] Move checker 'alpha.unix.Errno' to 'unix.Errno'. (PR #69469)

2023-11-21 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/69469 From 0fdc57b49002afd8aa54043837ee4155688b4c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Tue, 17 Oct 2023 11:51:27 +0200 Subject: [PATCH] [clang][Analyzer] Move checker 'alpha.unix.

[llvm] [clang] [clang-tools-extra] [clang][Analyzer] Move checker 'alpha.unix.Errno' to 'unix.Errno'. (PR #69469)

2023-11-21 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/69469 From 0fdc57b49002afd8aa54043837ee4155688b4c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Tue, 17 Oct 2023 11:51:27 +0200 Subject: [PATCH 1/2] [clang][Analyzer] Move checker 'alpha.u

[clang] [clang-tools-extra] [llvm] [clang][Analyzer] Move checker 'alpha.unix.Errno' to 'unix.Errno'. (PR #69469)

2023-11-21 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/69469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Improve StdLibraryFunctionsChecker 'readlink' modeling. (PR #71373)

2023-11-06 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/71373 The functions 'readlink' and 'readlinkat' do return 0 only if the 'bufsize' argument is 0. From 653aeb7f5b0d0f200b3f706bad770a9be643669c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date:

[clang] [clang][analyzer] Improve 'errno' handling in StdLibraryFunctionsChecker. (PR #71392)

2023-11-06 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/71392 The checker now displays one combined note tag for errno-related and "case"-related notes. Previous functions in the errno-modeling part that were used for construction of note tags are removed. The note tag ad

[clang] [clang][Analyzer] Move checker 'alpha.unix.Errno' to 'unix.Errno'. (PR #69469)

2023-11-06 Thread Balázs Kéri via cfe-commits
balazske wrote: PRs #71373 and #71392 are created to improve the indicated problems. https://github.com/llvm/llvm-project/pull/69469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Analyzer][NFC] Simplify preDefault/preFseek/preFreadFwrite of StreamChecker (PR #71394)

2023-11-06 Thread Balázs Kéri via cfe-commits
https://github.com/balazske requested changes to this pull request. https://github.com/llvm/llvm-project/pull/71394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Analyzer][NFC] Simplify preDefault/preFseek/preFreadFwrite of StreamChecker (PR #71394)

2023-11-06 Thread Balázs Kéri via cfe-commits
@@ -639,12 +644,7 @@ void StreamChecker::preFreadFwrite(const FnDescription *Desc, bool IsFread) const { ProgramStateRef State = C.getState(); SVal StreamVal = getStreamArg(Desc, Call); - State = ensureStreamNonNull(StreamVal, Call.getAr

[clang] [clang][Analyzer][NFC] Simplify preDefault/preFseek/preFreadFwrite of StreamChecker (PR #71394)

2023-11-06 Thread Balázs Kéri via cfe-commits
@@ -342,6 +342,11 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/71394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Analyzer][NFC] Simplify preDefault/preFseek/preFreadFwrite of StreamChecker (PR #71394)

2023-11-06 Thread Balázs Kéri via cfe-commits
https://github.com/balazske edited https://github.com/llvm/llvm-project/pull/71394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Analyzer][NFC] Simplify preDefault/preFseek/preFreadFwrite of StreamChecker (PR #71394)

2023-11-06 Thread Balázs Kéri via cfe-commits
@@ -639,12 +644,7 @@ void StreamChecker::preFreadFwrite(const FnDescription *Desc, bool IsFread) const { ProgramStateRef State = C.getState(); SVal StreamVal = getStreamArg(Desc, Call); - State = ensureStreamNonNull(StreamVal, Call.getAr

[clang] [clang][Analyzer][NFC] Simplify preDefault/preFseek/preFreadFwrite of StreamChecker (PR #71394)

2023-11-06 Thread Balázs Kéri via cfe-commits
balazske wrote: With the current code it is a corner case if this change makes the code more readable. Probably it can be useful if new functions are added to the checker. But the rule here is that there is one "ensure" function to check one aspect of the state, and the pre-callbacks call all

[clang] [clang][analyzer][NFC] Remove redundant code in StreamChecker (PR #71394)

2023-11-07 Thread Balázs Kéri via cfe-commits
balazske wrote: This change looks not very useful to me. These removed return statements indicate that at the end of the `if` branch there is no more work to do in this function, and it reduces complexity (less execution paths). The code becomes a bit shorter but not necessarily more easy to u

[clang] [clang][analyzer][NFC] Remove redundant code in StreamChecker (PR #71394)

2023-11-07 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/71394 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Improve 'errno' handling in StdLibraryFunctionsChecker. (PR #71392)

2023-11-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/71392 From e92bf72fc80bb6823996cb71cb811d238b304aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 2 Nov 2023 18:12:32 +0100 Subject: [PATCH 1/2] [clang][analyzer] Improve 'errno' handli

[clang] [clang][analyzer] Improve StdLibraryFunctionsChecker 'readlink' modeling. (PR #71373)

2023-11-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/71373 From 653aeb7f5b0d0f200b3f706bad770a9be643669c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Fri, 3 Nov 2023 09:48:18 +0100 Subject: [PATCH 1/2] [clang][analyzer] Improve StdLibraryFunc

[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske requested changes to this pull request. https://github.com/llvm/llvm-project/pull/71518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-08 Thread Balázs Kéri via cfe-commits
@@ -268,3 +285,41 @@ void error_indeterminate_feof2(void) { } fclose(F); } + +void error_indeterminate_feof3(void) { + FILE *F = fopen("file", "r+"); + if (!F) +return; + char Buf[10]; + if (fread(Buf, 1, 10, F) < 10) { +if (feof(F)) { + // error is feof, s

[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske edited https://github.com/llvm/llvm-project/pull/71518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-08 Thread Balázs Kéri via cfe-commits
@@ -111,6 +117,14 @@ void f_use_after_close(void) { clearerr(p); // expected-warning {{Stream might be already closed}} } +void f_write_after_close(void) { balazske wrote: This is not needed if the other indicated test is added. https://github.com/llvm/llv

[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-08 Thread Balázs Kéri via cfe-commits
@@ -14,6 +14,12 @@ void check_fwrite(void) { fclose(fp); } +void check_fgetc(void) { balazske wrote: This should be `check_fputc`. https://github.com/llvm/llvm-project/pull/71518 ___ cfe-commits mailing list cfe-

[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-08 Thread Balázs Kéri via cfe-commits
@@ -745,6 +751,46 @@ void StreamChecker::evalFreadFwrite(const FnDescription *Desc, C.addTransition(StateFailed); } +void StreamChecker::evalFgetcFputc(const FnDescription *Desc, balazske wrote: I do not know if there are enough similarities between `fpu

[clang] [clang][analyzer] Improve StdLibraryFunctionsChecker 'readlink' modeling. (PR #71373)

2023-11-09 Thread Balázs Kéri via cfe-commits
balazske wrote: I tested on vim and the problematic report disappeared, no other changes were detected. https://github.com/llvm/llvm-project/pull/71373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/list

[clang] [clang][analyzer] Improve StdLibraryFunctionsChecker 'readlink' modeling. (PR #71373)

2023-11-09 Thread Balázs Kéri via cfe-commits
balazske wrote: The checker was already tested on some projects, but much more is needed to find such corner cases. It can be better to manually check the functions for cases when a 0 return value is not possible or only at a special (known) case. https://github.com/llvm/llvm-project/pull/7137

[clang] [clang][analyzer] Improve 'errno' handling in StdLibraryFunctionsChecker. (PR #71392)

2023-11-09 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/71392 From e92bf72fc80bb6823996cb71cb811d238b304aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 2 Nov 2023 18:12:32 +0100 Subject: [PATCH 1/3] [clang][analyzer] Improve 'errno' handli

[clang] [clang][ASTImporter] Fix import of SubstTemplateTypeParmType in return type of function. (PR #69724)

2023-10-25 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/69724 From 2bfad6f0fbb7a5757318c77ef76335986d23ab83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 19 Oct 2023 16:27:24 +0200 Subject: [PATCH 1/2] [clang][ASTImporter] Fix import of Sub

[clang] [clang][ASTImporter] Fix crash when template class static member imported to other translation unit. (PR #68774)

2023-10-27 Thread Balázs Kéri via cfe-commits
https://github.com/balazske edited https://github.com/llvm/llvm-project/pull/68774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ASTImporter] Fix crash when template class static member imported to other translation unit. (PR #68774)

2023-10-27 Thread Balázs Kéri via cfe-commits
@@ -1373,6 +1373,40 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportCorrectTemplatedDecl) { ASSERT_EQ(ToTemplated1, ToTemplated); } +TEST_P(ASTImporterOptionSpecificTestBase, + ImportTemplateSpecializationStaticMember) { + auto FromCode = R"( + template clas

[clang] [clang][ASTImporter] Fix crash when template class static member imported to other translation unit. (PR #68774)

2023-10-27 Thread Balázs Kéri via cfe-commits
https://github.com/balazske commented: The fix looks good but the formatting of the test code could be better, like in the other tests. https://github.com/llvm/llvm-project/pull/68774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lis

[clang] [clang][analyzer] Add 'tmpfile' as an open function to SimpleStreamChecker (PR #70539)

2023-10-30 Thread Balázs Kéri via cfe-commits
balazske wrote: If I remember correctly there is somewhere in the clang documentation a file that refers to this checker, and the purpose of this checker is mostly documentation. I do not know if it is good to change the code or to extend this checker, because there is `StreamChecker` that sho

[clang] [clang][analyzer][NFC] Add more information to CallDescriptions in StreamChecker (PR #70540)

2023-10-30 Thread Balázs Kéri via cfe-commits
https://github.com/balazske commented: The change is good but the title is too general, for example "Update CallDescription in StreamChecker for `tmpfile`", and this is not a NFC (it fixes a problem). https://github.com/llvm/llvm-project/pull/70540 _

[clang] [clang][analyzer][NFC] Add more information to CallDescriptions in StreamChecker (PR #70540)

2023-10-30 Thread Balázs Kéri via cfe-commits
https://github.com/balazske edited https://github.com/llvm/llvm-project/pull/70540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer][NFC] Add more tests of 'StreamChecker' about 'tmpfile' (PR #70540)

2023-10-31 Thread Balázs Kéri via cfe-commits
balazske wrote: I would like to have the new test in `stream.c` (not `stream.cpp`) because the C++ test file contains only C++ related StreamChecker tests (`tmpfile` belongs not here). And a "FIXME" could be added to the test to indicate that this is a faulty behavior (in the current case). Th

[clang] [clang][analyzer] Restrict 'fopen' & 'tmpfile' modeling to POSIX versions in StreamChecker (PR #70540)

2023-11-02 Thread Balázs Kéri via cfe-commits
https://github.com/balazske edited https://github.com/llvm/llvm-project/pull/70540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Restrict 'fopen' & 'tmpfile' modeling to POSIX versions in StreamChecker (PR #70540)

2023-11-02 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/70540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Restrict 'fopen' & 'tmpfile' modeling to POSIX versions in StreamChecker (PR #70540)

2023-11-02 Thread Balázs Kéri via cfe-commits
@@ -0,0 +1,16 @@ +// RUN: %clang_analyze_cc1 -fno-builtin -analyzer-checker=core,alpha.unix.Stream -verify %s +// expected-no-diagnostics + +typedef struct _FILE FILE; + +// These functions are not standard C library functions. +FILE *tmpfile(const char *restrict path); // Real '

[clang] Improve modeling of 'getcwd' in the StdLibraryFunctionsChecker (PR #77040)

2024-01-08 Thread Balázs Kéri via cfe-commits
@@ -2519,12 +2519,17 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( addToFunctionSummaryMap( "getcwd", Signature(ArgTypes{CharPtrTy, SizeTy}, RetType{CharPtrTy}), Summary(NoEvalCall) -.Case({ReturnValueCondition(BO_EQ, ArgNo(0))}, +

[clang] Improve modeling of 'getcwd' in the StdLibraryFunctionsChecker (PR #77040)

2024-01-08 Thread Balázs Kéri via cfe-commits
@@ -2519,12 +2519,17 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( addToFunctionSummaryMap( "getcwd", Signature(ArgTypes{CharPtrTy, SizeTy}, RetType{CharPtrTy}), Summary(NoEvalCall) -.Case({ReturnValueCondition(BO_EQ, ArgNo(0))}, +

[clang] Improve modeling of 'getcwd' in the StdLibraryFunctionsChecker (PR #77040)

2024-01-08 Thread Balázs Kéri via cfe-commits
@@ -75,13 +75,16 @@ void errno_mkdtemp(char *template) { } } -void errno_getcwd(char *Buf, size_t sz) { - char *Path = getcwd(Buf, sz); - if (Path == NULL) { -clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} -if (errno) {} /

[clang] [clang][analyzer] Add missing stream related functions to StdLibraryFunctionsChecker. (PR #76979)

2024-01-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/76979 From e24b90eebfff7a352dd2c0df7f948ffef26ea3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 4 Jan 2024 18:16:12 +0100 Subject: [PATCH 1/3] [clang][analyzer] Add missing stream rel

[clang] [clang][ASTImporter] Only reorder fields of RecordDecls (PR #77079)

2024-01-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. This reordering is not a significant feature (and may change in the future) and no test existed before, it is enough (if this exists) if there is a GDB test for the crash. https://github.com/llvm/llvm-project/pull/77079 __

[clang] Improve modeling of 'getcwd' in the StdLibraryFunctionsChecker (PR #77040)

2024-01-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/77040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Add function 'ungetc' to StreamChecker. (PR #77331)

2024-01-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/77331 `StdLibraryFunctionsChecker` is updated too with `ungetc`. From 9bcc43b5c62ba969f91c495d4d570c5c4337aca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 8 Jan 2024 16:42:58 +0100 S

[clang] [clang][analyzer] Add function 'ungetc' to StreamChecker. (PR #77331)

2024-01-09 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/77331 From 9bcc43b5c62ba969f91c495d4d570c5c4337aca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 8 Jan 2024 16:42:58 +0100 Subject: [PATCH 1/2] [clang][analyzer] Add 'ungetc' to Stream

[clang] [clang][analyzer] Add function 'ungetc' to StreamChecker. (PR #77331)

2024-01-09 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/77331 From 9bcc43b5c62ba969f91c495d4d570c5c4337aca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 8 Jan 2024 16:42:58 +0100 Subject: [PATCH 1/3] [clang][analyzer] Add 'ungetc' to Stream

[clang] [clang][analyzer] Add function 'ungetc' to StreamChecker. (PR #77331)

2024-01-09 Thread Balázs Kéri via cfe-commits
@@ -916,6 +922,44 @@ void StreamChecker::evalFputx(const FnDescription *Desc, const CallEvent &Call, C.addTransition(StateFailed); } +void StreamChecker::evalUngetc(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const {

[clang] [clang][analyzer] Add function 'ungetc' to StreamChecker. (PR #77331)

2024-01-09 Thread Balázs Kéri via cfe-commits
@@ -916,6 +922,44 @@ void StreamChecker::evalFputx(const FnDescription *Desc, const CallEvent &Call, C.addTransition(StateFailed); } +void StreamChecker::evalUngetc(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const {

[clang] [clang][analyzer] Implement modeling of 'fputc' in the StdLibraryFunctionsChecker (PR #77435)

2024-01-09 Thread Balázs Kéri via cfe-commits
balazske wrote: I have already a patch to add these functions: #76979. The conditions for `fputc` are not the same, this can be clarified at the other patch. https://github.com/llvm/llvm-project/pull/77435 ___ cfe-commits mailing list cfe-commits@list

[clang] [clang][analyzer] Add missing stream related functions to StdLibraryFunctionsChecker. (PR #76979)

2024-01-09 Thread Balázs Kéri via cfe-commits
@@ -2201,6 +2214,56 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( ErrnoNEZeroIrrelevant, GenericFailureMsg) .ArgConstraint(NotNull(ArgNo(0; +// int fgetc(FILE *stream); +// 'getc' is the same as 'fgetc' but may be a macro

[clang] [clang][ASTImporter] Improve import of friend class templates. (PR #74627)

2024-01-09 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/74627 From cbcb81ebdbc49e3bd11b6f716ac14658a729b787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Tue, 5 Dec 2023 15:23:37 +0100 Subject: [PATCH 1/4] [clang][ASTImporter] Improve import of f

[clang] [clang][ASTImporter] Improve import of friend class templates. (PR #74627)

2024-01-09 Thread Balázs Kéri via cfe-commits
@@ -5919,15 +5919,26 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { if (ToD) return ToD; - bool IsFriendTemplate = D->getFriendObjectKind() != Decl::FOK_None; - bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext(

[clang] [clang][analyzer] Add function 'ungetc' to StreamChecker. (PR #77331)

2024-01-10 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/77331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Fix incorrect range of 'ftell' in the StdLibraryFunctionsChecker (PR #77576)

2024-01-10 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/77576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Add function 'fprintf' to StreamChecker. (PR #77613)

2024-01-10 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/77613 [clang][analyzer] Add function 'fprintf' to StreamChecker. From 574816e425d623b3b07674422b901879cc3c83c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 10 Jan 2024 10:55:27 +0100

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread Balázs Kéri via cfe-commits
balazske wrote: It is better to replace in code of `evalFtell` the `C.getASTContext().LongTy` with `Call.getResultType()` (occurs 2 times), this is more exact if `off_t` is defined to something else than `long`. https://github.com/llvm/llvm-project/pull/77580 __

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread Balázs Kéri via cfe-commits
@@ -324,6 +355,57 @@ void error_fseek_0(void) { fclose(F); } +void error_fseeko_0(void) { + FILE *F = fopen("file", "r"); + if (!F) +return; + int rc = fseeko(F, 0, SEEK_SET); + if (rc) { +int IsFEof = feof(F), IsFError = ferror(F); +// Get ferror or no error

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread Balázs Kéri via cfe-commits
@@ -324,6 +355,57 @@ void error_fseek_0(void) { fclose(F); } +void error_fseeko_0(void) { + FILE *F = fopen("file", "r"); + if (!F) +return; + int rc = fseeko(F, 0, SEEK_SET); + if (rc) { +int IsFEof = feof(F), IsFError = ferror(F); +// Get ferror or no error

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread Balázs Kéri via cfe-commits
https://github.com/balazske deleted https://github.com/llvm/llvm-project/pull/77580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread Balázs Kéri via cfe-commits
@@ -324,6 +355,57 @@ void error_fseek_0(void) { fclose(F); } +void error_fseeko_0(void) { + FILE *F = fopen("file", "r"); + if (!F) +return; + int rc = fseeko(F, 0, SEEK_SET); + if (rc) { +int IsFEof = feof(F), IsFError = ferror(F); +// Get ferror or no error

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread Balázs Kéri via cfe-commits
@@ -324,6 +355,57 @@ void error_fseek_0(void) { fclose(F); } +void error_fseeko_0(void) { + FILE *F = fopen("file", "r"); + if (!F) +return; + int rc = fseeko(F, 0, SEEK_SET); + if (rc) { +int IsFEof = feof(F), IsFError = ferror(F); +// Get ferror or no error

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-10 Thread Balázs Kéri via cfe-commits
@@ -268,8 +268,12 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/77580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-11 Thread Balázs Kéri via cfe-commits
@@ -324,6 +343,60 @@ void error_fseek_0(void) { fclose(F); } +void error_fseeko_0(void) { + FILE *F = fopen("file", "r"); + if (!F) +return; + int rc = fseeko(F, 0, SEEK_SET); + if (rc) { +int IsFEof = feof(F), IsFError = ferror(F); +// Get ferror or no error

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-11 Thread Balázs Kéri via cfe-commits
@@ -268,8 +268,12 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/77580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ASTImporter] Improve import of friend class templates. (PR #74627)

2024-01-11 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/74627 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-11 Thread Balázs Kéri via cfe-commits
https://github.com/balazske deleted https://github.com/llvm/llvm-project/pull/77580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-11 Thread Balázs Kéri via cfe-commits
https://github.com/balazske deleted https://github.com/llvm/llvm-project/pull/77580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-11 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/77580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Add function 'fprintf' to StreamChecker. (PR #77613)

2024-01-12 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/77613 From 96a786f07ca5fb84b372e0b7c60f371bf4cdfd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 10 Jan 2024 10:55:27 +0100 Subject: [PATCH] [clang][analyzer] Add function 'fprintf' to

[clang] [clang][analyzer] Improve modeling of 'fseeko' and 'ftello' in StdLibraryFunctionsChecker (PR #77902)

2024-01-12 Thread Balázs Kéri via cfe-commits
@@ -2859,13 +2859,19 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( "fseeko", Signature(ArgTypes{FilePtrTy, Off_tTy, IntTy}, RetType{IntTy}), Summary(NoEvalCall) -.Case(ReturnsZeroOrMinusOne, ErrnoIrrelevant) -.ArgCons

[clang] [clang][analyzer] Improve modeling of 'fseeko' and 'ftello' in StdLibraryFunctionsChecker (PR #77902)

2024-01-12 Thread Balázs Kéri via cfe-commits
@@ -2859,13 +2859,19 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( "fseeko", Signature(ArgTypes{FilePtrTy, Off_tTy, IntTy}, RetType{IntTy}), Summary(NoEvalCall) -.Case(ReturnsZeroOrMinusOne, ErrnoIrrelevant) -.ArgCons

[clang] [clang][analyzer] Add function 'fprintf' to StreamChecker. (PR #77613)

2024-01-12 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/77613 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ASTImporter] Improve structural equivalence of overloadable operators. (PR #72242)

2024-01-12 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/72242 From 5300f979c96eb2f88c298872f0519e274c155cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Tue, 14 Nov 2023 11:53:20 +0100 Subject: [PATCH 1/3] [clang][ASTImporter] Improve structural

[clang] [clang][ASTImporter] Improve structural equivalence of overloadable operators. (PR #72242)

2024-01-12 Thread Balázs Kéri via cfe-commits
@@ -2252,6 +2252,176 @@ TEST_F(StructuralEquivalenceStmtTest, UnaryOperatorDifferentOps) { EXPECT_FALSE(testStructuralMatch(t)); } +TEST_F(StructuralEquivalenceStmtTest, + CXXOperatorCallExprVsUnaryBinaryOperator) { + auto t = makeNamedDecls( + R"( + templa

[clang] [clang][ASTImporter] Fix import of variable template redeclarations. (PR #72841)

2024-01-12 Thread Balázs Kéri via cfe-commits
@@ -6245,17 +6245,21 @@ ExpectedDecl ASTNodeImporter::VisitVarTemplateDecl(VarTemplateDecl *D) { D->getTemplatedDecl())) continue; if (IsStructuralMatch(D, FoundTemplate)) { -// The Decl in the "From" context

[clang] [clang][ASTImporter] Fix of possible crash "Did not find base!". (PR #67680)

2023-10-16 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/67680 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha. (PR #66207)

2023-10-16 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/66207 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha. (PR #66207)

2023-10-16 Thread Balázs Kéri via cfe-commits
https://github.com/balazske reopened https://github.com/llvm/llvm-project/pull/66207 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha. (PR #66207)

2023-10-16 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/66207 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Analyzer] Move checker 'alpha.unix.Errno' to 'unix.Errno'. (PR #69469)

2023-10-18 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/69469 None From 0fdc57b49002afd8aa54043837ee4155688b4c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Tue, 17 Oct 2023 11:51:27 +0200 Subject: [PATCH] [clang][Analyzer] Move checker 'alpha

[clang] [clang][Analyzer] Move checker 'alpha.unix.Errno' to 'unix.Errno'. (PR #69469)

2023-10-18 Thread Balázs Kéri via cfe-commits
balazske wrote: This checker was dependent on `unix.StdCLibraryFunctions`. After that checker was moved out of alpha, it is possible to move `alpha.unix.Errno` out of alpha. The checker was tested first on the following projects. The following links were automatically generated to compare the c

[clang] [clang][Analyzer] Move checker 'alpha.unix.Errno' to 'unix.Errno'. (PR #69469)

2023-10-19 Thread Balázs Kéri via cfe-commits
balazske wrote: The checker was tested additionally on projects libwebm, bitcoin, contour and produced no results. https://github.com/llvm/llvm-project/pull/69469 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[clang] [clang][ASTImporter] Fix import of SubstTemplateTypeParmType in return type of function. (PR #69724)

2023-10-20 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/69724 Import of a function with `auto` return type that is expanded to a `SubstTemplateTypeParmType` could fail if the function itself is the template specialization where the parameter was replaced. From 2bfad6f0fb

[clang] [clang][Analyzer] Move checker 'alpha.unix.Errno' to 'unix.Errno'. (PR #69469)

2023-10-20 Thread Balázs Kéri via cfe-commits
@@ -934,6 +934,76 @@ Check calls to various UNIX/Posix functions: ``open, pthread_once, calloc, mallo .. literalinclude:: checkers/unix_api_example.c :language: c +.. _unix-Errno: + +unix.Errno (C) +"" + +Check for improper use of ``errno``. +This checker impl

[clang] [analyzer][NFC] Combine similar methods of StreamChecker (PR #70170)

2023-10-25 Thread Balázs Kéri via cfe-commits
https://github.com/balazske edited https://github.com/llvm/llvm-project/pull/70170 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer][NFC] Combine similar methods of StreamChecker (PR #70170)

2023-10-25 Thread Balázs Kéri via cfe-commits
https://github.com/balazske requested changes to this pull request. Probably add [clang] tag to the commit message, and remove the change in DiagnosticParseKinds.td, otherwise the change looks good. https://github.com/llvm/llvm-project/pull/70170 ___

[clang] [analyzer][NFC] Combine similar methods of StreamChecker (PR #70170)

2023-10-25 Thread Balázs Kéri via cfe-commits
@@ -1349,7 +1349,7 @@ def warn_omp_extra_tokens_at_eol : Warning< "extra tokens at the end of '#pragma omp %0' are ignored">, InGroup; def err_omp_multiple_step_or_linear_modifier : Error< - "multiple %select{'step size'|'linear modifier'}0 found in linear clause">; + "m

[clang] [analyzer][NFC] Combine similar methods of StreamChecker (PR #70170)

2023-10-25 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/70170 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ASTImporter] Fix import of variable template redeclarations. (PR #72841)

2023-11-22 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/72841 From 99d6169f62862b7b1147da7fd26a85df20a0aba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 20 Nov 2023 10:14:52 +0100 Subject: [PATCH 1/2] [clang][ASTImporter] Fix import of vari

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-22 Thread Balázs Kéri via cfe-commits
@@ -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

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via cfe-commits
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

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via cfe-commits
@@ -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

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via cfe-commits
@@ -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:

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via 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

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via cfe-commits
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

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via cfe-commits
@@ -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

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via cfe-commits
@@ -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

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via cfe-commits
@@ -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

[clang] [clang][analyzer] Support `fgetc` in StreamChecker (PR #72627)

2023-11-23 Thread Balázs Kéri via cfe-commits
@@ -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

[clang] [clang][AST][ASTMerge] prevent AST nodes from being deallocated early (PR #73096)

2023-11-23 Thread Balázs Kéri via cfe-commits
balazske wrote: You have found that reason for the crash is that references to `IdentifierInfo` are remaining in `OnDiskChainedHashTableGenerator` and previously deallocated by `ASTUnit` destruction? In this case why is the `ASTUnit` (or something in it, probably `ASTContext`) the owner of the

[clang] [clang][ASTImporter] Fix import of variable template redeclarations. (PR #72841)

2023-11-23 Thread Balázs Kéri via cfe-commits
balazske wrote: I plan to fix import of `VarTemplateSpecializationDecl` in a different PR. The indicated assertion "Missing call to MapImported?" is likely to related to this part. https://github.com/llvm/llvm-project/pull/72841 ___ cfe-commits maili

<    1   2   3   4   5   6   7   8   >