[all-commits] [llvm/llvm-project] b29186: [analyzer] canonicalize special case of structure/...

vabridgers via All-commits all-commits at lists.llvm.org
Wed Oct 6 03:19:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b29186c08ae230d0decbca67565be68919c6b24d
      https://github.com/llvm/llvm-project/commit/b29186c08ae230d0decbca67565be68919c6b24d
  Author: Vince Bridgers <vince.a.bridgers at gmail.com>
  Date:   2021-10-06 (Wed, 06 Oct 2021)

  Changed paths:
    M clang/lib/StaticAnalyzer/Core/Store.cpp
    M clang/test/Analysis/ptr-arith.c

  Log Message:
  -----------
  [analyzer] canonicalize special case of structure/pointer deref

This simple change addresses a special case of structure/pointer
aliasing that produced different symbolvals, leading to false positives
during analysis.

The reproducer is as simple as this.

```lang=C++
struct s {
  int v;
};

void foo(struct s *ps) {
  struct s ss = *ps;
  clang_analyzer_dump(ss.v); // reg_$1<int Element{SymRegion{reg_$0<struct s *ps>},0 S64b,struct s}.v>
  clang_analyzer_dump(ps->v); //reg_$3<int SymRegion{reg_$0<struct s *ps>}.v>
  clang_analyzer_eval(ss.v == ps->v); // UNKNOWN
}
```

Acks: Many thanks to @steakhal and @martong for the group debug session.

Reviewed By: steakhal, martong

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




More information about the All-commits mailing list