123 Commits

Author SHA1 Message Date
Paul Semel
bc37893433 [clang][dataflow] fix bug for transparent ListInitExpr handling
This fixes the handling of "transparent" ListInitExpr, when they're only
used as a copy constructor for records.

Without the fix, the two tests are crashing the process.
2023-07-26 08:50:28 +00:00
Martin Braenne
c3cf630d80 [clang][dataflow] Remove checks that test for consistency between StructValue and AggregateStorageLocation.
Now that the redundancy between these two classes has been eliminated, these
checks aren't needed any more.

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D155813
2023-07-24 13:20:04 +00:00
Martin Braenne
44f98d0101 [clang][dataflow] Eliminate duplication between AggregateStorageLocation and StructValue.
After this change, `StructValue` is just a wrapper for an `AggregateStorageLocation`. For the wider context, see https://discourse.llvm.org/t/70086.

## How to review

- Start by looking at the comments added / changed in Value.h, StorageLocation.h,
  and DataflowEnvironment.h. This will give you a good overview of the semantic
  changes.

- Look at the corresponding .cpp files that implement the semantic changes.

- Transfer.cpp, TypeErasedDataflowAnalysis.cpp, and RecordOps.cpp show how the
  core of the framework is affected by the semantic changes.

- UncheckedOptionalAccessModel.cpp shows how this complex model is affected by
  the changes.

- Many of the changes in the rest of the patch are mechanical in nature.

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D155446
2023-07-24 13:20:01 +00:00
Martin Braenne
6236bf5341 [clang][dataflow] Strengthen flow condition assertions.
Instead of asserting merely that the flow condition doesn't imply that a variable is true, make the stronger assertion that the flow condition implies that the variable is false.

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D155067
2023-07-18 13:41:43 +00:00
Martin Braenne
4782597e3c [clang][dataflow] Add a test for not explicitly initialized fields in aggregate initialization.
Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D155074
2023-07-17 07:26:08 +00:00
Sam McCall
6272226b9f [dataflow] Remove deprecated BoolValue flow condition accessors
Use the Formula versions instead, now.

Differential Revision: https://reviews.llvm.org/D155152
2023-07-13 09:39:23 +02:00
Martin Braenne
bd9b57de4f [clang][dataflow] Fix initializing a reference field with an InitListExpr.
I added a test for this as the ongoing migration to strict handling of value categories (see https://discourse.llvm.org/t/70086) will change the code that handles this case. It turns out we already didn't handle this correctly, so I fixed the existing implementation.

Depends On D154961

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D154965
2023-07-12 04:52:30 +00:00
Martin Braenne
b47bdcbc72 [clang][dataflow] Include fields initialized in an InitListExpr in getModeledFields().
Previously, we were including these fields only in the specific instance that was initialized by the `InitListExpr`, but not in other instances of the same type. This is inconsistent and error-prone.

Depends On D154952

Reviewed By: xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D154961
2023-07-12 04:52:29 +00:00
Martin Braenne
103a0fc084 [clang][dataflow] Use getFieldValue() in TransferTest.cpp.
For context, see https://reviews.llvm.org/D154935.

Depends On D154935

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D154949
2023-07-12 04:52:25 +00:00
Sam McCall
fc9821a877 Reland "[dataflow] Add dedicated representation of boolean formulas"
This reverts commit 7a72ce98224be76d9328e65eee472381f7c8e7fe.

Test problems were due to unspecified order of function arg evaluation.

Reland "[dataflow] Replace most BoolValue subclasses with references to Formula (and AtomicBoolValue => Atom and BoolValue => Formula where appropriate)"

This properly frees the Value hierarchy from managing boolean formulas.

We still distinguish AtomicBoolValue; this type is used in client code.
However we expect to convert such uses to BoolValue (where the
distinction is not needed) or Atom (where atomic identity is intended),
and then fold AtomicBoolValue into FormulaBoolValue.

We also distinguish TopBoolValue; this has distinct rules for
widen/join/equivalence, and top-ness is not represented in Formula.
It'd be nice to find a cleaner representation (e.g. the absence of a
formula), but no immediate plans.

For now, BoolValues with the same Formula are deduplicated. This doesn't
seem desirable, as Values are mutable by their creators (properties).
We can probably drop this for FormulaBoolValue immediately (not in this
patch, to isolate changes). For AtomicBoolValue we first need to update
clients to stop using value pointers for atom identity.

The data structures around flow conditions are updated:
- flow condition tokens are Atom, rather than AtomicBoolValue*
- conditions are Formula, rather than BoolValue
Most APIs were changed directly, some with many clients had a
new version added and the existing one deprecated.

The factories for BoolValues in Environment keep their existing
signatures for now (e.g. makeOr(BoolValue, BoolValue) => BoolValue)
and are not deprecated. These have very many clients and finding the
most ergonomic API & migration path still needs some thought.

Differential Revision: https://reviews.llvm.org/D153469
2023-07-07 11:58:33 +02:00
Martin Braenne
ca01be54c1 [clang][dataflow] Bug fix: BuiltinFnToFnPtr cast does not produce a pointer.
See comments in the code for details.

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D154479
2023-07-06 06:56:02 +00:00
Sam McCall
2d8cd19512 Revert "Reland "[dataflow] Add dedicated representation of boolean formulas" and followups
These changes are OK, but they break downstream stuff that needs more time to adapt :-(

This reverts commit 71579569f4399d3cf6bc618dcd449b5388d749cc.
This reverts commit 5e4ad816bf100b0325ed45ab1cfea18deb3ab3d1.
This reverts commit 1c3ac8dfa16c42a631968aadd0396cfe7f7778e0.
2023-07-05 14:32:25 +02:00
Sam McCall
71579569f4 [dataflow] use true/false literals in formulas, rather than variables
And simplify formulas containing true/false
It's unclear to me how useful this is, it does make formulas more
conveniently self-contained now (we can usefully print them without
carrying around the "true/false" labels)

(while here, simplify !!X to X, too)

Differential Revision: https://reviews.llvm.org/D153485
2023-07-05 14:06:48 +02:00
Sam McCall
5e4ad816bf [dataflow] Replace most BoolValue subclasses with references to Formula (and AtomicBoolValue => Atom and BoolValue => Formula where appropriate)
This properly frees the Value hierarchy from managing boolean formulas.

We still distinguish AtomicBoolValue; this type is used in client code.
However we expect to convert such uses to BoolValue (where the
distinction is not needed) or Atom (where atomic identity is intended),
and then fold AtomicBoolValue into FormulaBoolValue.

We also distinguish TopBoolValue; this has distinct rules for
widen/join/equivalence, and top-ness is not represented in Formula.
It'd be nice to find a cleaner representation (e.g. the absence of a
formula), but no immediate plans.

For now, BoolValues with the same Formula are deduplicated. This doesn't
seem desirable, as Values are mutable by their creators (properties).
We can probably drop this for FormulaBoolValue immediately (not in this
patch, to isolate changes). For AtomicBoolValue we first need to update
clients to stop using value pointers for atom identity.

The data structures around flow conditions are updated:
- flow condition tokens are Atom, rather than AtomicBoolValue*
- conditions are Formula, rather than BoolValue
Most APIs were changed directly, some with many clients had a
new version added and the existing one deprecated.

The factories for BoolValues in Environment keep their existing
signatures for now (e.g. makeOr(BoolValue, BoolValue) => BoolValue)
and are not deprecated. These have very many clients and finding the
most ergonomic API & migration path still needs some thought.

Differential Revision: https://reviews.llvm.org/D153469
2023-07-05 13:54:32 +02:00
Martin Braenne
d0be47c51c [clang][dataflow] Make runDataflowReturnError() a non-template function.
It turns out this didn't need to be a template at all.

Likewise, change callers to they're non-template functions.

Also, correct / clarify some comments in RecordOps.h.

This is in response to post-commit comments on https://reviews.llvm.org/D153006.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D154339
2023-07-04 12:44:49 +00:00
Martin Braenne
880f306226 [clang][dataflow] Add a test for a struct that is directly self-referential through a reference.
The ongoing migration to strict handling of value
categories (see https://discourse.llvm.org/t/70086) will change the way we
handle fields of reference type, and I want to put a test in place that makes
sure we continue to handle this special case correctly.

Depends On D154420

Reviewed By: gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D154421
2023-07-04 12:06:13 +00:00
Martin Braenne
1e7329cd79 [clang][dataflow] Model variables / fields / funcs used in default initializers.
The newly added test fails without the other changes in this patch.

Reviewed By: sammccall, gribozavr2

Differential Revision: https://reviews.llvm.org/D154420
2023-07-04 12:06:10 +00:00
Martin Braenne
1d7f9ce61f [clang][dataflow] Don't crash when creating pointers to members.
The newly added tests crash without the other changes in this patch.

Reviewed By: sammccall, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D153960
2023-06-29 07:12:55 +00:00
Martin Braenne
74d8455ba6 [clang][dataflow] Make getThisPointeeStorageLocation() return an AggregateStorageLocation.
This avoids the need for casts at callsites.

Depends On D153852

Reviewed By: sammccall, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D153854
2023-06-29 04:07:08 +00:00
Martin Braenne
d36324866e [clang][dataflow] Initialize fields of anonymous records correctly.
Previously, the newly added test would crash.

Depends On D153851

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D153852
2023-06-29 04:07:04 +00:00
Martin Braenne
abc8367413 [clang][dataflow] Don't crash if copy constructor arg doesn't have a storage location.
I accidentally used `cast` instead of `cast_or_null`.

Reviewed By: sammccall, xazax.hun

Differential Revision: https://reviews.llvm.org/D153956
2023-06-28 11:15:52 +00:00
Martin Braenne
d04b198973 [clang][dataflow] Add a test that we can access fields of anonymous records.
Reviewed By: sammccall, ymandel, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D153409
2023-06-28 09:12:03 +00:00
Martin Braenne
f2123af1e7 [clang][dataflow] Perform deep copies in copy and move operations.
This serves two purposes:

- Because, today, we only copy the `StructValue`, modifying the destination of
  the copy also modifies the source. This is demonstrated by the new checks
  added to `CopyConstructor` and `MoveConstructor`, which fail without the
  deep copy.

- It lays the groundwork for eliminating the redundancy between
  `AggregateStorageLocation` and `StructValue`, which will happen as part of the
  ongoing migration to strict handling of value categories (seeo
  https://discourse.llvm.org/t/70086 for details). This will involve turning
  `StructValue` into essentially just a wrapper for `AggregateStorageLocation`;
  under this scheme, the current "shallow" copy (copying a `StructValue` from
  one `AggregateStorageLocation` to another) will no longer be possible.

Because we now perform deep copies, tests need to perform a deep equality
comparison instead of just comparing for equal identity of the `StructValue`s.
The new function `recordsEqual()` provides such a deep equality comparison.

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D153006
2023-06-26 13:52:56 +00:00
Martin Braenne
762cb1d377 [clang][dataflow] Create Values for integer literals.
This patch includes a test that fails without the fix.

I discovered that we weren't creating `Value`s for integer literals when, in a
different patch, I tried to overwrite the value of a struct field with a literal
for the purposes of a test and was surprised to find that the struct compared
the same before and after the assignment.

This functionality therefore seems useful at least for tests, but is probably
also useful for actual analysis of code.

Reviewed By: ymandel, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D152813
2023-06-19 08:37:41 +00:00
Martin Braenne
3f31d3204b [clang][dataflow] Model pointer value for builtin functions.
This fixes a false positive in the Crubit nullability verification.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D152683
2023-06-12 12:23:18 +00:00
Martin Braenne
7f6c3a9033 [clang][dataflow] Fix a crash in getLogicOperatorSubExprValue().
This patch adds a test that crashes without the fix.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D151201
2023-05-25 14:47:03 +00:00
Martin Braenne
64413584da [clang][dataflow] Add support for return values of reference type.
This patch changes the way `Environment::ReturnLoc` is set: Whereas previously it was set by the caller, it is now set by the callee (obviously, as we otherwise would not be able to return references).

The patch also introduces `Environment::ReturnVal`, which is used for non-reference-type return values. This allows these to be handled with the correct value category semantics; see also https://discourse.llvm.org/t/70086, which describes the ongoing migration to strict value category semantics.

Depends On D150776

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D151194
2023-05-25 08:38:33 +00:00
Martin Braenne
1a42f79558 [clang][dataflow] Don't analyze templated declarations.
Attempting to analyze templated code doesn't have a good cost-benefit ratio. We
have so far done a best-effort attempt at this, but maintaining this support has
an ongoing high maintenance cost because the AST for templates can violate a lot
of the invariants that otherwise hold for the AST of concrete code. As just one
example, in concrete code the operand of a UnaryOperator '*' is always a prvalue
(https://godbolt.org/z/s3e5xxMd1), but in templates this isn't true
(https://godbolt.org/z/6W9xxGvoM).

Further rationale for not analyzing templates:

* The semantics of a template itself are weakly defined; semantics can depend
  strongly on the concrete template arguments. Analyzing the template itself (as
  opposed to an instantiation) therefore has limited value.

* Analyzing templates requires a lot of special-case code that isn't necessary
  for concrete code because dependent types are hard to deal with and the AST
  violates invariants that otherwise hold for concrete code (see above).

* There's precedent in that neither Clang Static Analyzer nor the flow-sensitive
  warnings in Clang (such as uninitialized variables) support analyzing
  templates.

Reviewed By: gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D150352
2023-05-15 11:04:51 +00:00
Martin Braenne
0c852dc88e [clang][dataflow][NFC] Remove SkipPast param from getValue(const ValueDecl &).
This parameter was already a no-op, so removing it doesn't change behavior.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D150137
2023-05-09 07:42:20 +00:00
Martin Braenne
9940fac753 [clang][dataflow][NFC] Remove SkipPast parameter from `getStorageLocation(const ValueDecl &).
This parameter was already a no-op, so removing it doesn't change behavior.

Depends On D149144

Reviewed By: ymandel, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D149151
2023-05-08 07:10:44 +00:00
Martin Braenne
bfbe137888 [clang][dataflow] Eliminate intermediate ReferenceValues from Environment::DeclToLoc.
For the wider context of this change, see the RFC at
https://discourse.llvm.org/t/70086.

After this change, global and local variables of reference type are associated
directly with the `StorageLocation` of the referenced object instead of the
`StorageLocation` of a `ReferenceValue`.

Some tests that explicitly check for an existence of `ReferenceValue` for a
variable of reference type have been modified accordingly.

As discussed in the RFC, I have added an assertion to `Environment::join()` to
check that if both environments contain an entry for the same declaration in
`DeclToLoc`, they both map to the same `StorageLocation`. As discussed in
https://discourse.llvm.org/t/70086/5, this also necessitates removing
declarations from `DeclToLoc` when they go out of scope.

In the RFC, I proposed a gradual migration for this change, but it appears
that all of the callers of `Environment::setStorageLocation(const ValueDecl &,
SkipPast` are in the dataflow framework itself, and that there are only a few of
them.

As this is the function whose semantics are changing in a way that callers
potentially need to adapt to, I've decided to change the semantics of the
function directly.

The semantics of `getStorageLocation(const ValueDecl &, SkipPast SP` now no
longer depend on the behavior of the `SP` parameter. (There don't appear to be
any callers that use `SkipPast::ReferenceThenPointer`, so I've added an
assertion that forbids this usage.)

This patch adds a default argument for the `SP` parameter and removes the
explicit `SP` argument at the callsites that are touched by this change. A
followup patch will remove the argument from the remaining callsites,
allowing the `SkipPast` parameter to be removed entirely. (I don't want to do
that in this patch so that semantics-changing changes can be reviewed separately
from semantics-neutral changes.)

Reviewed By: ymandel, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D149144
2023-05-04 20:57:30 +00:00
Kinuko Yasuda
791b0fd026 [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG
Keeping this false could end up with extra iterations on a lot of loops
that aren't real ones (e.g. they could be a do-while-false for macros),
and makes the analyses very slow.

This patch changes the default for
CFG::BuildOptions.PruneTriviallyFalseEdges to true to avoid it.

Reviewed By: ymandel, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D149640
2023-05-03 18:42:15 +00:00
Samira Bazuzi
2cdb6b84c1 [clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.
This will eliminate the need for more pass-through APIs. Also replace pass-through usages with this exposure.

Reviewed By: ymandel, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D149464
2023-05-02 11:32:19 +00:00
Martin Braenne
d9e717338f [clang][dataflow] Associate FunctionToPointerDecay nodes with a value.
To ensure that we have a pointee for the `PointerValue`, we also create
storage locations for `FunctionDecl`s referenced in the function under analysis.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D148006
2023-04-18 07:15:29 +00:00
Martin Braenne
6ab900f874 [clang][dataflow] Add support for new expressions.
Reviewed By: xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D147698
2023-04-18 04:11:43 +00:00
Martin Braenne
5acd29eb4d [clang][dataflow] Fix crash when RHS of && or || calls noreturn func.
The crash happened because the transfer fucntion for `&&` and `||`
unconditionally tried to retrieve the value of the RHS. However, if the RHS
is unreachable, there is no environment for it, and trying to retrieve the
operand's value causes an assertion failure.

See also the comments in the code for further details.

Reviewed By: xazax.hun, ymandel, sgatev, gribozavr2

Differential Revision: https://reviews.llvm.org/D146514
2023-03-23 08:02:43 +00:00
Paul Semel
96d035c1dc [clang][dataflow] unnamed bitfields should be discarded in InitListExpr
Differential Revision: https://reviews.llvm.org/D144892
2023-02-28 15:43:28 +00:00
Paul Semel
e6e753d173 [clang][dataflow] Fix wrong assert for CXXConstructExpr
Differential Revision: https://reviews.llvm.org/D144546
2023-02-24 09:51:10 +00:00
Yitzhak Mandelbaum
02562804d0 [clang][dataflow] Fix handling of DeclRefExprs to BindingDecls.
The invariants around `ReferenceValues` are subtle (arguably, too much so). That
includes that we need to take care not to double wrap them -- in cases where we
wrap a loc in an `ReferenceValue` we need to be sure that the pointee isn't
already a `ReferenceValue`.  `BindingDecl` introduces another situation in which
this can arise. Previously, the code did not properly handle `BindingDecl`,
resulting in double-wrapped values, which broke other invariants (at least, that
struct values have an `AggregateStorageLocation`).

This patch adjusts the interpretation of `DeclRefExpr` to take `BindingDecl`'s
peculiarities into account. It also fixes the two tests which should have caught
this issue but were themselves (subtly) buggy.

Differential Revision: https://reviews.llvm.org/D140897
2023-02-01 13:23:23 +00:00
Yitzhak Mandelbaum
b84ac96a35 [clang][dataflow] Fix bug in handling of reference-typed fields.
This patch fixes a subtle bug in how we create lvalues to reference-typed
fields. In the rare case that the field is umodeled because of the depth limit
on field modeling, the lvalue created can be malformed. This patch prevents that
and adds some related assertions to other code dealing with lvalues for
references.

Differential Revision: https://reviews.llvm.org/D142468
2023-01-24 16:10:50 +00:00
Kazu Hirata
6ad0788c33 [clang] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<.  I'll post
a separate patch to remove #include "llvm/ADT/Optional.h".

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14 12:31:01 -08:00
Kazu Hirata
a1580d7b59 [clang] Add #include <optional> (NFC)
This patch adds #include <optional> to those files containing
llvm::Optional<...> or Optional<...>.

I'll post a separate patch to actually replace llvm::Optional with
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14 11:07:21 -08:00
Yitzhak Mandelbaum
3ce03c42db [clang][dataflow] Fix 2 bugs in MemberExpr interpretation.
There were two (small) bugs causing crashes in the analysis.  This patch fixes both of them.

1. An enum value was accessed as a class member. Now, the engine gracefully
ignores such member expressions.

2. Field access in `MemberExpr` of struct/class-typed global variables. Analysis
didn't interpret fields of global vars, because the vars were initialized before
the fields were added to the "allowlist". Now, the allowlist is set _before_
init of globals.

Differential Revision: https://reviews.llvm.org/D141384
2023-01-10 15:48:00 +00:00
Yitzhak Mandelbaum
264976d98e [clang][dataflow] Unify TransferOptions and DataflowAnalysisContext::Options.
Merges `TransferOptions` into the newly-introduced
`DataflowAnalysisContext::Options` and removes explicit parameter for
`TransferOptions`, relying instead on the common options carried by the analysis
context. Given that there was no intent to allow different options between calls
to `transfer`, a common value for the options is preferable.

Differential Revision: https://reviews.llvm.org/D140703
2023-01-10 14:17:25 +00:00
Yitzhak Mandelbaum
01ccf7b3ce Revert "Revert "[clang][dataflow] Only model struct fields that are used in the function being analyzed.""
This reverts commit 2b1a517a92bfdfa3b692a660e19a2bb22513a567. It's a fix forward
with two memory errors fixed, one of which was the cause of the build breakage
in the buildbots.

Original message:

Previously, the model for structs modeled all fields in a struct when
`createValue` was called for that type. This patch adds a prepass on the
function under analysis to discover the fields referenced in the scope and then
limits modeling to only those fields. This reduces wasted memory usage
(modeling unused fields) which can be important for programs that use large
structs.

Note: This patch obviates the need for https://reviews.llvm.org/D123032.
2023-01-09 19:32:10 +00:00
Yitzhak Mandelbaum
2b1a517a92 Revert "[clang][dataflow] Only model struct fields that are used in the function being analyzed."
This reverts commit 5e8f597c2fedc740b71f07dfdb1ef3c2d348b193. It caused msan and ubsan breakages.
2023-01-06 01:07:28 +00:00
Yitzhak Mandelbaum
5e8f597c2f [clang][dataflow] Only model struct fields that are used in the function being analyzed.
Previously, the model for structs modeled all fields in a struct when
`createValue` was called for that type. This patch adds a prepass on the
function under analysis to discover the fields referenced in the scope and then
limits modeling to only those fields.  This reduces wasted memory usage
(modeling unused fields) which can be important for programss that use large
structs.

Note: This patch obviates the need for https://reviews.llvm.org/D123032.

Differential Revision: https://reviews.llvm.org/D140694
2023-01-05 21:46:39 +00:00
Dani Ferreira Franco Moura
d862f66221 [clang][dataflow] Treat unions as structs.
This is a straightfoward way to handle unions in dataflow analysis. Without this change, nullability verification crashes on files that contain unions.

Reviewed By: gribozavr2, ymandel

Differential Revision: https://reviews.llvm.org/D140696
2023-01-03 18:36:24 +00:00
Yitzhak Mandelbaum
38404df9d8 [clang][dataflow] Fix bug in handling of return statements.
The handling of return statements, added in support of context-sensitive
analysis, has a bug relating to functions that return reference
types. Specifically, interpretation of such functions can result in a crash from
a bad cast. This patch fixes the bug and guards all of that code with the
context-sensitive option, since there's no reason to execute at all when
context-sensitive analysis is off.

Differential Revision: https://reviews.llvm.org/D140430
2022-12-22 14:42:17 +00:00
Yitzhak Mandelbaum
ef4635452f [clang][dataflow] Add support for structured bindings of tuple-like types.
This patch adds interpretation of binding declarations resulting from a
structured binding (`DecompositionDecl`) to a tuple-like type. Currently, the
framework only supports binding to a struct.

Fixes issue #57252.

Differential Revision: https://reviews.llvm.org/D139544
2022-12-09 18:58:00 +00:00