[all-commits] [llvm/llvm-project] 2ee396: [clang][dataflow] Add `Environment::get<>()`. (#76...

Vitaly Buka via All-commits all-commits at lists.llvm.org
Thu Dec 21 00:13:34 PST 2023


  Branch: refs/heads/users/vitalybuka/spr/hwasan-print-stack-overflow-underflow-uas
  Home:   https://github.com/llvm/llvm-project
  Commit: 2ee396b0b102a857ec918beb583c3e71718efbce
      https://github.com/llvm/llvm-project/commit/2ee396b0b102a857ec918beb583c3e71718efbce
  Author: martinboehme <mboehme at google.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
    M clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
    M clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
    M clang/lib/Analysis/FlowSensitive/RecordOps.cpp
    M clang/lib/Analysis/FlowSensitive/Transfer.cpp
    M clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
    M clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp

  Log Message:
  -----------
  [clang][dataflow] Add `Environment::get<>()`. (#76027)

This template function casts the result of `getValue()` or
`getStorageLocation()` to a given subclass of `Value` or
`StorageLocation` (using `cast_or_null`).

It's a common pattern to do something like this:

```cxx
auto *Val = cast_or_null<PointerValue>(Env.getValue(E));
```

This can now be expressed more concisely like this:

```cxx
auto *Val = Env.get<PointerValue>(E);
```

Instead of adding a new method `get()`, I had originally considered
simply adding a template parameter to `getValue()` and
`getStorageLocation()` (with a default argument of `Value` or
`StorageLocation`), but this results in an undesirable repetition at the
callsite, e.g. `getStorageLocation<RecordStorageLocation>(...)`. The
`Value` and `StorageLocation` in the method name adds nothing of value
when the template argument already contains this information, so it
seemed best to shorten the method name to simply `get()`.


  Commit: da4bd5bece9a32d9a5f903e0a3a6cb8233dd43f2
      https://github.com/llvm/llvm-project/commit/da4bd5bece9a32d9a5f903e0a3a6cb8233dd43f2
  Author: Vitaly Buka <vitalybuka at google.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M compiler-rt/test/hwasan/TestCases/heap-buffer-overflow.c

  Log Message:
  -----------
  [test][hwasan] Clang-format a test


  Commit: 6e1dbab41447c6eeaba95f9a599b676247ce2f87
      https://github.com/llvm/llvm-project/commit/6e1dbab41447c6eeaba95f9a599b676247ce2f87
  Author: Vitaly Buka <vitalybuka at google.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
    M clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
    M clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
    M clang/lib/Analysis/FlowSensitive/RecordOps.cpp
    M clang/lib/Analysis/FlowSensitive/Transfer.cpp
    M clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
    M clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
    M compiler-rt/test/hwasan/TestCases/heap-buffer-overflow.c

  Log Message:
  -----------
  [𝘀𝗽𝗿] changes introduced through rebase

Created using spr 1.3.4

[skip ci]


  Commit: b9c7e021914b03e7b880c0ca9e4f16403181e46d
      https://github.com/llvm/llvm-project/commit/b9c7e021914b03e7b880c0ca9e4f16403181e46d
  Author: Vitaly Buka <vitalybuka at google.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
    M clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
    M clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
    M clang/lib/Analysis/FlowSensitive/RecordOps.cpp
    M clang/lib/Analysis/FlowSensitive/Transfer.cpp
    M clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
    M clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
    M compiler-rt/test/hwasan/TestCases/heap-buffer-overflow.c
    M compiler-rt/test/hwasan/TestCases/stack-overflow.c
    M compiler-rt/test/hwasan/TestCases/stack-underflow.c

  Log Message:
  -----------
  rebase

Created using spr 1.3.4


Compare: https://github.com/llvm/llvm-project/compare/bd2a5987e9c6...b9c7e021914b


More information about the All-commits mailing list