summaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/FlowSensitive/Models/UncheckedStatusOrAccessModel.cpp
AgeCommit message (Collapse)Author
2025-10-27[FlowSensitive] [StatusOr] [9/N] Make sure all StatusOr are initializedFlorian Mayer
This is important if the first use of a StatusOr (or Status) is in a conditional statement, we need a stable value for `ok` from outside of the conditional statement to make sure we don't use a different variable in every branch. Reviewers: jvoung, Xazax-hun Reviewed By: jvoung Pull Request: https://github.com/llvm/llvm-project/pull/163898
2025-10-27[FlowSensitive] [StatusOr] [8/N] Support value ctor and assignmentFlorian Mayer
Reviewers: jvoung, Xazax-hun Reviewed By: jvoung Pull Request: https://github.com/llvm/llvm-project/pull/163894
2025-10-23[FlowSensitive] [StatusOr] [7/N] Support StatusOr::emplaceFlorian Mayer
This always makes the StatusOr OK. Reviewers: jvoung, Xazax-hun Reviewed By: jvoung Pull Request: https://github.com/llvm/llvm-project/pull/163876
2025-10-23[FlowSensitive] [StatusOr] [6/N] support pointer comparison (#164856)Florian Mayer
2025-10-22[FlowSensitive] [StatusOr] [5/N] Support absl::OkStatus et al (#163872)Florian Mayer
This allows comparison which these status codes
2025-10-22[FlowSensitive] [StatusOr] [4/N] Support comparisons (#163871)Florian Mayer
2025-10-21[FlowSensitive] [StatusOr] [3/N] Support absl::Status ops (#163868)Florian Mayer
`absl::StatusOr::status` allows extraction of the status associated with a StatusOr value. That can also be used to check whether the StatusOr has a value or not. This makes sure code like this is checked properly: ```cpp int target(absl::StatusOr<int> SOR) { if (SOR.status().ok()) return *SOR; return 0; } ```
2025-10-21[NFC] [FlowSensitive] [StatusOr] remove unused function (#164351)Florian Mayer
2025-10-20Reapply "[FlowSensitive] [StatusOr] [2/N] Add minimal model" (#164040) (#164305)Florian Mayer
This reverts commit eed8d3aa4aa6efe01fcf7bd56015b671f5f18e29.
2025-10-18Revert "[FlowSensitive] [StatusOr] [2/N] Add minimal model" (#164040)Florian Mayer
Reverts llvm/llvm-project#162932 Failed Tests (1): Clang-Unit :: ./AllClangUnitTests/failed_to_discover_tests_from_gtest
2025-10-17[FlowSensitive] [StatusOr] [2/N] Add minimal model (#162932)Florian Mayer
This model implements a dataflow analysis for reporting instances of unchecked use of absl::StatusOr values. It makes sure that every use the value of a StatusOr object is dominated by a check that the StatusOr object is ok. This is an example of code that will be flagged by the analysis: ```cpp int f(absl::StatusOr<int> SOR) { return SOR.value(); } ``` This is an example of code that will not be flagged by the analysis: ```cpp int f(absl::StatusOr<int> SOR) { if (SOR.ok()) return SOR.value(); return 0; } ``` This model has successfully been used by Google for some time now. This is the initial commit that adds the simplest possible model, that only models calls to `ok()` and checks for unsafe accesses. I will add more fidelity to the model in follow up changes. The test setup is notable in that it has an extra indirection. This is because we have an internal model that extends the model we intend to upstream, in order to model special constructs only found in our code base. The parametrized test allows us (and anyone who chooses to do this) to make sure our extensions do not break the base functionality. RFC: https://discourse.llvm.org/t/rfc-abseil-unchecked-statusor-use-check/87998