[all-commits] [llvm/llvm-project] 558b46: [analyzer] Fix crashing getSValFromInitListExpr fo...

Balazs Benics via All-commits all-commits at lists.llvm.org
Wed Mar 22 00:44:19 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 558b46fde2db2215794336bbd08e411fee5240d7
      https://github.com/llvm/llvm-project/commit/558b46fde2db2215794336bbd08e411fee5240d7
  Author: Balazs Benics <benicsbalazs at gmail.com>
  Date:   2023-03-22 (Wed, 22 Mar 2023)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/RegionStore.cpp
    M clang/test/Analysis/initialization.cpp

  Log Message:
  -----------
  [analyzer] Fix crashing getSValFromInitListExpr for nested initlists

In the following example, we will end up hitting the `llvm_unreachable()`:
https://godbolt.org/z/5sccc95Ec
```lang=C++
enum class E {};
const E glob[] = {{}};
void initlistWithinInitlist() {
  clang_analyzer_dump(glob[0]); // crashes at loading from `glob[0]`
}
```

We should just return `std::nullopt` instead for these cases.
It's better than crashing.

Reviewed By: xazax.hun

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




More information about the All-commits mailing list