From d061685a8304eb0b6adacd24f8dd2c2ef6dfee39 Mon Sep 17 00:00:00 2001 From: Gabor Marton Date: Tue, 5 May 2020 16:37:10 +0200 Subject: [PATCH] [analyzer] Make NonNullParamChecker as dependency for StdCLibraryFunctionsChecker Summary: If a given parameter in a FunctionDecl has a nonull attribute then the NonNull constraint in StdCLibraryFunctionsChecker has the same effect as NonNullParamChecker. I think it is better to emit diagnostics from the simpler checker. By making NonNullParamChecker as a dependency, in these cases it will be the first to emit a diagnostic and to stop the analysis on that path. Reviewers: Szelethus, NoQ, baloghadamsoftware, balazske, steakhal Subscribers: whisperity, xazax.hun, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, gamesh411, Charusso, ASDenysPetrov, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D79420 --- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td | 3 ++- clang/test/Analysis/analyzer-enabled-checkers.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index c35f8b1..b4caaa0 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -293,13 +293,14 @@ let ParentPackage = APIModeling in { def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">, HelpText<"Improve modeling of the C standard library functions">, + Dependencies<[NonNullParamChecker, CallAndMessageChecker]>, Documentation; def StdCLibraryFunctionArgsChecker : Checker<"StdCLibraryFunctionArgs">, HelpText<"Check constraints of arguments of C standard library functions, " "such as whether the parameter of isalpha is in the range [0, 255] " "or is EOF.">, - Dependencies<[StdCLibraryFunctionsChecker, CallAndMessageChecker]>, + Dependencies<[StdCLibraryFunctionsChecker]>, Documentation; def TrustNonnullChecker : Checker<"TrustNonnull">, diff --git a/clang/test/Analysis/analyzer-enabled-checkers.c b/clang/test/Analysis/analyzer-enabled-checkers.c index 6f719ec..0e44b11 100644 --- a/clang/test/Analysis/analyzer-enabled-checkers.c +++ b/clang/test/Analysis/analyzer-enabled-checkers.c @@ -6,15 +6,15 @@ // CHECK: OVERVIEW: Clang Static Analyzer Enabled Checkers List // CHECK-EMPTY: -// CHECK-NEXT: apiModeling.StdCLibraryFunctions +// CHECK-NEXT: core.NonNullParamChecker // CHECK-NEXT: core.CallAndMessage +// CHECK-NEXT: apiModeling.StdCLibraryFunctions // CHECK-NEXT: apiModeling.StdCLibraryFunctionArgs // CHECK-NEXT: apiModeling.TrustNonnull // CHECK-NEXT: apiModeling.llvm.CastValue // CHECK-NEXT: apiModeling.llvm.ReturnValue // CHECK-NEXT: core.DivideZero // CHECK-NEXT: core.DynamicTypePropagation -// CHECK-NEXT: core.NonNullParamChecker // CHECK-NEXT: core.NonnilStringConstants // CHECK-NEXT: core.NullDereference // CHECK-NEXT: core.StackAddrEscapeBase -- 2.7.4