[all-commits] [llvm/llvm-project] ca4a40: [analyzer] Refactor recognition of the errno gette...

Donát Nagy via All-commits all-commits at lists.llvm.org
Wed May 15 01:54:16 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ca4a405232cf170f20a2f111bf72beab82095935
      https://github.com/llvm/llvm-project/commit/ca4a405232cf170f20a2f111bf72beab82095935
  Author: Donát Nagy <donat.nagy at ericsson.com>
  Date:   2024-05-15 (Wed, 15 May 2024)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
    M clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
    M clang/test/Analysis/memory-model.cpp

  Log Message:
  -----------
  [analyzer] Refactor recognition of the errno getter functions (#91531)

There are many environments where `errno` is a macro that expands to
something like `(*__errno())` (different standard library
implementations use different names instead of "__errno").

In these environments the ErrnoModeling checker creates a symbolic
region which will be used to represent the return value of this "get the
location of errno" function.

Previously this symbol was only created when the checker was able to
find the declaration of the "get the location of errno" function; but
this commit eliminates the complex logic that was responsible for this
and always creates the symbolic region when `errno` is not available as
a "regular" global variable.

This significantly simplifies a code and only introduces a minimal
performance reduction (one extra symbol) in the case when `errno` is not
declared (neither as a variable nor as a function).


In addition to this simplification, this commit specifies that the
`CallDescription`s for the "get the location of errno" functions are
matched in `CDM::CLibrary` mode. (This was my original goal, but I was
sidetracked by resolving a FIXME above the `CallDescriptionSet` in
`ErrnoModeling.cpp`.)

This change is very close to being NFC, but it fixes weird corner cases
like the handling of a C++ method that happens to be named "__errno()"
(previously it could've been recognized as an errno location getter
function).



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