llvm-project
2eeac2d4 - [analyzer] Avoid fuzzy builtin matching for predefined library functions (#244425)

Commit
1 day ago
[analyzer] Avoid fuzzy builtin matching for predefined library functions (#244425) `CheckerContext::isCLibraryFunction` performs `_`-delimited fuzzy substring matching whenever `FD->getBuiltinID() != 0` so that compiler-prefixed builtin variants such as `__builtin_memcpy` or `__builtin_memcpy_inline` match `"memcpy"`. However, predefined library functions registered via `LibBuiltin` / `GNULibBuiltin` / `ObjCLibBuiltin` also have non-zero builtin IDs. Applying fuzzy matching to them causes distinct library functions whose names contain another library function name separated by `_` to falsely match the base name — for example, `objc_read_weak` currently matches POSIX `"read"` (in `BlockInCriticalSectionChecker` and `GenericTaintChecker`), and adding builtins such as `getlogin_r` or `ttyname_r` causes `GenericTaintChecker` to misclassify them as `getlogin`/`ttyname`. - Restrict fuzzy builtin matching in `CheckerContext::isCLibraryFunction` to non-library builtins (`!BuiltinInfo.isPredefinedLibFunction(BId)`), falling through to exact matching for predefined library builtins while preserving fuzzy matching for `__builtin_*` variants. - Explicitly register C23 `memset_explicit` in `CStringChecker` (resolving the existing `FIXME`) so it continues to be modeled after fuzzy matching on `memset` is removed. - Add unit tests in `IsCLibraryFunctionTest.cpp` and `CallDescriptionTest.cpp`, analyzer test coverage for `memset_explicit`, and a `ReleaseNotes.md` entry. Assisted-by: Gemini
Author
Parents
Loading