[clang][dataflow] Relax validity assumptions in `UncheckedOptionalAccessModel`.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Thu, 26 Jan 2023 14:31:03 +0000 (14:31 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Wed, 1 Feb 2023 15:57:09 +0000 (15:57 +0000)
commitd4fb829b718059eb044843aea7b03d5b65556351
tree00487bd38104371ec72a5cdf9b5263ed56b3a949
parentb0c1a45ba5e5f9f04f5e208a6efb120dbb903758
[clang][dataflow] Relax validity assumptions in `UncheckedOptionalAccessModel`.

Currently, the interpretation of `swap` calls in the optional model assumes the
optional arguments are modeled (and therefore have valid storage locations and
values). This assumption is incorrect, for example, in the case of unmodeled
optional fields (which can be missing either value or location). This patch
relaxes these assumptions, to return rather than assert when either argument is
not modeled.

Differential Revision: https://reviews.llvm.org/D142710
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp