Page MenuHomePhabricator

[analyzer][StdLibraryFunctionsChecker] Have proper weak dependencies
ClosedPublic

Authored by martong on Sep 7 2020, 8:21 AM.

Details

Summary

We want the generice StdLibraryFunctionsChecker to report only if there
are no specific checkers that would handle the argument constraint for a
function.

Note, the assumptions are still evaluated, even if the arguement
constraint checker is set to not report. This means that the assumptions
made in the generic StdLibraryFunctionsChecker should be an
over-approximation of the assumptions made in the specific checkers. But
most importantly, the assumptions should not contradict.

Diff Detail

Unit TestsFailed

TimeTest
30 mslinux > Clang.Analysis::std-c-library-functions-arg-enabled-checkers.c
Script: -- : 'RUN: at line 4'; /mnt/disks/ssd0/agent/llvm-project/build/bin/clang --analyze /mnt/disks/ssd0/agent/llvm-project/clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c --target=x86_64-pc-linux-gnu -Xclang -analyzer-checker=core -Xclang -analyzer-checker=apiModeling.StdCLibraryFunctions -Xclang -analyzer-config -Xclang apiModeling.StdCLibraryFunctions:ModelPOSIX=true -Xclang -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs -Xclang -analyzer-checker=alpha.unix.Stream -Xclang -analyzer-list-enabled-checkers -Xclang -analyzer-display-progress 2>&1 | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c --implicit-check-not=ANALYZE --implicit-check-not=\.
110 mswindows > Clang.Analysis::std-c-library-functions-arg-enabled-checkers.c
Script: -- : 'RUN: at line 4'; c:\ws\w16-1\llvm-project\premerge-checks\build\bin\clang.exe --analyze C:\ws\w16-1\llvm-project\premerge-checks\clang\test\Analysis\std-c-library-functions-arg-enabled-checkers.c --target=x86_64-pc-linux-gnu -Xclang -analyzer-checker=core -Xclang -analyzer-checker=apiModeling.StdCLibraryFunctions -Xclang -analyzer-config -Xclang apiModeling.StdCLibraryFunctions:ModelPOSIX=true -Xclang -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs -Xclang -analyzer-checker=alpha.unix.Stream -Xclang -analyzer-list-enabled-checkers -Xclang -analyzer-display-progress 2>&1 | c:\ws\w16-1\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w16-1\llvm-project\premerge-checks\clang\test\Analysis\std-c-library-functions-arg-enabled-checkers.c --implicit-check-not=ANALYZE --implicit-check-not=\.

Event Timeline

martong created this revision.Sep 7 2020, 8:21 AM
martong requested review of this revision.Sep 7 2020, 8:21 AM
Szelethus accepted this revision.Sep 7 2020, 8:30 AM

This is exactly how I imagines weak dependencies to work. LGTM on my end.

This revision is now accepted and ready to land.Sep 7 2020, 8:30 AM
This revision was landed with ongoing or failed builds.Sep 7 2020, 8:56 AM
This revision was automatically updated to reflect the committed changes.
martong added inline comments.Sep 15 2020, 7:32 AM
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
352

Umm, we should not have removed this. The checker always asserts that the arguments are initialized and that is checked by the dependency.

This is causing an assertion in D87081. Unfortunately, we hadn't have any tests to catch this, but now we have one, exactly in D87081. So I am putting back this dependency there.