|
Revision tags: llvmorg-20.1.0, llvmorg-20.1.0-rc3, llvmorg-20.1.0-rc2, llvmorg-20.1.0-rc1, llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init |
|
| #
58fe7f96 |
| 29-Jun-2022 |
Sam Estep <[email protected]> |
[clang][dataflow] Add API to separate analysis from diagnosis
This patch adds an optional `PostVisitStmt` parameter to the `runTypeErasedDataflowAnalysis` function, which does one more pass over all
[clang][dataflow] Add API to separate analysis from diagnosis
This patch adds an optional `PostVisitStmt` parameter to the `runTypeErasedDataflowAnalysis` function, which does one more pass over all statements in the CFG after a fixpoint is reached. It then defines a `diagnose` method for the optional model in a new `UncheckedOptionalAccessDiagnosis` class, but only integrates that into the tests and not the actual optional check for `clang-tidy`. That will be done in a followup patch.
The primary motivation is to separate the implementation of the unchecked optional access check into two parts, to allow for further refactoring of just the model part later, while leaving the checking part alone. Currently there is duplication between the `transferUnwrapCall` and `diagnoseUnwrapCall` functions, but that will be dealt with in the followup.
Because diagnostics are now all gathered into one collection rather than being populated at each program point like when computing a fixpoint, this patch removes the usage of `Pair` and `UnorderedElementsAre` from the optional model tests, and instead modifies all their expectations to simply check the stringified set of diagnostics against a single string, either `"safe"` or some concatenation of `"unsafe: input.cc:y:x"`. This is not ideal as it loses any connection to the `/*[[check]]*/` annotations in the source strings, but it does still retain the source locations from the diagnostic strings themselves.
Reviewed By: sgatev, gribozavr2, xazax.hun
Differential Revision: https://reviews.llvm.org/D127898
show more ...
|
|
Revision tags: llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4 |
|
| #
8fcdd625 |
| 18-May-2022 |
Stanislav Gatev <[email protected]> |
[clang][dataflow] Add support for correlated branches to optional model
Add support for correlated branches to the std::optional dataflow model.
Differential Revision: https://reviews.llvm.org/D125
[clang][dataflow] Add support for correlated branches to optional model
Add support for correlated branches to the std::optional dataflow model.
Differential Revision: https://reviews.llvm.org/D125931
Reviewed-by: ymandel, xazax.hun
show more ...
|
| #
cd0d5261 |
| 10-Jun-2022 |
Sam Estep <[email protected]> |
[clang][dataflow] In `optional` model, match call return via hasType
Currently the unchecked-optional-access model fails on this example:
#include <memory> #include <optional>
void foo
[clang][dataflow] In `optional` model, match call return via hasType
Currently the unchecked-optional-access model fails on this example:
#include <memory> #include <optional>
void foo() { std::unique_ptr<std::optional<float>> x; *x = std::nullopt; }
You can verify the failure by saving the file as `foo.cpp` and running this command:
clang-tidy -checks='-*,bugprone-unchecked-optional-access' foo.cpp -- -std=c++17
The failing `assert` is in the `transferAssignment` function of the `UncheckedOptionalAccessModel.cpp` file:
assert(OptionalLoc != nullptr);
The symptom can be treated by replacing that `assert` with an early `return`:
if (OptionalLoc == nullptr) return;
That would be better anyway since we cannot expect to always cover all possible LHS expressions, but it is out of scope for this patch and left as a followup.
Note that the failure did not occur on this very similar example:
#include <optional>
template <typename T> struct smart_ptr { T& operator*() &; T* operator->(); };
void foo() { smart_ptr<std::optional<float>> x; *x = std::nullopt; }
The difference is caused by the `isCallReturningOptional` matcher, which was previously checking the `functionDecl` of the `callee`. This patch changes it to instead use `hasType` directly on the call expression, fixing the failure for the `std::unique_ptr` example above.
Reviewed By: sgatev
Differential Revision: https://reviews.llvm.org/D127434
show more ...
|
| #
dd38caf3 |
| 03-May-2022 |
Yitzhak Mandelbaum <[email protected]> |
[clang][dataflow] Track `optional` contents in `optional` model.
This patch adds partial support for tracking (i.e. modeling) the contents of an optional value. Specifically, it supports tracking th
[clang][dataflow] Track `optional` contents in `optional` model.
This patch adds partial support for tracking (i.e. modeling) the contents of an optional value. Specifically, it supports tracking the value after it is accessed. We leave tracking constructed/assigned contents to a future patch.
Differential Revision: https://reviews.llvm.org/D124932
show more ...
|
| #
6adfc64e |
| 03-Jun-2022 |
Yitzhak Mandelbaum <[email protected]> |
[clang][dataflow] Modify `optional` model to handle type aliases.
Previously, type aliases were not handled (and resulted in an assertion firing). This patch generalizes the model to consider aliase
[clang][dataflow] Modify `optional` model to handle type aliases.
Previously, type aliases were not handled (and resulted in an assertion firing). This patch generalizes the model to consider aliases everywhere (a previous patch already considered aliases for optional-returning functions).
Differential Revision: https://reviews.llvm.org/D126972
show more ...
|
| #
65e710c3 |
| 01-Jun-2022 |
Stanislav Gatev <[email protected]> |
[clang][dataflow] Model calls returning optionals
Model calls returning optionals
Differential Revision: https://reviews.llvm.org/D126759
Reviewed-by: ymandel, xazax.hun
|
|
Revision tags: llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1 |
|
| #
7f076004 |
| 21-Mar-2022 |
Yitzhak Mandelbaum <[email protected]> |
[clang][dataflow] Add support for `value_or` in a comparison.
This patch adds limited modeling of the `value_or` method. Specifically, when used in a particular idiom in a comparison to implicitly c
[clang][dataflow] Add support for `value_or` in a comparison.
This patch adds limited modeling of the `value_or` method. Specifically, when used in a particular idiom in a comparison to implicitly check whether the optional holds a value.
Differential Revision: https://reviews.llvm.org/D122231
show more ...
|
| #
a184a0d8 |
| 21-Mar-2022 |
Yitzhak Mandelbaum <[email protected]> |
[clang][dataflow] Add support for disabling warnings on smart pointers.
This patch provides the user with the ability to disable all checked of accesses to optionals that are the pointees of smart p
[clang][dataflow] Add support for disabling warnings on smart pointers.
This patch provides the user with the ability to disable all checked of accesses to optionals that are the pointees of smart pointers. Since smart pointers are not modeled (yet), the system cannot distinguish safe from unsafe accesses to optionals through smart pointers. This results in false positives whenever optionals are used through smart pointers. The patch gives the user the choice of ignoring all positivess in these cases.
Differential Revision: https://reviews.llvm.org/D122143
show more ...
|
| #
2ddd57ae |
| 21-Mar-2022 |
Stanislav Gatev <[email protected]> |
[clang][dataflow] Model the behavior of optional and std swap
Differential Revision: https://reviews.llvm.org/D122129
Reviewed-by: ymandel, xazax.hun
|
| #
b000b770 |
| 16-Mar-2022 |
Stanislav Gatev <[email protected]> |
[clang][dataflow] Model the behavior of non-standard optional assignment
Model nullopt, value, and conversion assignment operators.
Reviewed-by: xazax.hun
Differential Revision: https://reviews.ll
[clang][dataflow] Model the behavior of non-standard optional assignment
Model nullopt, value, and conversion assignment operators.
Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D121863
show more ...
|
| #
092a530c |
| 14-Mar-2022 |
Stanislav Gatev <[email protected]> |
[clang][dataflow] Model the behavior of non-standard optional constructors
Model nullopt, inplace, value, and conversion constructors.
Reviewed-by: ymandel, xazax.hun, gribozavr2
Differential Revi
[clang][dataflow] Model the behavior of non-standard optional constructors
Model nullopt, inplace, value, and conversion constructors.
Reviewed-by: ymandel, xazax.hun, gribozavr2
Differential Revision: https://reviews.llvm.org/D121602
show more ...
|
|
Revision tags: llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3 |
|
| #
9e0fc676 |
| 10-Mar-2022 |
Stanislav Gatev <[email protected]> |
[clang][dataflow] Model the behavior of various optional members
Model `make_optional`, optional's default constructor, `emplace`, `reset`, and `operator bool` members.
Reviewed-by: xazax.hun
Diff
[clang][dataflow] Model the behavior of various optional members
Model `make_optional`, optional's default constructor, `emplace`, `reset`, and `operator bool` members.
Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D121378
show more ...
|
| #
af98b0af |
| 10-Mar-2022 |
Stanislav Gatev <[email protected]> |
[clang][dataflow] Add analysis that detects unsafe accesses to optionals
This commit reverts e0cc28dfdc67105974924cce42bb8c85bd44925a and moves UncheckedOptionalAccessModelTest.cpp into clang/unitte
[clang][dataflow] Add analysis that detects unsafe accesses to optionals
This commit reverts e0cc28dfdc67105974924cce42bb8c85bd44925a and moves UncheckedOptionalAccessModelTest.cpp into clang/unittests/Analysis/FlowSensitive, to avoid build failures. The test will be moved back into a Models subdir in a follow up patch that will address the build configuration issues.
Original description:
Adds a dataflow analysis that detects unsafe accesses to values of type `std::optional`, `absl::optional`, or `base::Optional`.
Reviewed-by: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D121197
show more ...
|