From a807e8ea9f6ecf151e2ccc84af05431e54be8dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Tue, 22 Jul 2025 13:36:58 +0200 Subject: [PATCH] [analyzer] Prettify checker registration and unittest code (#147797) This commit tweaks the interface of `CheckerRegistry::addChecker` to make it more practical for plugins and tests: - The parameter `IsHidden` now defaults to `false` even in the non-templated overload (because setting it to true is unusual, especially in plugins). - The parameter `DocsUri` defaults to the dummy placeholder string `"NoDocsUri"` because (as of now) nothing queries its value from the checker registry (it's only used by the logic that generates the clang-tidy documentation, but that loads it directly from `Checkers.td` without involving the `CheckerRegistry`), so there is no reason to demand specifying this value. In addition to propagating these changes, this commit clarifies, corrects and extends lots of comments and performs various minor code quality improvements in the code of unit tests and example plugins. I originally wrote the bulk of this commit when I was planning to add an extra parameter to `addChecker` in order to implement some technical details of the CheckerFamily framework. At the end I decided against adding that extra parameter, so this cleanup was left out of the PR https://github.com/llvm/llvm-project/pull/139256 and I'm merging it now as a separate commit (after minor tweaks). This commit is mostly NFC: the only functional change is that the analyzer will be compatible with plugins that rely on the default argument values and don't specify `IsHidden` or `DocsUri`. (But existing plugin code will remain valid as well.) --- .../StaticAnalyzer/Frontend/CheckerRegistry.h | 61 +++++++++---------- .../CheckerDependencyHandling.cpp | 13 ++-- .../CheckerOptionHandling.cpp | 13 ++-- .../SampleAnalyzer/MainCallChecker.cpp | 18 +++--- .../BlockEntranceCallbackTest.cpp | 6 +- .../BugReportInterestingnessTest.cpp | 2 +- .../StaticAnalyzer/CallDescriptionTest.cpp | 4 +- .../StaticAnalyzer/CallEventTest.cpp | 2 +- .../ConflictingEvalCallsTest.cpp | 6 +- .../StaticAnalyzer/ExprEngineVisitTest.cpp | 8 +-- .../FalsePositiveRefutationBRVisitorTest.cpp | 4 +- .../MemRegionDescriptiveNameTest.cpp | 2 +- .../NoStateChangeFuncVisitorTest.cpp | 4 +- .../StaticAnalyzer/ObjcBug-124477.cpp | 2 +- .../RegisterCustomCheckersTest.cpp | 24 ++++---- .../StaticAnalyzer/SValSimplifyerTest.cpp | 3 +- clang/unittests/StaticAnalyzer/SValTest.cpp | 6 +- .../TestReturnValueUnderConstruction.cpp | 6 +- 18 files changed, 89 insertions(+), 95 deletions(-) diff --git a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h index 43dbfb158515..da3efd76c6aa 100644 --- a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h +++ b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h @@ -38,29 +38,29 @@ // function clang_registerCheckers. For example: // // extern "C" -// void clang_registerCheckers (CheckerRegistry ®istry) { -// registry.addChecker("example.MainCallChecker", -// "Disallows calls to functions called main"); +// void clang_registerCheckers(CheckerRegistry &Registry) { +// Registry.addChecker( +// "example.MainCallChecker", +// "Disallows calls to functions called main"); // } // -// The first method argument is the full name of the checker, including its -// enclosing package. By convention, the registered name of a checker is the -// name of the associated class (the template argument). -// The second method argument is a short human-readable description of the -// checker. +// The first argument of this templated method is the full name of the checker +// (including its package), while the second argument is a short description +// that is printed by `-analyzer-checker-help`. // -// The clang_registerCheckers function may add any number of checkers to the -// registry. If any checkers require additional initialization, use the three- -// argument form of CheckerRegistry::addChecker. +// A plugin may register several separate checkers by calling `addChecker()` +// multiple times. If a checker requires custom registration functions (e.g. +// checker option handling) use the non-templated overload of `addChecker` that +// takes two callback functions as the first two parameters. // // To load a checker plugin, specify the full path to the dynamic library as // the argument to the -load option in the cc1 frontend. You can then enable // your custom checker using the -analyzer-checker: // -// clang -cc1 -load -analyze -// -analyzer-checker= +// clang -cc1 -load /path/to/plugin.dylib -analyze +// -analyzer-checker=example.MainCallChecker // -// For a complete working example, see examples/analyzer-plugin. +// For complete examples, see clang/lib/Analysis/plugins/SampleAnalyzer #ifndef CLANG_ANALYZER_API_VERSION_STRING // FIXME: The Clang version string is not particularly granular; @@ -108,30 +108,25 @@ private: mgr.template registerChecker(); } - template static bool returnTrue(const CheckerManager &mgr) { - return true; - } + static bool returnTrue(const CheckerManager &) { return true; } public: - /// Adds a checker to the registry. Use this non-templated overload when your - /// checker requires custom initialization. - void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction sfn, - StringRef FullName, StringRef Desc, StringRef DocsUri, - bool IsHidden); + /// Adds a checker to the registry. + /// Use this for a checker defined in a plugin if it requires custom + /// registration functions (e.g. for handling checker options). + /// NOTE: As of now `DocsUri` is never queried from the checker registry. + void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction Sfn, + StringRef FullName, StringRef Desc, + StringRef DocsUri = "NoDocsUri", bool IsHidden = false); - /// Adds a checker to the registry. Use this templated overload when your - /// checker does not require any custom initialization. - /// This function isn't really needed and probably causes more headaches than - /// the tiny convenience that it provides, but external plugins might use it, - /// and there isn't a strong incentive to remove it. + /// Adds a checker to the registry. + /// Use this for a checker defined in a plugin if it doesn't require custom + /// registration functions. template - void addChecker(StringRef FullName, StringRef Desc, StringRef DocsUri, - bool IsHidden = false) { - // Avoid MSVC's Compiler Error C2276: - // http://msdn.microsoft.com/en-us/library/850cstw1(v=VS.80).aspx + void addChecker(StringRef FullName, StringRef Desc, + StringRef DocsUri = "NoDocsUri", bool IsHidden = false) { addChecker(&CheckerRegistry::initializeManager, - &CheckerRegistry::returnTrue, FullName, Desc, DocsUri, - IsHidden); + &CheckerRegistry::returnTrue, FullName, Desc, DocsUri, IsHidden); } /// Makes the checker with the full name \p fullName depend on the checker diff --git a/clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp b/clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp index aacb886f6e12..518f9e7ddf34 100644 --- a/clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp +++ b/clang/lib/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp @@ -2,6 +2,9 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h" +// This barebones plugin is used by clang/test/Analysis/checker-plugins.c +// to test dependency handling among checkers loaded from plugins. + using namespace clang; using namespace ento; @@ -15,12 +18,12 @@ struct DependendentChecker : public Checker { } // end anonymous namespace // Register plugin! -extern "C" void clang_registerCheckers(CheckerRegistry ®istry) { - registry.addChecker("example.Dependency", "", ""); - registry.addChecker("example.DependendentChecker", "", - ""); +extern "C" void clang_registerCheckers(CheckerRegistry &Registry) { + Registry.addChecker("example.Dependency", "MockDescription"); + Registry.addChecker("example.DependendentChecker", + "MockDescription"); - registry.addDependency("example.DependendentChecker", "example.Dependency"); + Registry.addDependency("example.DependendentChecker", "example.Dependency"); } extern "C" const char clang_analyzerAPIVersionString[] = diff --git a/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp b/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp index 82c105824255..2adb9348f671 100644 --- a/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp +++ b/clang/lib/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp @@ -5,6 +5,9 @@ using namespace clang; using namespace ento; +// This barebones plugin is used by clang/test/Analysis/checker-plugins.c +// to test option handling on checkers loaded from plugins. + namespace { struct MyChecker : public Checker { void checkBeginFunction(CheckerContext &Ctx) const {} @@ -25,13 +28,11 @@ bool shouldRegisterMyChecker(const CheckerManager &mgr) { return true; } } // end anonymous namespace // Register plugin! -extern "C" void clang_registerCheckers(CheckerRegistry ®istry) { - registry.addChecker(registerMyChecker, shouldRegisterMyChecker, - "example.MyChecker", "Example Description", - "example.mychecker.documentation.nonexistent.html", - /*isHidden*/false); +extern "C" void clang_registerCheckers(CheckerRegistry &Registry) { + Registry.addChecker(registerMyChecker, shouldRegisterMyChecker, + "example.MyChecker", "Example Description"); - registry.addCheckerOption(/*OptionType*/ "bool", + Registry.addCheckerOption(/*OptionType*/ "bool", /*CheckerFullName*/ "example.MyChecker", /*OptionName*/ "ExampleOption", /*DefaultValStr*/ "false", diff --git a/clang/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp b/clang/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp index fd210d733fd0..53a01d278e6d 100644 --- a/clang/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp +++ b/clang/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp @@ -3,12 +3,16 @@ #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h" +// This simple plugin is used by clang/test/Analysis/checker-plugins.c +// to test the use of a checker that is defined in a plugin. + using namespace clang; using namespace ento; namespace { class MainCallChecker : public Checker> { - mutable std::unique_ptr BT; + + const BugType BT{this, "call to main", "example analyzer plugin"}; public: void checkPreStmt(const CallExpr *CE, CheckerContext &C) const; @@ -33,21 +37,17 @@ void MainCallChecker::checkPreStmt(const CallExpr *CE, if (!N) return; - if (!BT) - BT.reset(new BugType(this, "call to main", "example analyzer plugin")); - auto report = - std::make_unique(*BT, BT->getDescription(), N); + std::make_unique(BT, BT.getDescription(), N); report->addRange(Callee->getSourceRange()); C.emitReport(std::move(report)); } } // Register plugin! -extern "C" void clang_registerCheckers(CheckerRegistry ®istry) { - registry.addChecker( - "example.MainCallChecker", "Disallows calls to functions called main", - ""); +extern "C" void clang_registerCheckers(CheckerRegistry &Registry) { + Registry.addChecker("example.MainCallChecker", + "Example Description"); } extern "C" const char clang_analyzerAPIVersionString[] = diff --git a/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp b/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp index 0f05c39df93e..d15bec02879f 100644 --- a/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp +++ b/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp @@ -91,8 +91,7 @@ void addBlockEntranceTester(AnalysisASTConsumer &AnalysisConsumer, AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker(®isterChecker, &shouldAlwaysRegister, "test.BlockEntranceTester", - "EmptyDescription", "EmptyDocsUri", - /*IsHidden=*/false); + "EmptyDescription"); }); } @@ -102,8 +101,7 @@ void addBranchConditionTester(AnalysisASTConsumer &AnalysisConsumer, AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker(®isterChecker, &shouldAlwaysRegister, "test.BranchConditionTester", - "EmptyDescription", "EmptyDocsUri", - /*IsHidden=*/false); + "EmptyDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp b/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp index 0ef63b049621..fc50f0028015 100644 --- a/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp +++ b/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp @@ -120,7 +120,7 @@ public: std::move(ExpectedDiags), Compiler.getSourceManager())); AnalysisConsumer->AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker("test.Interestingness", - "Description", ""); + "MockDescription"); }); Compiler.getAnalyzerOpts().CheckersAndPackages = { {"test.Interestingness", true}}; diff --git a/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp b/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp index 4cb6bd34fa36..e2007a9589c6 100644 --- a/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp +++ b/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp @@ -616,8 +616,8 @@ void addCallDescChecker(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { AnOpts.CheckersAndPackages = {{"test.CallDescChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker("test.CallDescChecker", "Description", - ""); + Registry.addChecker("test.CallDescChecker", + "MockDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/CallEventTest.cpp b/clang/unittests/StaticAnalyzer/CallEventTest.cpp index 2843572e5f80..8b5289ea7472 100644 --- a/clang/unittests/StaticAnalyzer/CallEventTest.cpp +++ b/clang/unittests/StaticAnalyzer/CallEventTest.cpp @@ -56,7 +56,7 @@ void addCXXDeallocatorChecker(AnalysisASTConsumer &AnalysisConsumer, AnOpts.CheckersAndPackages = {{"test.CXXDeallocator", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker("test.CXXDeallocator", - "Description", ""); + "MockDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp b/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp index e410cca07663..cffdbf1896df 100644 --- a/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp +++ b/clang/unittests/StaticAnalyzer/ConflictingEvalCallsTest.cpp @@ -33,10 +33,8 @@ void addEvalFooCheckers(AnalysisASTConsumer &AnalysisConsumer, AnOpts.CheckersAndPackages = {{"test.EvalFoo1", true}, {"test.EvalFoo2", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker("test.EvalFoo1", "EmptyDescription", - "EmptyDocsUri"); - Registry.addChecker("test.EvalFoo2", "EmptyDescription", - "EmptyDocsUri"); + Registry.addChecker("test.EvalFoo1", "MockDescription"); + Registry.addChecker("test.EvalFoo2", "MockDescription"); }); } } // namespace diff --git a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp index b6eeb9ce3738..12be2289c317 100644 --- a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp +++ b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp @@ -78,7 +78,7 @@ void addExprEngineVisitPreChecker(AnalysisASTConsumer &AnalysisConsumer, AnOpts.CheckersAndPackages = {{"ExprEngineVisitPreChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker("ExprEngineVisitPreChecker", - "Desc", "DocsURI"); + "MockDescription"); }); } @@ -87,7 +87,7 @@ void addExprEngineVisitPostChecker(AnalysisASTConsumer &AnalysisConsumer, AnOpts.CheckersAndPackages = {{"ExprEngineVisitPostChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker( - "ExprEngineVisitPostChecker", "Desc", "DocsURI"); + "ExprEngineVisitPostChecker", "MockDescription"); }); } @@ -95,8 +95,8 @@ void addMemAccessChecker(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { AnOpts.CheckersAndPackages = {{"MemAccessChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker("MemAccessChecker", "Desc", - "DocsURI"); + Registry.addChecker("MemAccessChecker", + "MockDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp b/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp index 8f0a96d41e75..146797f5b17f 100644 --- a/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp +++ b/clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp @@ -92,8 +92,8 @@ void addFalsePositiveGenerator(AnalysisASTConsumer &AnalysisConsumer, AnOpts.CheckersAndPackages = {{"test.FalsePositiveGenerator", true}, {"debug.ViewExplodedGraph", false}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker( - "test.FalsePositiveGenerator", "EmptyDescription", "EmptyDocsUri"); + Registry.addChecker("test.FalsePositiveGenerator", + "MockDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp b/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp index 0f6e49bf42f4..7b837f3b7fb2 100644 --- a/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp +++ b/clang/unittests/StaticAnalyzer/MemRegionDescriptiveNameTest.cpp @@ -46,7 +46,7 @@ void addDescriptiveNameChecker(AnalysisASTConsumer &AnalysisConsumer, AnOpts.CheckersAndPackages = {{"DescriptiveNameChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker("DescriptiveNameChecker", - "Desc", "DocsURI"); + "MockDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp b/clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp index a9033425dfb5..68d267853e92 100644 --- a/clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp +++ b/clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp @@ -140,7 +140,7 @@ void addNonThoroughStatefulChecker(AnalysisASTConsumer &AnalysisConsumer, AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry .addChecker>( - "test.StatefulChecker", "Description", ""); + "test.StatefulChecker", "MockDescription"); }); } @@ -233,7 +233,7 @@ void addThoroughStatefulChecker(AnalysisASTConsumer &AnalysisConsumer, AnOpts.CheckersAndPackages = {{"test.StatefulChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker>( - "test.StatefulChecker", "Description", ""); + "test.StatefulChecker", "MockDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp b/clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp index 51bd33210032..ab78090b42f3 100644 --- a/clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp +++ b/clang/unittests/StaticAnalyzer/ObjcBug-124477.cpp @@ -37,7 +37,7 @@ void addFlagFlipperChecker(AnalysisASTConsumer &AnalysisConsumer, AnOpts.CheckersAndPackages = {{"test.FlipFlagOnCheckLocation", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker("test.FlipFlagOnCheckLocation", - "Description", ""); + "MockDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp index 454eee9cf7e0..e17d107d90ce 100644 --- a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp +++ b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp @@ -44,7 +44,7 @@ void addCustomChecker(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { AnOpts.CheckersAndPackages = {{"test.CustomChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker("test.CustomChecker", "Description", ""); + Registry.addChecker("test.CustomChecker", "MockDescription"); }); } @@ -73,8 +73,8 @@ void addLocIncDecChecker(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { AnOpts.CheckersAndPackages = {{"test.LocIncDecChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker("test.LocIncDecChecker", "Description", - ""); + Registry.addChecker("test.LocIncDecChecker", + "MockDescription"); }); } @@ -119,10 +119,10 @@ bool shouldRegisterCheckerRegistrationOrderPrinter(const CheckerManager &mgr) { void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) { Registry.addChecker(registerCheckerRegistrationOrderPrinter, shouldRegisterCheckerRegistrationOrderPrinter, - "test.RegistrationOrder", "Description", "", false); + "test.RegistrationOrder", "Description"); } -#define UNITTEST_CHECKER(CHECKER_NAME, DIAG_MSG) \ +#define UNITTEST_CHECKER(CHECKER_NAME) \ class CHECKER_NAME : public Checker> { \ public: \ void checkPreStmt(const DeclStmt *DS, CheckerContext &C) const {} \ @@ -137,11 +137,11 @@ void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) { } \ void add##CHECKER_NAME(CheckerRegistry &Registry) { \ Registry.addChecker(register##CHECKER_NAME, shouldRegister##CHECKER_NAME, \ - "test." #CHECKER_NAME, "Description", "", false); \ + "test." #CHECKER_NAME, "Description"); \ } -UNITTEST_CHECKER(StrongDep, "Strong") -UNITTEST_CHECKER(Dep, "Dep") +UNITTEST_CHECKER(StrongDep) +UNITTEST_CHECKER(Dep) bool shouldRegisterStrongFALSE(const CheckerManager &mgr) { return false; @@ -154,7 +154,7 @@ void addDep(AnalysisASTConsumer &AnalysisConsumer, {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker(registerStrongDep, shouldRegisterStrongFALSE, - "test.Strong", "Description", "", false); + "test.Strong", "Description"); addStrongDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); @@ -172,7 +172,7 @@ TEST(RegisterDeps, UnsatisfiedDependency) { // Weak checker dependencies. //===----------------------------------------------------------------------===// -UNITTEST_CHECKER(WeakDep, "Weak") +UNITTEST_CHECKER(WeakDep) void addWeakDepCheckerBothEnabled(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { @@ -225,8 +225,8 @@ void addWeakDepCheckerDepUnspecified(AnalysisASTConsumer &AnalysisConsumer, }); } -UNITTEST_CHECKER(WeakDep2, "Weak2") -UNITTEST_CHECKER(Dep2, "Dep2") +UNITTEST_CHECKER(WeakDep2) +UNITTEST_CHECKER(Dep2) void addWeakDepHasWeakDep(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { diff --git a/clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp b/clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp index 85cfe2c1965a..4331ffc1b585 100644 --- a/clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp +++ b/clang/unittests/StaticAnalyzer/SValSimplifyerTest.cpp @@ -68,8 +68,7 @@ static void addSimplifyChecker(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { AnOpts.CheckersAndPackages = {{"SimplifyChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker("SimplifyChecker", "EmptyDescription", - "EmptyDocsUri"); + Registry.addChecker("SimplifyChecker", "MockDescription"); }); } diff --git a/clang/unittests/StaticAnalyzer/SValTest.cpp b/clang/unittests/StaticAnalyzer/SValTest.cpp index d8897b0f2183..58e9a8da0e99 100644 --- a/clang/unittests/StaticAnalyzer/SValTest.cpp +++ b/clang/unittests/StaticAnalyzer/SValTest.cpp @@ -139,10 +139,10 @@ class SValTest : public testing::TestWithParam {}; \ void add##NAME##SValCollector(AnalysisASTConsumer &AnalysisConsumer, \ AnalyzerOptions &AnOpts) { \ - AnOpts.CheckersAndPackages = {{"test.##NAME##SValCollector", true}}; \ + AnOpts.CheckersAndPackages = {{"test." #NAME "SValColl", true}}; \ AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { \ - Registry.addChecker("test.##NAME##SValCollector", \ - "Description", ""); \ + Registry.addChecker("test." #NAME "SValColl", \ + "MockDescription"); \ }); \ } \ \ diff --git a/clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp b/clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp index 5fc084a48667..0cb3c59a4421 100644 --- a/clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp +++ b/clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp @@ -49,9 +49,9 @@ void addTestReturnValueUnderConstructionChecker( AnOpts.CheckersAndPackages = {{"test.TestReturnValueUnderConstruction", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker( - "test.TestReturnValueUnderConstruction", "", ""); - }); + Registry.addChecker( + "test.TestReturnValueUnderConstruction", "MockDescription"); + }); } TEST(TestReturnValueUnderConstructionChecker,