Page MenuHomePhabricator

Re-analyze functions as top-level
Needs ReviewPublic

Authored by chrisbazley on Jan 27 2023, 9:06 AM.

Details

Reviewers
NoQ
Summary

If a function with a _Nullable parameter has at least
one caller, the checker behaves as though no other
parameter value is possible. This is because the static
analyzer doesn't re-analyse functions as top level
(with the exception of C++ copy and move operators, and
ObjC methods).

Fixed by modifying shouldSkipFunction to return false.

After this change, Clang-tidy even emits different
warnings for the same line of code, if appropriate:
"Nullable pointer is dereferenced" for a (simulated)
top-level call and "Dereference of null pointer"
for a call to the same function with a known null value.

Diff Detail

Unit TestsFailed

TimeTest
3,470 mslibcxx CI Modules > llvm-libc++-shared-cfg-in.libcxx/algorithms/specialized_algorithms/special_mem_concepts::nothrow_sentinel_for.compile.pass.cpp
Script: -- : 'COMPILED WITH'; /home/libcxx-builder/.buildkite-agent/builds/b44fbc847e23-1/llvm-project/libcxx-ci/install/bin/clang++ /home/libcxx-builder/.buildkite-agent/builds/b44fbc847e23-1/llvm-project/libcxx-ci/libcxx/test/libcxx/algorithms/specialized.algorithms/special.mem.concepts/nothrow_sentinel_for.compile.pass.cpp --target=x86_64-unknown-linux-gnu -nostdinc++ -I /home/libcxx-builder/.buildkite-agent/builds/b44fbc847e23-1/llvm-project/libcxx-ci/build/generic-modules/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/b44fbc847e23-1/llvm-project/libcxx-ci/build/generic-modules/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/b44fbc847e23-1/llvm-project/libcxx-ci/libcxx/test/support -std=c++2b -fmodules -fcxx-modules -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_DISABLE_AVAILABILITY -Werror=thread-safety -Wuser-defined-warnings -fsyntax-only

Event Timeline

chrisbazley created this revision.Jan 27 2023, 9:06 AM
Herald added a project: Restricted Project. · View Herald Transcript
chrisbazley requested review of this revision.Jan 27 2023, 9:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2023, 9:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This change is admittedly a hack. It might be better to check the function parameter types, or maybe the list of exceptions in this function is now so long that it no longer serves any purpose.