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

2023-12-13 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/3] [clang][ASTImporter] Improve import of f

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

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

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

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

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-13 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/74296 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

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

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-13 Thread Balázs Kéri via cfe-commits
@@ -299,6 +299,60 @@ void error_fseek_0(void) { fclose(F); } +void error_fflush_0(void) { + FILE *F = tmpfile(); + int Ret; + fflush(NULL); // no-warning + if (!F) { +if ((Ret = fflush(F)) != EOF) + clang_analyzer_eval(Ret == 0); // expected

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

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

[clang] [clang][ASTImporter] skip TemplateTypeParmDecl in VisitTypeAliasTemplateDecl (PR #74919)

2023-12-13 Thread Balázs Kéri via cfe-commits
balazske wrote: This code for the loop in `VisitTypeAliasTemplateDecl` should work: ``` for (auto *FoundDecl : FoundDecls) { if (!FoundDecl->isInIdentifierNamespace(IDNS)) continue; if (auto *FoundAlias = dyn_cast(FoundDecl)) { if (IsStructuralMatch(D, FoundAlias))

[clang] [clang][ASTImporter] skip TemplateTypeParmDecl in VisitTypeAliasTemplateDecl (PR #74919)

2023-12-13 Thread Balázs Kéri via cfe-commits
@@ -9284,6 +9284,29 @@ TEST_P(ASTImporterOptionSpecificTestBase, // EXPECT_EQ(ToF1Imported->getPreviousDecl(), ToF1); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportTypeAliasTemplateDecl) { balazske wrote: I like better names for the test (`ImportTypeA

[clang] [clang][ASTImporter] skip TemplateTypeParmDecl in VisitTypeAliasTemplateDecl (PR #74919)

2023-12-19 Thread Balázs Kéri via cfe-commits
balazske wrote: > > Is import of `Callable` should be failed? I compiled this code > > ```c++ > struct S; > template > using Callable = S; > template > using Callable = S; > ``` > > and clang report an error. Yes the test was not exact, with the new code this import should fail. https://gi

[clang] [clang][ASTImporter] skip TemplateTypeParmDecl in VisitTypeAliasTemplateDecl (PR #74919)

2023-12-19 Thread Balázs Kéri via cfe-commits
@@ -1977,6 +1977,22 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, D2->getTemplatedDecl()->getType()); } +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, +

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

2023-12-19 Thread Balázs Kéri via cfe-commits
@@ -5050,6 +5050,59 @@ TEST_P(ImportFriendClasses, RecordVarTemplateDecl) { EXPECT_EQ(ToTUX, ToX); } +TEST_P(ASTImporterOptionSpecificTestBase, VarTemplateDeclConflict) { + getToTuDecl( + R"( + template + constexpr int X = 1; + )", + Lang_CXX14); +

[clang] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr (PR #74813)

2023-12-19 Thread Balázs Kéri via cfe-commits
@@ -3220,6 +3220,12 @@ TEST_P(ImportExpr, UnresolvedMemberExpr) { compoundStmt(has(callExpr(has(unresolvedMemberExpr()); } +TEST_P(ImportExpr, BuiltinBitCastExpr) { + MatchVerifier Verifier; + testImport("void declToImport(int T) { (void)__builtin_bi

[clang] [clang][ASTImporter] add processing of SubstNonTypeTemplateParmExpr in isAncestorDeclContextOf (PR #74991)

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

[clang] [clang][ASTImporter] Support Importer of BuiltinBitCastExpr (PR #74813)

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

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

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

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-20 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/74296 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-20 Thread Balázs Kéri via cfe-commits
@@ -299,6 +299,74 @@ void error_fseek_0(void) { fclose(F); } +void error_fflush_after_fclose(void) { + FILE *F = tmpfile(); + int Ret; + fflush(NULL); // no-warning + if (!F) +return; + if ((Ret = fflush(F)) != 0) +clang_analyzer_eval(Ret ==

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-20 Thread Balázs Kéri via cfe-commits
@@ -1191,6 +1199,82 @@ void StreamChecker::evalSetFeofFerror(const FnDescription *Desc, C.addTransition(State); } +void StreamChecker::preFflush(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const { + ProgramStateRef St

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-20 Thread Balázs Kéri via cfe-commits
@@ -1191,6 +1199,82 @@ void StreamChecker::evalSetFeofFerror(const FnDescription *Desc, C.addTransition(State); } +void StreamChecker::preFflush(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const { + ProgramStateRef St

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-20 Thread Balázs Kéri via cfe-commits
@@ -299,6 +299,74 @@ void error_fseek_0(void) { fclose(F); } +void error_fflush_after_fclose(void) { + FILE *F = tmpfile(); + int Ret; + fflush(NULL); // no-warning + if (!F) +return; + if ((Ret = fflush(F)) != 0) +clang_analyzer_eval(Ret ==

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-20 Thread Balázs Kéri via cfe-commits
@@ -1191,6 +1199,82 @@ void StreamChecker::evalSetFeofFerror(const FnDescription *Desc, C.addTransition(State); } +void StreamChecker::preFflush(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const { + ProgramStateRef St

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-20 Thread Balázs Kéri via cfe-commits
@@ -299,6 +299,74 @@ void error_fseek_0(void) { fclose(F); } +void error_fflush_after_fclose(void) { + FILE *F = tmpfile(); + int Ret; + fflush(NULL); // no-warning + if (!F) +return; + if ((Ret = fflush(F)) != 0) +clang_analyzer_eval(Ret ==

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-20 Thread Balázs Kéri via cfe-commits
@@ -1191,6 +1199,82 @@ void StreamChecker::evalSetFeofFerror(const FnDescription *Desc, C.addTransition(State); } +void StreamChecker::preFflush(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const { + ProgramStateRef St

[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

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

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

[clang] [analyzer] Switch to PostStmt callbacks in ArrayBoundV2 (PR #72107)

2023-11-23 Thread Balázs Kéri via cfe-commits
@@ -64,6 +100,28 @@ double arrayInStructPtr(struct vec *pv) { // expected-note@-2 {{Access of the field 'elems' at index 64, while it holds only 64 'double' elements}} } +struct item { + int a, b; +} itemArray[20] = {0}; + +int structOfArrays(void) { balaz

[clang] [clang][ASTImporter] IdentifierInfo of Attribute should be set using 'ToASTContext' (PR #73290)

2023-11-24 Thread Balázs Kéri via cfe-commits
https://github.com/balazske requested changes to this pull request. I think it is better to add the import of AttrName to the attribute import code (function `Import(const Attr *FromAttr)` and what is called from it). Probably it works to add it to `AttrImporter::cloneAttr` and do it like `cons

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

2023-11-24 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/69724 ___ 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)

2023-11-24 Thread Balázs Kéri via cfe-commits
@@ -437,12 +439,67 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const UnaryOperator *E1, + const CXXOperatorCallExpr *E2) { + re

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

2023-11-24 Thread Balázs Kéri via cfe-commits
https://github.com/balazske edited https://github.com/llvm/llvm-project/pull/72242 ___ 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)

2023-11-24 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][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-24 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/73335 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-24 Thread Balázs Kéri via cfe-commits
@@ -50,6 +50,7 @@ size_t fread(void *restrict, size_t, size_t, FILE *restrict); size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict); int fgetc(FILE *stream); int fputc(int ch, FILE *stream); +int fputs(const char *str, FILE *stream); balazske wr

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-24 Thread Balázs Kéri via cfe-commits
@@ -774,26 +780,45 @@ void StreamChecker::evalFgetcFputc(const FnDescription *Desc, // `fgetc` returns the read character on success, otherwise returns EOF. // `fputc` returns the written character on success, otherwise returns EOF. + // `fputs` returns a non negative va

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

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

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-27 Thread Balázs Kéri via cfe-commits
@@ -824,20 +817,76 @@ void StreamChecker::evalFgetcFputc(const FnDescription *Desc, // If a (non-EOF) error occurs, the resulting value of the file position // indicator for the stream is indeterminate. - StreamErrorState NewES; - if (IsRead) -NewES = -OldSS

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-27 Thread Balázs Kéri via cfe-commits
@@ -824,20 +817,76 @@ void StreamChecker::evalFgetcFputc(const FnDescription *Desc, // If a (non-EOF) error occurs, the resulting value of the file position // indicator for the stream is indeterminate. - StreamErrorState NewES; - if (IsRead) -NewES = -OldSS

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-27 Thread Balázs Kéri via cfe-commits
@@ -824,20 +817,76 @@ void StreamChecker::evalFgetcFputc(const FnDescription *Desc, // If a (non-EOF) error occurs, the resulting value of the file position // indicator for the stream is indeterminate. - StreamErrorState NewES; - if (IsRead) -NewES = -OldSS

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-27 Thread Balázs Kéri via cfe-commits
@@ -824,20 +817,76 @@ void StreamChecker::evalFgetcFputc(const FnDescription *Desc, // If a (non-EOF) error occurs, the resulting value of the file position // indicator for the stream is indeterminate. - StreamErrorState NewES; - if (IsRead) -NewES = -OldSS

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-27 Thread Balázs Kéri via cfe-commits
@@ -141,6 +141,24 @@ void error_fputc(void) { fputc('A', F); // expected-warning {{Stream might be already closed}} } +void error_fputs(void) { + FILE *F = tmpfile(); + if (!F) +return; + int Ret = fputs("XYZ", F); + if (Ret >= 0) { +clang_analyzer_eval(feof(F) |

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

2023-11-27 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/2] [clang][ASTImporter] Improve structural

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

2023-11-27 Thread Balázs Kéri via cfe-commits
balazske wrote: I have updated the comment. Probably I can test it with more projects after the other fixes with variable templates (#72841) are finished, then there may be less crashes. https://github.com/llvm/llvm-project/pull/72242 ___ cfe-commits

[clang] [analyzer] Switch to PostStmt callbacks in ArrayBoundV2 (PR #72107)

2023-11-27 Thread Balázs Kéri via cfe-commits
@@ -350,17 +383,38 @@ void ArrayBoundCheckerV2::checkLocation(SVal Location, bool IsLoad, if (ExceedsUpperBound) { if (!WithinUpperBound) { // We know that the index definitely exceeds the upper bound. -std::string RegName = getRegionName(Reg); -

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-28 Thread Balázs Kéri via cfe-commits
@@ -824,20 +817,76 @@ void StreamChecker::evalFgetcFputc(const FnDescription *Desc, // If a (non-EOF) error occurs, the resulting value of the file position // indicator for the stream is indeterminate. - StreamErrorState NewES; - if (IsRead) -NewES = -OldSS

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

2023-11-28 Thread Balázs Kéri via cfe-commits
balazske wrote: I prefer to have the new test code with `StreamTesterChecker_make_feof_stream` in a new test function (with appropriate name like `write_after_eof_is_allowed`), to improve code maintainability (`fputc` and `fputs` can be in the same function). In github PR's usually force push

[clang] [clang][analyzer] Support `fputs` in the StreamChecker (PR #73335)

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

[clang] [clang][ASTImporter] IdentifierInfo of Attribute should be set using 'ToASTContext' (PR #73290)

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

[clang] [clang][analyzer] Support `fgets` in the SteamChecker (PR #73638)

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

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-21 Thread Balázs Kéri via cfe-commits
@@ -1191,6 +1199,83 @@ void StreamChecker::evalSetFeofFerror(const FnDescription *Desc, C.addTransition(State); } +void StreamChecker::preFflush(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const { + ProgramStateRef St

[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

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

[clang] [clang][ASTImporter] Import AlignValueAttr correctly. (PR #75308)

2023-12-21 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/75308 From 2e6fe315bdebea705d84b4152a831e5934b659eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 13 Dec 2023 10:23:48 +0100 Subject: [PATCH 1/2] [clang][ASTImporter] Import AlignValueA

[clang] [clang][ASTImporter] Import AlignValueAttr correctly. (PR #75308)

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

[clang] [clang][analyzer] Improve modeling of `fileno` in the StreamChecker (PR #76207)

2023-12-22 Thread Balázs Kéri via cfe-commits
balazske wrote: I do not see much benefit of adding `fileno` to the checker in the current state. If the `StdLibraryFunctionsChecker` is turned on it will anyway do a similar modeling of `fileno` (this applied to `ftell` too). The `fileno` and `ftell` are semantically different and `fileno` ca

[clang] [clang][ASTImporter] skip TemplateTypeParmDecl in VisitTypeAliasTemplateDecl (PR #74919)

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

[clang] [clang][ASTImporter][StructuralEquivalence] improve StructuralEquivalence on recordType (PR #76226)

2024-01-02 Thread Balázs Kéri via cfe-commits
@@ -1491,6 +1492,12 @@ static bool IsRecordContextStructurallyEquivalent(RecordDecl *D1, return false; } +if (auto *D1Spec = dyn_cast(DC1)) { + auto *D2Spec = dyn_cast(DC2); balazske wrote: It would be better to check if `D2Spec` is null

[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)

2024-01-03 Thread Balázs Kéri via cfe-commits
@@ -9342,6 +9342,38 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportConflictTypeAliasTemplate) { EXPECT_FALSE(ImportedCallable); } +AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) { + if (auto Instantiate = Node.getInstantiatedFrom()) { +if (

[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)

2024-01-03 Thread Balázs Kéri via cfe-commits
@@ -9342,6 +9342,38 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportConflictTypeAliasTemplate) { EXPECT_FALSE(ImportedCallable); } +AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) { + if (auto Instantiate = Node.getInstantiatedFrom()) { +if (

[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)

2024-01-03 Thread Balázs Kéri via cfe-commits
@@ -9342,6 +9342,38 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportConflictTypeAliasTemplate) { EXPECT_FALSE(ImportedCallable); } +AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) { + if (auto Instantiate = Node.getInstantiatedFrom()) { +if (

[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Balázs Kéri via cfe-commits
@@ -2511,10 +2511,12 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( .ArgConstraint(NotNull(ArgNo(0; // char *mkdtemp(char *template); -// FIXME: Improve for errno modeling. addToFunctionSummaryMap( "mkdtemp", Signature(ArgTypes

[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Balázs Kéri via cfe-commits
@@ -54,3 +51,25 @@ int errno_lseek(int fildes, off_t offset) { } return 0; } + +void errno_mkstemp(char *template) { + int FD = mkstemp(template); + if (FD >= 0) { +if (errno) {}// expected-warning{{An undefined value may be read from 'errno'}} +

[clang] [clang][ASTImporter][StructuralEquivalence] improve StructuralEquivalence on recordType (PR #76226)

2024-01-03 Thread Balázs Kéri via cfe-commits
@@ -1491,6 +1492,12 @@ static bool IsRecordContextStructurallyEquivalent(RecordDecl *D1, return false; } +if (auto *D1Spec = dyn_cast(DC1)) { + auto *D2Spec = dyn_cast(DC2); balazske wrote: I see now that the old code was better, there i

[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-03 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. LGTM (if the tests pass) https://github.com/llvm/llvm-project/pull/76671 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Support 'fdopen' in the StreamChecker (PR #76776)

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

[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)

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

[clang] [clang][analyzer] Support 'fdopen' in the StreamChecker (PR #76776)

2024-01-03 Thread Balázs Kéri via cfe-commits
balazske wrote: One note that should be added to the documentation: The `StreamChecker` does not handle file descriptors associated to streams. Therefore some issues can appear, for example `fileno` does not return the value that was used to open a stream with `fdopen`, and the standard streams

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

2024-01-04 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/76979 Some stream functions were recently added to `StreamChecker` that were not modeled by `StdCLibraryFunctionsChecker`. To ensure consistency these functions are added to the other checker too. Some of the related

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

2024-01-05 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/2] [clang][analyzer] Add missing stream rel

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

2024-01-05 Thread Balázs Kéri via cfe-commits
balazske wrote: Next step is to add all functions to the non-POSIX part that exist in the C standard (at least the stream functions), and change `fread` and `fwrite` too (currently `errno` is always modeled but should be only in POSIX mode). https://github.com/llvm/llvm-project/pull/76979

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

2024-01-05 Thread Balázs Kéri via cfe-commits
@@ -2516,12 +2516,15 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( .ArgConstraint(NotNull(ArgNo(0; // char *getcwd(char *buf, size_t size); -// FIXME: Improve for errno modeling. addToFunctionSummaryMap( "getcwd", Signature(Ar

[clang] [clang][analyzer] Support 'fdopen' in the StreamChecker (PR #76776)

2024-01-05 Thread Balázs Kéri via cfe-commits
balazske wrote: Documentation is in **checkers.rst** but not accurate now. It must be updated with more information. https://github.com/llvm/llvm-project/pull/76776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

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

2024-01-05 Thread Balázs Kéri via cfe-commits
balazske wrote: > Why do we need to keep these two checkers in-sync? Technically the checkers work independently. There is a functionality that is added by `StdLibraryFunctionsChecker`, the modeling of `errno` (this works even if `StreamChecker` is not used), and maybe some preconditions are m

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

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

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

2024-01-05 Thread Balázs Kéri via cfe-commits
balazske wrote: I can not check what caused exactly the problems but the change looks correct and in change D154764 there seems to be no reason for re-ordering at non-record objects. As an improvement, some tests could be added that check for re-ordering at `RecordDecl` and (this is the more

[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

<    1   2   3   4   5   6   7   8   9   >