History log of /llvm-project/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp (Results 1 – 25 of 26)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 655c2233 16-Jul-2024 martinboehme <mboehme@google.com>

[clang][dataflow] reland #96766 with fix (#98896)

- **Reapply "[clang][dataflow] Teach `AnalysisASTVisitor` that
`typeid()` can be evaluated." (#96766)**
- **Turn on RTTI explicitly in `checkDataflo

[clang][dataflow] reland #96766 with fix (#98896)

- **Reapply "[clang][dataflow] Teach `AnalysisASTVisitor` that
`typeid()` can be evaluated." (#96766)**
- **Turn on RTTI explicitly in `checkDataflowWithNoopAnalysis()`.**

show more ...


Revision tags: 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
# 2d539db2 08-Mar-2024 martinboehme <mboehme@google.com>

[clang][dataflow] When analyzing ctors, don't initialize fields of `*this` with values. (#84164)

This is the constructor's job, and we want to be able to test that it
does this.


Revision tags: 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
# f3dd8f10 23-Jan-2024 Yitzhak Mandelbaum <ymand@users.noreply.github.com>

[clang][dataflow] Make cap on block visits configurable by caller. (#77481)

Previously, we hard-coded the cap on block visits inside the framework.
This
patch enables the caller to specify the cap i

[clang][dataflow] Make cap on block visits configurable by caller. (#77481)

Previously, we hard-coded the cap on block visits inside the framework.
This
patch enables the caller to specify the cap in the APIs for running an
analysis.

show more ...


# 71f2ec2d 04-Dec-2023 martinboehme <mboehme@google.com>

[clang][dataflow] Add synthetic fields to `RecordStorageLocation` (#73860)

Synthetic fields are intended to model the internal state of a class
(e.g. the value stored in a `std::optional`) without

[clang][dataflow] Add synthetic fields to `RecordStorageLocation` (#73860)

Synthetic fields are intended to model the internal state of a class
(e.g. the value stored in a `std::optional`) without having to depend on
that class's implementation details.

Today, this is typically done with properties on `RecordValue`s, but
these have several drawbacks:

* Care must be taken to call `refreshRecordValue()` before modifying a
property so that the modified property values aren’t seen by other
environments that may have access to the same `RecordValue`.

* Properties aren’t associated with a storage location. If an analysis
needs to associate a location with the value stored in a property (e.g.
to model the reference returned by `std::optional::value()`), it needs
to manually add an indirection using a `PointerValue`. (See for example
the way this is done in UncheckedOptionalAccessModel.cpp, specifically
in `maybeInitializeOptionalValueMember()`.)

* Properties don’t participate in the builtin compare, join, and widen
operations. If an analysis needs to apply these operations to
properties, it needs to override the corresponding methods of
`ValueModel`.

* Longer-term, we plan to eliminate `RecordValue`, as by-value
operations on records aren’t really “a thing” in C++ (see
https://discourse.llvm.org/t/70086#changed-structvalue-api-14). This
would obviously eliminate the ability to set properties on
`RecordValue`s.

To demonstrate the advantages of synthetic fields, this patch converts
UncheckedOptionalAccessModel.cpp to synthetic fields. This greatly
simplifies the implementation of the check.

This PR is pretty big; to make it easier to review, I have broken it
down into a stack of three commits, each of which contains a set of
logically related changes. I considered submitting each of these as a
separate PR, but the commits only really make sense when taken together.

To review, I suggest first looking at the changes in
UncheckedOptionalAccessModel.cpp. This gives a flavor for how the
various API changes work together in the context of an analysis. Then,
review the rest of the changes.

show more ...


Revision tags: llvmorg-17.0.6, llvmorg-17.0.5
# bbd61d80 31-Oct-2023 martinboehme <mboehme@google.com>

[clang][dataflow][NFC] Move `parseAll()` to TestingSupport and rename `parseFormulas()` (#70437)

I'm working on a patch that will use this function from a different
test.


Revision tags: llvmorg-17.0.4, llvmorg-17.0.3
# 52d06963 11-Oct-2023 Stanislav Gatev <sgatev@google.com>

[clang][dataflow] Add support for lambda captures (#68558)

This adds support for copy, ref, and this lambda captures to the core
framework and also adds relevant tests in UncheckedOptionalAccessTes

[clang][dataflow] Add support for lambda captures (#68558)

This adds support for copy, ref, and this lambda captures to the core
framework and also adds relevant tests in UncheckedOptionalAccessTest.

show more ...


Revision tags: 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
# d0be47c5 04-Jul-2023 Martin Braenne <mboehme@google.com>

[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,

[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

show more ...


# d04b1989 28-Jun-2023 Martin Braenne <mboehme@google.com>

[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


Revision tags: 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
# c8b31da1 21-Jan-2023 Dmitri Gribenko <gribozavr@gmail.com>

[clang][dataflow] Allow analyzing multiple functions in unit tests

In unit tests for concrete dataflow analyses we typically use the
testonly `checkDataflow()` helper to analyse a free function call

[clang][dataflow] Allow analyzing multiple functions in unit tests

In unit tests for concrete dataflow analyses we typically use the
testonly `checkDataflow()` helper to analyse a free function called
"target". This pattern allows our tests to be uniform and focused on
specific statement- or expression-level C++ features.

As we expand our feature coverage, we want to analyze functions whose
names we don't fully control, like constructors, destructors, operators
etc. In such tests it is often convenient to analyze all functions
defined in the input code, to avoid having to carefully craft an AST
matcher that finds the exact function we're interested in. That can be
easily done by providing `checkDataflow()` with a catch-all matcher like
`functionDecl()`.

It is also often convenient to define multiple special member functions
in a single unit test, for example, multiple constructors, and share the
rest of the class definition code between constructors. As a result, it
makes sense to analyze multiple functions in one unit test.

This change allows `checkDataflow()` to correctly handle AST matchers
that match more than one function. Previously, it would only ever
analyze the first matched function, and silently ignore the rest. Now it
runs dataflow analysis in a loop, and calls `VerifyResults` for each
function that was found in the input and analyzed.

Reviewed By: ymandel, sgatev

Differential Revision: https://reviews.llvm.org/D140859

show more ...


# 3432f4bf 12-Jan-2023 Jordan Rupprecht <rupprecht@google.com>

[test] Split out Annotations from `TestingSupport`

The Annotations helper class does not have a gtest or gmock dependency, but because it's bundled with the rest of TestingSupport, it gets one. By s

[test] Split out Annotations from `TestingSupport`

The Annotations helper class does not have a gtest or gmock dependency, but because it's bundled with the rest of TestingSupport, it gets one. By splitting it out, a target can use it without being forced to use LLVM's copy of gtest.

Reviewed By: GMNGeoffrey, sammccall, gribozavr2

Differential Revision: https://reviews.llvm.org/D141175

show more ...


Revision tags: llvmorg-15.0.7
# 56743855 02-Jan-2023 Dmitri Gribenko <gribozavr@gmail.com>

[clang][dataflow] Remove unused includes


# a996cc21 05-Dec-2022 Fangrui Song <i@maskray.me>

Remove unused #include "llvm/ADT/Optional.h"


Revision tags: llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0
# 8dd14c42 01-Sep-2022 Wei Yi Tee <wyt@google.com>

[clang][dataflow] Use `StringMap` for storing analysis states at annotated points instead of `vector<pair<string, StateT>>`.

Reviewed By: gribozavr2, sgatev, ymandel

Differential Revision: https://

[clang][dataflow] Use `StringMap` for storing analysis states at annotated points instead of `vector<pair<string, StateT>>`.

Reviewed By: gribozavr2, sgatev, ymandel

Differential Revision: https://reviews.llvm.org/D132763

show more ...


# 5a4aece7 01-Sep-2022 Wei Yi Tee <wyt@google.com>

[clang][dataflow] Add `SetupTest` parameter for `AnalysisInputs`.

Moves the work required for retrieving annotation states into the `SetupTest` and `PostVisitCFG` callback to avoid having to run a s

[clang][dataflow] Add `SetupTest` parameter for `AnalysisInputs`.

Moves the work required for retrieving annotation states into the `SetupTest` and `PostVisitCFG` callback to avoid having to run a separate pass over the CFG after analysis has completed.

Reviewed By: gribozavr2, sgatev, ymandel

Differential Revision: https://reviews.llvm.org/D132377

show more ...


# db898d43 01-Sep-2022 Wei Yi Tee <wyt@google.com>

[clang][dataflow] Refactor `TestingSupport.h`

- Add `AnalysisInputs` struct as the parameters for `checkDataflow`, and renamed `AnalysisData` struct to `AnalysisOutputs` which contains the data stru

[clang][dataflow] Refactor `TestingSupport.h`

- Add `AnalysisInputs` struct as the parameters for `checkDataflow`, and renamed `AnalysisData` struct to `AnalysisOutputs` which contains the data structures generated from a dataflow analysis run.

- Remove compulsory binding from statement to annotations. Instead, `checkDataflow` in the most general form takes a `VerifyResults` callback which takes as input an `AnalysisOutputs` struct. This struct contains the data structures generated by the analysis that can then be tested. We then introduce two overloads/wrappers of `checkDataflow` for different mechanisms of testing - one which exposes annotation line numbers and is not restricted to statements, and the other which exposes states computed after annotated statements. In the future, we should look at retrieving the analysis states for constructs other than statements.

Reviewed By: gribozavr2, sgatev

Differential Revision: https://reviews.llvm.org/D132147

show more ...


Revision tags: llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init
# ca05cc20 27-Jun-2022 Kazu Hirata <kazu@google.com>

[clang] Don't use Optional::hasValue (NFC)

This patch replaces x.hasValue() with x where x is contextually
convertible to bool.


# 3b7c3a65 25-Jun-2022 Kazu Hirata <kazu@google.com>

Revert "Don't use Optional::hasValue (NFC)"

This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.


# aa8feeef 25-Jun-2022 Kazu Hirata <kazu@google.com>

Don't use Optional::hasValue (NFC)


Revision tags: llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3
# 3dd7877b 09-Mar-2022 Stanislav Gatev <sgatev@google.com>

Revert "[clang][dataflow] Move dataflow testing support out of unittests"

This reverts commit 26bbde2612b2042c3a8a31aed7f45e065c3dd413.


# e0cc28df 09-Mar-2022 Stanislav Gatev <sgatev@google.com>

Revert "[clang][dataflow] Add analysis that detects unsafe accesses to optionals"

This reverts commit ce205cffdfa0f16ce9441ba46fa43e23cecf8be7.


Revision tags: llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1, llvmorg-15-init
# d3597ec0 24-Jan-2022 Stanislav Gatev <sgatev@google.com>

[clang][dataflow] Enable merging distinct values in Environment::join

Make specializations of `DataflowAnalysis` extendable with domain-specific
logic for merging distinct values when joining enviro

[clang][dataflow] Enable merging distinct values in Environment::join

Make specializations of `DataflowAnalysis` extendable with domain-specific
logic for merging distinct values when joining environments. This could be
a strict lattice join or a more general widening operation.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: xazax.hun

Differential Revision: https://reviews.llvm.org/D118038

show more ...


Revision tags: llvmorg-13.0.1, llvmorg-13.0.1-rc3
# 875117ae 14-Jan-2022 Yitzhak Mandelbaum <yitzhakm@google.com>

[clang][dataflow] Remove TestingSupport's dependency on gtest

Users outside of the clang repo may use different googletest versions. So, it's
better not to depend on llvm's googletest. This patch re

[clang][dataflow] Remove TestingSupport's dependency on gtest

Users outside of the clang repo may use different googletest versions. So, it's
better not to depend on llvm's googletest. This patch removes the dependency by
having `checkDataflow` return an `llvm::Error` instead of calling googletest's
`FAIL` or `ASSERT...` macros.

Differential Revision: https://reviews.llvm.org/D117304

show more ...


Revision tags: llvmorg-13.0.1-rc2
# b5c5d891 20-Dec-2021 Stanislav Gatev <sgatev@google.com>

[clang][dataflow] Add support for noreturn destructor calls

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

[clang][dataflow] Add support for noreturn destructor calls

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed By: xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D116022

show more ...


# 93fbaa46 10-Dec-2021 Yitzhak Mandelbaum <yitzhakm@google.com>

Revert "Revert "[clang][dataflow] Add framework for testing analyses.""

This reverts commit 78ff12da1115abcaf4cbf50b605a197011505646 and fixes the initial cause of the revert.


Revision tags: llvmorg-13.0.1-rc1
# 5a40df63 16-Nov-2021 Yitzhak Mandelbaum <yitzhakm@google.com>

[clang][dataflow] Add framework for testing analyses.

Adds a general-purpose framework to support testing of dataflow analyses.

Differential Revision: https://reviews.llvm.org/D115341


12