[PATCH] D103094: [analyzer] Implemented RangeSet::Factory::castTo function to perform promotions, truncations and conversions

2021-11-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 388481. ASDenysPetrov added a comment. Rebased. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103094/new/ https://reviews.llvm.org/D103094 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-11-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 388219. ASDenysPetrov added a comment. Fixed comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99797/new/ https://reviews.llvm.org/D99797 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-11-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:229-233 +// We want to keep the following invariant at all times: +// ---[ First --> +// -[ Second ---> +if (First->From() > Second->From()) +

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-17 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal Please, read the discussion started from here D104285#2943449 . It's directly relates to this patch and what we've been arguing about. I'm still hesitating about this patch. On one hand we have the fact that

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-17 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @NoQ > If we ever prove that strict aliasing is violated on a given execution path > (while being enabled), the ideal thing to do is to terminate the analysis > immediately by generating a sink. We can then optionally develop a checker > that emits a warning in

[PATCH] D114006: [analyzer][NFC] Enable access to CodeGenOptions from analyzer's instances

2021-11-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D114006#3135456 , @steakhal wrote: > Sweet! > I think commit titles are not punctuated, even though they start with an > uppercase letter. Thanks! That depends on the mood at the particular moment :) But seriously,

[PATCH] D114006: [analyzer][NFC] Enable access to CodeGenOptions from analyzer's instances.

2021-11-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 387773. ASDenysPetrov added a comment. Fixed failed unittest. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114006/new/ https://reviews.llvm.org/D114006 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h

[PATCH] D114006: [analyzer]{NFC} Enable access to CodeGenOptions from analyzer's instances.

2021-11-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision. ASDenysPetrov added reviewers: martong, steakhal, Charusso, Szelethus, NoQ. ASDenysPetrov added a project: clang. Herald added subscribers: manas, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun. ASDenysPetrov

[PATCH] D113480: [analyzer] Fix region cast between the same types with different qualifiers.

2021-11-15 Thread Denys Petrov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rGf0bc7d24882a: [analyzer] Fix region cast between the same types with different qualifiers. (authored by ASDenysPetrov). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/test/Analysis/initialization.cpp:295-299 +void glob_cast_opposite_sign1() { + auto *ptr = (unsigned int *)glob_arr2; + auto x1 = ptr[0]; // no-warning + auto x2 = ptr[1]; // expected-warning{{garbage or undefined}} +}

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal > I think I know. Great! Thank you! Comment at: clang/test/Analysis/initialization.cpp:295-299 +void glob_cast_opposite_sign1() { + auto *ptr = (unsigned int *)glob_arr2; + auto x1 = ptr[0]; // no-warning + auto x2 = ptr[1]; //

[PATCH] D113480: [analyzer] Fix region cast between the same types with different qualifiers.

2021-11-10 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal Thank you! > Please clang-format the patch to reflow the touched comment. Given that's > done, you are good to go. The comment is OK. `clang-format` doesn't complain on it. > Also, wait a couple days before committing to give chance to the rest of the

[PATCH] D113480: [analyzer] Fix region cast between the same types with different qualifiers.

2021-11-10 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 386226. ASDenysPetrov added a comment. Updated according to comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113480/new/ https://reviews.llvm.org/D113480 Files: clang/lib/StaticAnalyzer/Core/Store.cpp

[PATCH] D113480: [analyzer] Fix region cast between the same types with different qualifiers.

2021-11-10 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/Store.cpp:98 QualType PointeeTy = CastToTy->getPointeeType(); QualType CanonPointeeTy = Ctx.getCanonicalType(PointeeTy); steakhal wrote: > You only use

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D110927#3117728 , @steakhal wrote: > For testing this I would recommend using a separate test file. > That being said, you should avoid globals even in tests when you can. The > distance between its declaration and use

[PATCH] D113480: [analyzer] Fix region cast between the same types with different qualifiers.

2021-11-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision. ASDenysPetrov added reviewers: steakhal, NoQ, martong. ASDenysPetrov added a project: clang. Herald added subscribers: manas, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun. ASDenysPetrov requested

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-08 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. Ping. Does anyone know how to check the status of`-fno-strict-aliasing` flag from CSA side? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D110927/new/ https://reviews.llvm.org/D110927 ___ cfe-commits mailing

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-08 Thread Denys Petrov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rGa12bfac292db: [analyzer] Retrieve a value from list initialization of multi-dimensional array… (authored by ASDenysPetrov). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-08 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal Thanks for your effort! > Yeah, I'm soo bad in review. I should have proposed these previously. Sorry. No, you're not! I'm telling you. Keep it up! :) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111654/new/ https://reviews.llvm.org/D111654

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-08 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 385457. ASDenysPetrov marked 7 inline comments as done. ASDenysPetrov added a comment. Updated according to the nits. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111654/new/ https://reviews.llvm.org/D111654 Files:

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-05 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 385096. ASDenysPetrov added a comment. Updated according to @steakhal's comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111654/new/ https://reviews.llvm.org/D111654 Files: clang/lib/StaticAnalyzer/Core/RegionStore.cpp

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal Thank you for your suggestion. I'll make corresponding changes. > I'm still worried about the fact that you assume that there is a > correspondence between `ElementRegions` and `InitListExprs`. > I cannot see why this assumption holds, since reinterpret

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-01 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 383812. ASDenysPetrov added a comment. Updated according to comments. TODO: make the feature `-fno-strict-aliasing` dependent. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D110927/new/ https://reviews.llvm.org/D110927 Files:

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-11-01 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 383751. ASDenysPetrov added a comment. Changed test to fix a buildbot failure. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111654/new/ https://reviews.llvm.org/D111654 Files: clang/lib/StaticAnalyzer/Core/RegionStore.cpp

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-29 Thread Denys Petrov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG1deccd05ba8a: [analyzer] Retrieve a character from StringLiteral as an initializer for… (authored by ASDenysPetrov). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-29 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 383396. ASDenysPetrov added a comment. - Added support of aliased types. - Added tests aliased types. - Added tests with initialization values in parentheses. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111654/new/

[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal I'll address all of your remarks. Thanks a lot! Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1630-1641 +/// Returns true if the stored value can be accessed through the pointer to +/// another type: +/// const int arr[42]

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:81 const llvm::APSInt (BaseType X) { -llvm::APSInt Dummy = Base; -Dummy = X; -return BVF.getValue(Dummy); +static llvm::APSInt Base{sizeof(BaseType) * 8, +

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 383065. ASDenysPetrov added a comment. Fixed nits. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99797/new/ https://reviews.llvm.org/D99797 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:200-204 +} else { + //[ First ]--> + //[ Second ]---> + // MIN^ + // The First range is entirely inside the Second one.

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 383054. ASDenysPetrov added a comment. @steakhal @martong Updated according to your comments. I think I'm done with this patch. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111654/new/ https://reviews.llvm.org/D111654 Files:

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D107339#3093207 , @steakhal wrote: > Next time I would rather have two patches, one of which adds tests to > document the existing behavior and a follow-up changing the behavior. It makes sense. I will take this into

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 382999. ASDenysPetrov edited the summary of this revision. ASDenysPetrov added a comment. Updated comments briefly explaining the root of the existing issue. Thanks, @steakhal and @martong. I appreciate your efforts! CHANGES SINCE LAST ACTION

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760 + // FIXME: Nevertheless, we can't do the same for cases, like: + // const char *str = "123"; // literal length is 4 + // char c = str[41];// offset is 41 +

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 382823. ASDenysPetrov added a comment. Added doc comment to `getSValFromStringLiteral` function. Fixed minor code defects. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D107339/new/ https://reviews.llvm.org/D107339 Files:

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. I'm gonna add docs to `getSValFromStringLiteral` and update the patch. And of course will fix your nits. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760 + // FIXME: Nevertheless, we can't do the same for cases, like: + //

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. I'll do an update soon taking into account all the suggestions. > Please, try to focus on marking inline comments done if you accomplished them. In the next update. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1706-1743 + // Check

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-10-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 382679. ASDenysPetrov added a comment. @martong @steakhal Updated according to your comments. Thank you! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99797/new/ https://reviews.llvm.org/D99797 Files:

[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

2021-10-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision. ASDenysPetrov added inline comments. This revision is now accepted and ready to land. Comment at: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp:44-49 +// Handle adjustment with non-comparison ops. +const llvm::APSInt =

[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov requested changes to this revision. ASDenysPetrov added inline comments. This revision now requires changes to proceed. Comment at: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp:44-49 +// Handle adjustment with non-comparison ops. +const

[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp:52 + + if (const SymSymExpr *SSE = dyn_cast(Sym)) { BinaryOperator::Opcode Op = SSE->getOpcode(); Repository: rG LLVM Github Monorepo CHANGES

[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp:46-49 +if (Assumption) { + return assumeSymRel(State, SIE, BO_NE, Zero); +} +return assumeSymRel(State, SIE, BO_EQ, Zero); Repository:

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 382361. ASDenysPetrov added a comment. @martong @steakhal Thank you for your remarks. Updated according to them (at least the best I could do for now). CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111654/new/

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1706-1743 + // Check offsets for being out of bounds. // C++20 [expr.add] 7.6.6.4 (excerpt): // If P points to an array element i of an array object x with n // elements,

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/test/Analysis/initialization.cpp:17-23 -int const arr[2][2] = {}; -void arr2init() { - int i = 1; - // FIXME: Should recognize that it is 0. - clang_analyzer_eval(arr[i][0]); // expected-warning{{UNKNOWN}} -} -

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1643-1654 + const VarRegion *VR = dyn_cast(R->getSuperRegion()); + SmallVector SValOffsets; + SValOffsets.push_back(R->getIndex()); + if (const ElementRegion *ER =

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @martong (inline) Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760 + // FIXME: Nevertheless, we can't do the same for cases, like: + // const char *str = "123"; // literal length is 4 + // char c = str[41];//

[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1623 if (!Constraint.containsZero()) { - State = RCM.assumeSymNE(State, LHS, Zero, Zero); + State = RCM.assumeSymRel(State, LHS, BO_NE, Zero); if

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1618-1627 +const SymbolRef LHS = Sym->getLHS(); +const llvm::APSInt = +Builder.getBasicValueFactory().getValue(0, Sym->getType()); +// a % b != 0

[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1623 if (!Constraint.containsZero()) { - State = RCM.assumeSymNE(State, LHS, Zero, Zero); + State = RCM.assumeSymRel(State, LHS, BO_NE, Zero); if

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760 + // FIXME: Nevertheless, we can't do the same for cases, like: + // const char *str = "123"; // literal length is 4 + // char c = str[41];// offset is 41 +

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG3b1165ba3d15: [analyzer] Retrieve incomplete array extent from its redeclaration. (authored by ASDenysPetrov). Changed prior to commit: https://reviews.llvm.org/D111542?vs=381252=381944#toc

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG44e803ef6d41: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions (authored by ASDenysPetrov). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1654 + // NOTE: If `Init` is non-null, then a new `VD` is non-null for sure. So check + // `Init` for null only and don't worry about the replaced `VD`. if (!Init)

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D106681#3083409 , @steakhal wrote: > Sorry for blocking the review of this one for so long. Thank you for the review! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106681/new/ https://reviews.llvm.org/D106681

[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1623 if (!Constraint.containsZero()) { - State = RCM.assumeSymNE(State, LHS, Zero, Zero); + State = RCM.assumeSymRel(State, LHS, BO_NE, Zero); if

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-25 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1618-1627 +const SymbolRef LHS = Sym->getLHS(); +const llvm::APSInt = +Builder.getBasicValueFactory().getValue(0, Sym->getType()); +// a % b != 0

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-10-22 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @martong Thanks for your inlines. I'll update the patch. Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:81 const llvm::APSInt (BaseType X) { -llvm::APSInt Dummy = Base; -Dummy = X; -return BVF.getValue(Dummy); +

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-22 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 381562. ASDenysPetrov added a comment. Improved. Rebased on top of D107339 . @martong kind ping. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111654/new/ https://reviews.llvm.org/D111654 Files:

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-22 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 381533. ASDenysPetrov added a comment. Fixed test unpassing in `array-struct-region.c`. Added examples in comments according to suggestions. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D107339/new/ https://reviews.llvm.org/D107339 Files:

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1708-1710 + // Handle StringLiteral. + if (const auto *SL = dyn_cast(Init)) +return getSValFromStringLiteral(SL, Offset, R->getElementType()); martong wrote: > I

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/test/Analysis/initialization.c:103 +void glob_arr_index4() { + clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}} +} ASDenysPetrov wrote: > steakhal wrote: > > ASDenysPetrov wrote: > >

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/test/Analysis/initialization.c:103 +void glob_arr_index4() { + clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}} +} steakhal wrote: > ASDenysPetrov wrote: > > ASDenysPetrov wrote: > >

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @martong > I am close to accepting this. However, D111542 > should be its parent patch. I think > similar issues could arise here as well, so, redecl chain tests would be > really beneficial. I think I'm done. You can proceed

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D107339#3075306 , @steakhal wrote: > Why does `glob_invalid_index7()` and `glob_invalid_index8()` differ in > behavior? > I would expect that the analyzer produces the same `Loc` symbolic value for > both cases thus,

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 381274. ASDenysPetrov added a comment. Rebased. Improved behavior to make `glob_invalid_index8` case passed and some other cases. Added more tests. Added tests for universal characters. CHANGES SINCE LAST ACTION

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 381252. ASDenysPetrov added a comment. Rebased. Updated comment for obscure behaviour of `getAnyInitializer` function. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111542/new/ https://reviews.llvm.org/D111542 Files:

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1649-1653 + // NOTE: `VD` is always non-null if `Init` is non-null, so we can check for + // null only one of them. + const Expr *Init = VD->getAnyInitializer(VD); if (!Init)

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-21 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 381240. ASDenysPetrov added a comment. Added a comment to //initialization.c//, that we can reason about values of constant array which doesn't have an initializer. This is not such simple for C++, since there are much more ways to initialize the

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/test/Analysis/initialization.c:103 +void glob_arr_index4() { + clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}} +} ASDenysPetrov wrote: > steakhal wrote: > > martong wrote: > > >

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/test/Analysis/initialization.c:103 +void glob_arr_index4() { + clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}} +} steakhal wrote: > martong wrote: > > ASDenysPetrov wrote: > > >

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D106681#3075337 , @steakhal wrote: > I just wanted you to think about these cases. > BTW this should work for **L1646**: > > extern const int arr[]; // Incomplete array type > void top() { > (void)arr[42]; > }

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380936. ASDenysPetrov added a comment. Fixed redefinition in test file initialization.cpp. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111542/new/ https://reviews.llvm.org/D111542 Files: clang/lib/StaticAnalyzer/Core/RegionStore.cpp

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380934. ASDenysPetrov added a comment. Fixed redefinition in test file //initialization.cpp//. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106681/new/ https://reviews.llvm.org/D106681 Files: clang/lib/StaticAnalyzer/Core/RegionStore.cpp

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D111542#3073709 , @NoQ wrote: > Amazing, thanks a lot! Thank you, @NoQ, for the acceptance. I got some fresher update. And, of course in order to load it, we should accept a parent revision D106681

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380910. ASDenysPetrov added a comment. Updated according to the latest suggestions. @martong I think now this patch is way more simple and clear than before. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111542/new/

[PATCH] D106681: [analyzer][NFCI] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1666 + if (!OffsetVal.hasValue()) +return UnknownVal(); + Item 2 from the Summary. This was borrowed from `RegionStoreManager::getBindingForFieldOrElementCommon`

[PATCH] D106681: [analyzer][NFC] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380906. ASDenysPetrov added a comment. Minor comment update. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106681/new/ https://reviews.llvm.org/D106681 Files: clang/lib/StaticAnalyzer/Core/RegionStore.cpp

[PATCH] D106681: [analyzer][NFC] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380897. ASDenysPetrov added a comment. Make changes according to comments. Thanks to @steakhal CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106681/new/ https://reviews.llvm.org/D106681 Files: clang/lib/StaticAnalyzer/Core/RegionStore.cpp

[PATCH] D106681: [analyzer][NFC] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D106681#3074678 , @steakhal wrote: > I think it's fine, maybe `NFCi` is would be slightly more accurate, while > stating the minor behavior change and the reason for doing so in the patch > summary could further

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D107339#3060812 , @martong wrote: > I am close to accepting this. However, D111542 > should be its parent patch. I think > similar issues could arise here as well, so, redecl chain

[PATCH] D106681: [analyzer][NFC] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1686-1689 + // Array's declaration should have an initializer. + const Expr *Init = VD->getAnyInitializer(); + if (!Init) +return None; ASDenysPetrov wrote: >

[PATCH] D106681: [analyzer][NFC] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1686-1689 + // Array's declaration should have an initializer. + const Expr *Init = VD->getAnyInitializer(); + if (!Init) +return None; steakhal wrote: > This

[PATCH] D106681: [analyzer][NFC] Move a block from `getBindingForElement` to separate functions

2021-10-20 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal All your comments are fair in terms of NFC. I also tried to improve some places. I think I should requalificate the revision to non-NFC, that I can be more untied to bring some improvements. Comment at:

[PATCH] D111534: [analyzer][NFC] Refactor CallEvent::isCalled()

2021-10-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:1289 + /// E.g. { "std", "vector", "data" } -> "vector", "std" + auto begin_qualified_name_parts() const { +return std::next(QualifiedName.rbegin());

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380518. ASDenysPetrov added a comment. Rebased on top of D106681 . CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111542/new/ https://reviews.llvm.org/D111542 Files:

[PATCH] D106681: [analyzer][NFC] Move a block from `getBindingForElement` to separate functions

2021-10-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 380441. ASDenysPetrov retitled this revision from "[analyzer] Retrieve a value from list initialization of constant multi-dimensional array." to "[analyzer][NFC] Move a block from `getBindingForElement` to separate functions". ASDenysPetrov edited the

[PATCH] D111534: [analyzer][NFC] Refactor CallEvent::isCalled()

2021-10-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. Thank you for adding me. I'll make a deeper review later. Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:1289 + /// E.g. { "std", "vector", "data" } -> "vector", "std" + auto begin_qualified_name_parts() const {

[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-10-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D99797#3059203 , @steakhal wrote: > PS: the test coverage is outstanding! Thank you for this analysis. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:149 + +RangeSet

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-18 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1618-1627 +const SymbolRef LHS = Sym->getLHS(); +const llvm::APSInt = +Builder.getBasicValueFactory().getValue(0, Sym->getType()); +// a % b != 0

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-15 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D111654#3060822 , @martong wrote: > Could you please rebase on top of D111542 ? > That would make the changes direct and clear and the review would be easier. OK. I'll rebase.

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-15 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1669-1711 // The array index has to be known. if (auto CI = R->getIndex().getAs()) { -// If it is not an array, return Undef. -QualType T

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-15 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. Ok. Let's see what the benefits it brings. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1619 + return true; +const SymExpr *LHS = Sym->getLHS(); +const llvm::APSInt = steakhal wrote: >

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1619 + return true; +const SymExpr *LHS = Sym->getLHS(); +const llvm::APSInt = steakhal wrote: > Since `SymbolRef` actually is already

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1661-1663 // Check if the containing array has an initialized value that we can trust. // We can trust a const value or a value of a global initializer in main(). +const

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision. ASDenysPetrov added reviewers: NoQ, aaron.ballman, steakhal, martong, vsavchenko. Herald added subscribers: manas, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun. ASDenysPetrov requested review of

[PATCH] D111640: [Analyzer][NFC] Add RangedConstraintManager to ConstraintAssignor

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D111640#3058622 , @martong wrote: > In D111640#3058304 , @steakhal > wrote: > >> It looks good. >> Do you think we could remove the `RangedConstraintManager` abstraction? > >

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1609-1612 + const SymExpr *LHS = Sym->getLHS(); + const llvm::APSInt = + Builder.getBasicValueFactory().getValue(0, LHS->getType()); + State =

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1663 // We can trust a const value or a value of a global initializer in main(). -const VarDecl *VD = VR->getDecl(); +const VarDecl *VD =

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 378684. ASDenysPetrov retitled this revision from "[analyzer] Retrieve VLA extent from its redeclaration." to "[analyzer] Retrieve incomplete array extent from its redeclaration.". ASDenysPetrov edited the summary of this revision. CHANGES SINCE LAST

<    1   2   3   4   5   6   7   >