[all-commits] [llvm/llvm-project] 52a460: [analyzer] Refactor CallDescription match mode (NF...
NagyDonat via All-commits
all-commits at lists.llvm.org
Mon Mar 4 06:43:50 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 52a460f9d4640ddc04e65161c78958bdabaae2b2
https://github.com/llvm/llvm-project/commit/52a460f9d4640ddc04e65161c78958bdabaae2b2
Author: NagyDonat <donat.nagy at ericsson.com>
Date: 2024-03-04 (Mon, 04 Mar 2024)
Changed paths:
M clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
M clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
M clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
M clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
M clang/lib/StaticAnalyzer/Core/CallDescription.cpp
M clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
Log Message:
-----------
[analyzer] Refactor CallDescription match mode (NFC) (#83432)
The class `CallDescription` is used to define patterns that are used for
matching `CallEvent`s. For example, a
`CallDescription{{"std", "find_if"}, 3}`
matches a call to `std::find_if` with 3 arguments.
However, these patterns are somewhat fuzzy, so this pattern could also
match something like `std::__1::find_if` (with an additional namespace
layer), or, unfortunately, a `CallDescription` for the well-known
function `free()` can match a C++ method named `free()`:
https://github.com/llvm/llvm-project/issues/81597
To prevent this kind of ambiguity this commit introduces the enum
`CallDescription::Mode` which can limit the pattern matching to
non-method function calls (or method calls etc.). After this NFC change,
one or more follow-up commits will apply the right pattern matching
modes in the ~30 checkers that use `CallDescription`s.
Note that `CallDescription` previously had a `Flags` field which had
only two supported values:
- `CDF_None` was the default "match anything" mode,
- `CDF_MaybeBuiltin` was a "match only C library functions and accept
some inexact matches" mode.
This commit preserves `CDF_MaybeBuiltin` under the more descriptive
name `CallDescription::Mode::CLibrary` (or `CDM::CLibrary`).
Instead of this "Flags" model I'm switching to a plain enumeration
becasue I don't think that there is a natural usecase to combine the
different matching modes. (Except for the default "match anything" mode,
which is currently kept for compatibility, but will be phased out in the
follow-up commits.)
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