Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td =================================================================== --- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -365,18 +365,6 @@ } // end "apiModeling" -let ParentPackage = APIModelingAlpha in { - -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]>, - WeakDependencies<[NonNullParamChecker]>, - Documentation; - -} // end "alpha.apiModeling" - //===----------------------------------------------------------------------===// // Evaluate "builtin" functions. //===----------------------------------------------------------------------===// @@ -535,6 +523,14 @@ HelpText<"Check for calls to blocking functions inside a critical section">, 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]>, + WeakDependencies<[NonNullParamChecker]>, + Documentation; + } // end "alpha.unix" //===----------------------------------------------------------------------===// Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2107,7 +2107,7 @@ // Methods for BugReport and subclasses. //===----------------------------------------------------------------------===// -static bool isDependency(const CheckerRegistry &Registry, +LLVM_ATTRIBUTE_USED static bool isDependency(const CheckerRegistry &Registry, StringRef CheckerName) { for (const std::pair &Pair : Registry.Dependencies) { if (Pair.second == CheckerName) @@ -2116,6 +2116,17 @@ return false; } +LLVM_ATTRIBUTE_USED static bool isHidden(const CheckerRegistry &Registry, + StringRef CheckerName) { + for (const CheckerRegistry::CheckerInfo &Checker : Registry.Checkers) { + if (Checker.FullName == CheckerName) + return Checker.IsHidden; + } + llvm_unreachable( + "Checker name not found in CheckerRegistry -- did you retrieve it " + "correctly from CheckerManager::getCurrentCheckerName?"); +} + PathSensitiveBugReport::PathSensitiveBugReport( const BugType &bt, StringRef shortDesc, StringRef desc, const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique, @@ -2131,6 +2142,16 @@ "Some checkers depend on this one! We don't allow dependency " "checkers to emit warnings, because checkers should depend on " "*modeling*, not *diagnostics*."); + + assert( + bt.getCheckerName().startswith("debug") || + !isHidden(ErrorNode->getState() + ->getAnalysisManager() + .getCheckerManager() + ->getCheckerRegistry(), + bt.getCheckerName()) && + "Hidden checkers musn't emit diagnostics as they are by definition " + "non-user facing!"); } void PathSensitiveBugReport::addVisitor( Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c =================================================================== --- clang/test/Analysis/std-c-library-functions-arg-constraints.c +++ clang/test/Analysis/std-c-library-functions-arg-constraints.c @@ -2,7 +2,7 @@ // RUN: %clang_analyze_cc1 %s \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \ -// RUN: -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \ +// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \ // RUN: -analyzer-checker=debug.StdCLibraryFunctionsTester \ // RUN: -analyzer-checker=debug.ExprInspection \ // RUN: -triple x86_64-unknown-linux-gnu \ @@ -12,7 +12,7 @@ // RUN: %clang_analyze_cc1 %s \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \ -// RUN: -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \ +// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \ // RUN: -analyzer-checker=debug.StdCLibraryFunctionsTester \ // RUN: -analyzer-checker=debug.ExprInspection \ // RUN: -triple x86_64-unknown-linux-gnu \ Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp =================================================================== --- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp +++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp @@ -1,7 +1,7 @@ // RUN: %clang_analyze_cc1 %s \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \ -// RUN: -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \ +// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \ // RUN: -analyzer-checker=debug.StdCLibraryFunctionsTester \ // RUN: -analyzer-checker=debug.ExprInspection \ // RUN: -analyzer-config eagerly-assume=false \ Index: clang/test/Analysis/weak-dependencies.c =================================================================== --- clang/test/Analysis/weak-dependencies.c +++ clang/test/Analysis/weak-dependencies.c @@ -1,5 +1,5 @@ // RUN: %clang_analyze_cc1 %s -verify \ -// RUN: -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \ +// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \ // RUN: -analyzer-checker=core typedef __typeof(sizeof(int)) size_t;