[all-commits] [llvm/llvm-project] cbd380: [analyzer] Allow overriding Unknown memspaces usin...

Michael Flanders via All-commits all-commits at lists.llvm.org
Sat Feb 22 03:37:22 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cbd3801acfa4ace50df8d0eba275fc3bd6d3f1ac
      https://github.com/llvm/llvm-project/commit/cbd3801acfa4ace50df8d0eba275fc3bd6d3f1ac
  Author: Michael Flanders <flanders.michaelk at gmail.com>
  Date:   2025-02-22 (Sat, 22 Feb 2025)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
    M clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
    M clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/PutenvStackArrayChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
    M clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
    M clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
    M clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
    M clang/lib/StaticAnalyzer/Core/MemRegion.cpp
    M clang/lib/StaticAnalyzer/Core/RegionStore.cpp
    M clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

  Log Message:
  -----------
  [analyzer] Allow overriding Unknown memspaces using a ProgramState trait (#123003)

In general, if we see an allocation, we associate the immutable memory
space with the constructed memory region.
This works fine if we see the allocation.
However, with symbolic regions it's not great because there we don't
know anything about their memory spaces, thus put them into the Unknown
space.

The unfortunate consequence is that once we learn about some aliasing
with this Symbolic Region, we can't change the memory space to the
deduced one.

In this patch, we open up the memory spaces as a trait, basically
allowing associating a better memory space with a memregion that
was created with the Unknown memory space.

As a side effect, this means that now queriing the memory space of a
region depends on the State, but many places in the analyzer, such as
the Store, doesn't have (and cannot have) access to the State by design.

This means that some uses must solely rely on the memspaces of the
region, but any other users should use the getter taking a State.

Co-authored-by: Balazs Benics <benicsbalazs at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list