[clang][dataflow] Fix bug in optional-checker's handling of nullopt constructor.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Tue, 3 Jan 2023 20:50:01 +0000 (20:50 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Tue, 3 Jan 2023 21:57:39 +0000 (21:57 +0000)
commit0086a3555ac6cd76bb637252a0ba17c06c9b869b
tree0312dd84ea5254951a39ad32f929a930cedfc62c
parentd36936fdb462fdda29326a51c2193a3fd10d6807
[clang][dataflow] Fix bug in optional-checker's handling of nullopt constructor.

Currently, the checker only recognizes the nullopt constructor when it is called
without sugar, resulting in a crash in the (rare) case where it has been wrapped
in sugar. This relaxes the constraint by checking the constructor decl directly
(which always contains the same, desugared form) rather than the construct
expression (where the spelling depends on the context).

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