[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 357463. ASDenysPetrov added a comment. Added more descriptive comments. Fixed `RangeConstraintManager::updateExistingConstraints` function. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103096/new/ https://reviews.llvm.org/D103096 Files: c

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @vsavchenko Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2797-2799 +ProgramStateRef +RangeConstraintManager::updateExistingConstraints(ProgramStateRef State, + SymbolRef Sym,

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D103096#2866730 , @vsavchenko wrote: > In D103096#2866704 , @ASDenysPetrov > wrote: > >> @vsavchenko > > That's not the question I'm asking. Why do you need to set constraints

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. Generally, with this patch we kinda have several constraints for each cast of a single symbol. And we shall care for all of that constraints and timely update them (if possible). For instance, we have `int x` and met casts of this symbol in code: int x; (char)

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @vsavchenko > I still want to hear a good explanation why is it done this way. Here `c` is > mapped to `(char)x`, and we have `[-10, 10]` directly associated with it, but > we also have `(short)x` associated with `[8, 8]`. Why can't > `VisitSymbolCast` look up

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @vsavchenko > Why did you write it this way!? I want the map contains only valid constraints at any time, so we can easely get them without traversing with all variants intersecting with each other. I'm gonna move `updateExistingConstraints ` logic to `VisitSymbo

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1241 + // Find the first constraint and exit the loop. + RSPtr = getConstraint(State, S); +} vsavchenko wrote: > Why do you get associated cons

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @vsavchenko I've updated the summary. I hope, I addressed your question. Currently, this patch has some issues and may not fully reflect the summary. I'll update it soon(not without your suggestions). Thanks. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D

[PATCH] D104381: [analyzer] Added a test case for PR46264

2021-07-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @NoQ Just a ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104381/new/ https://reviews.llvm.org/D104381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-13 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1203 +if (!Opts.ShouldSupportSymbolicIntegerCasts) + return VisitSymExpr(Sym); + vsavchenko wrote: > Why do you use `VisitSymExpr` here? You want t

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-13 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:293-296 +SymbolRef Sym = Operand; +while (isa(Sym)) + Sym = cast(Sym)->Operand; +return Sym; vsavchenko wrote: > Do you think

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-13 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:293-296 +SymbolRef Sym = Operand; +while (isa(Sym)) + Sym = cast(Sym)->Operand; +return Sym; vsavchenko wrote: > ASDenysPetrov

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-13 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1203 +if (!Opts.ShouldSupportSymbolicIntegerCasts) + return VisitSymExpr(Sym); + vsavchenko wrote: > ASDenysPetrov wrote: > > vsavchenko wrote: > >

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

2021-07-14 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 358656. ASDenysPetrov added a comment. Rebased CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99797/new/ https://reviews.llvm.org/D99797 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h clang/lib/Stat

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-14 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:293-296 +SymbolRef Sym = Operand; +while (isa(Sym)) + Sym = cast(Sym)->Operand; +return Sym; vsavchenko wrote: > ASDenysPetrov

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

2021-07-14 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 358661. 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 clang/include/clang/Stati

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-14 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 358669. ASDenysPetrov added a comment. Rebased CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103096/new/ https://reviews.llvm.org/D103096 Files: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h clang/include/clang/StaticAnalyze

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-14 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 358685. ASDenysPetrov added a comment. Made`ignoreCast` non-virtual . CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103096/new/ https://reviews.llvm.org/D103096 Files: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h clang/incl

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers.

2021-07-14 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h:293-296 +SymbolRef Sym = Operand; +while (isa(Sym)) + Sym = cast(Sym)->Operand; +return Sym; vsavchenko wrote: > ASDenysPetrov

[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];// offs

[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 = dyn_cast(R->getSu

[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: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 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/ https://reviews.llvm.org/D11165

[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] 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 SI

[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 llvm::AP

[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 &Zero

[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: clang/include/clang/StaticAnalyzer/Co

[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] 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] 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: clang/lib/StaticAna

[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-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 https

[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 ac

[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: clang/lib/Sta

[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] 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 clang/lib/

[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 &from(BaseType X) { -llvm::APSInt Dummy = Base; -Dummy = X; -return BVF.getValue(Dummy); +static llvm::APSInt Base{sizeof(BaseType) * 8, +

[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] 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/ https://reviews.llvm.org

[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 https://reviews.llvm

[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 clang/test/Anal

[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: clang/lib/Stati

[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 c

[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 clang/test/A

[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: clang/lib/StaticAnalyzer

[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
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 https://revie

[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 lis

[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 rev

[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 j

[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 `CanonPointeeTy.getLocal

[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 clang/test/Analysis/initializa

[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] 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]; // expe

[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] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

2021-02-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 326651. ASDenysPetrov added a comment. A bit improved. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97388/new/ https://reviews.llvm.org/D97388 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h clang/lib/StaticAna

[PATCH] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

2021-02-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal > Please make sure that you specify the parent revision or the patch can be > applied on top of the tree. Sorry, probably missed to add a parent revision. Done. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97388/new/ https://reviews.llvm.org/

[PATCH] D97874: [analyzer] Improve SVal cast from integer to bool using known RangeSet

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

[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 328105. ASDenysPetrov added a comment. Rebased on main. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D96090/new/ https://reviews.llvm.org/D96090 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h clang/include/clan

[PATCH] D97277: [analyzer] Eliminate dispatchCast, evalCastFromNonLoc and evalCastFromLoc functions from SValBuilder

2021-03-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 328106. ASDenysPetrov added a comment. Rebased on main. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97277/new/ https://reviews.llvm.org/D97277 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h clang/lib/StaticAn

[PATCH] D97296: [analyzer] Add a new parameter ProgramStateRef to SValBuilder::evalCast function

2021-03-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 328107. ASDenysPetrov added a comment. Rebased on main. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97296/new/ https://reviews.llvm.org/D97296 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h clang/include/clan

[PATCH] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

2021-03-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 328108. ASDenysPetrov added a comment. Rebased on main. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97388/new/ https://reviews.llvm.org/D97388 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h clang/lib/StaticAn

[PATCH] D97874: [analyzer] Improve SVal cast from integer to bool using known RangeSet

2021-03-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 328109. ASDenysPetrov added a comment. Rebased on main. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97874/new/ https://reviews.llvm.org/D97874 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h clang/lib/St

[PATCH] D97296: [analyzer] Add a new parameter ProgramStateRef to SValBuilder::evalCast function

2021-03-04 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 328238. ASDenysPetrov added a comment. Missed to add changes in unittests. Fixed. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97296/new/ https://reviews.llvm.org/D97296 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/Environm

[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-05 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @NoQ Thanks, I could finally draw your attention :) > When, and why, would a regular user use this functionality? IMO there is no reason to use evalCast without an **original** type. But I'm not sure that you can get an **original** type in every case. About `Cas

[PATCH] D97874: [analyzer] Improve SVal cast from integer to bool using known RangeSet

2021-03-05 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @NoQ Thanks for your comment. Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:877-879 + std::tie(IsZero, IsNotZero) = + getStateManager().getConstraintManager().isSymValWithinOrOutsideRange( + State, SE, Zero,

[PATCH] D95799: [analyzer] Symbolicate float values with integral casting

2021-03-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @NoQ wrote: > IIUC this is roughly the first time ever when `SValBuilder` starts emitting > symbols of float type. This is a huge change with an almost unlimited scope > of unexpected side effects and very rigorous testing is required to > understand the actual e

[PATCH] D97874: [analyzer] Improve SVal cast from integer to bool using known RangeSet

2021-03-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 329282. ASDenysPetrov added a comment. Updated due to discussion. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97874/new/ https://reviews.llvm.org/D97874 Files: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp clang/test/Analysis/cast_symbo

[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-10 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 329699. ASDenysPetrov edited the summary of this revision. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D96090/new/ https://reviews.llvm.org/D96090 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h clang/include/cla

[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-10 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D96090#261 , @steakhal wrote: > You could still pass a default constructed QualType at each callsite. We can try. At least it will be like this is a hack for the particular cases then, that will emphesys to pay atten

[PATCH] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

2021-03-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D97388#2615104 , @NoQ wrote: > Ok then, let's try to land it! 🤞 Thanks for the approval. Before land this we should land the preparatory revision D97296 . Please, take a look. CHANGES S

[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-03-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 329982. ASDenysPetrov added a comment. Updated. In D96090#2618410 , @NoQ wrote: > In all cases we're supposed to have an **original** type, whether we need it > or not. Simply because we're simulating a typed l

[PATCH] D98504: [clang][Checkers] Fix PthreadLockChecker state cleanup at dead symbol.

2021-03-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. Hi, @balazske Comment at: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp:290-304 // Existence in DestroyRetVal ensures existence in LockMap. // Existence in Destroyed also ensures that the lock state for lockR is either // Unto

[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 https://reviews.l

[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 req

[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 clang/

[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, it'

[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 s

[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 almo

[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()) + sw

[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 clang/

[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 clang/include/clang/Stat

[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 388512. ASDenysPetrov added a comment. Fixed missed part during rebasing in the unit test. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103094/new/ https://reviews.llvm.org/D103094 Files: clang/include/clang/StaticAnalyzer/Core/PathSensiti

[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers

2021-11-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 388552. ASDenysPetrov added a comment. Rebased. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103096/new/ https://reviews.llvm.org/D103096 Files: clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h clang/include/clang/StaticAnalyz

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

2021-11-19 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D114006#3142313 , @martong wrote: > LGTM! Thanks, guys! I'll load it as soon as D110927 also be ready for load(I'm working on it), as this patch is just a preparatory one. CHANGES SI

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

2021-11-23 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov abandoned this revision. ASDenysPetrov added a comment. Temporary suspended this revision in favor of making a new checker //StrictAliasingChecker//, which would define an access to values through unpermited types as Unefined Behavior according to certain statements of the current

[PATCH] D114441: [analyzer][NFC] Refactor AnalysisConsumer::getModeForDecl()

2021-11-29 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:599-603 + const SourceLocation Loc = [&SM](Decl *D) -> SourceLocation { +const Stmt *Body = D->getBody(); +SourceLocation SL = Body ? Body->getBeginLoc() : D->getLocat

[PATCH] D114718: [analyzer] Implement a new checker for Strict Aliasing Rule.

2021-11-29 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision. ASDenysPetrov added reviewers: rsmith, martong, NoQ, vsavchenko, steakhal, aaron.ballman, xazax.hun, Szelethus. ASDenysPetrov added a project: clang. Herald added subscribers: manas, jeroen.dobbelaere, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs,

[PATCH] D114718: [analyzer] Implement a new checker for Strict Aliasing Rule.

2021-11-29 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @rsmith, @aaron.ballman I kindly invite you to join the review process especially in a part of the Standard interpretation. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114718/new/ https://reviews.llvm.org/D114718

[PATCH] D114718: [analyzer] Implement a new checker for Strict Aliasing Rule.

2021-11-30 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/StrictAliasingChecker.cpp:48-49 + // + // NOTE: User must provide canonical and unqualified QualType's for the + // correct result. + static bool canAccess(QualType From, QualType To, ASTContex

[PATCH] D114718: [analyzer] Implement a new checker for Strict Aliasing Rule.

2021-12-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @xazax.hun Updated the summary for better undersanding differencies between the Standards. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114718/new/ https://reviews.llvm.org/D114718

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

2021-12-03 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @martong > Nice, assiduous work! Many thanks for your time! Your work is not less assiduous! > (LHS, RHS) swaps it doesn't really matter, as the operation is comutative, but, yes, it does matter to depict the particular test case. I'll revise twise LHS-RHS's. >

[PATCH] D131707: [analyzer]{NFC} Cache the result of getLocationType in TypedValueRegion

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

[PATCH] D131707: [analyzer][NFC] Cache the result of getLocationType in TypedValueRegion

2022-08-15 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @steakhal Thank you for the review. Could you please do testing for me, since I'm on Windows and have no prepared testing environment as I know you are. I'll add an assertion. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.

[PATCH] D131707: [analyzer][NFC] Cache the result of getLocationType in TypedValueRegion

2022-08-15 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 452689. ASDenysPetrov added a comment. Add assertion accroding to the remark. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D131707/new/ https://reviews.llvm.org/D131707 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.

[PATCH] D131707: [analyzer][NFC] Cache the result of getLocationType in TypedValueRegion

2022-08-15 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. In D131707#3723403 , @ASDenysPetrov wrote: > @steakhal > Thank you for the review. > Could you please do testing for me, since I'm on Windows and have no prepared > testing environment as I know you do. > I'll add an asser

[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-09-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov reopened this revision. ASDenysPetrov added a comment. This revision is now accepted and ready to land. I've just investigated this patch deeply. I think we have wrong logic here. Assume we have `(int)(short)(int x)`. `VisitSymbolCast` will try to get the constant recursively in th

[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-09-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment. @martong wrote: I think you did get it. I'm not talking about range but about concrete int. And I see that the current behavior needs an improvement or rework. Consider next code, which I used in my example: 1. void test(int x) { 2. assert((short)x == 0); 3

<    1   2   3   4   5   6   7   >