Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, baloghadamsoftware, martong, 
balazske, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
whisperity.
Szelethus added parent revisions: D78101: [analyzer][StackAddressEscape] Tie 
warnings to the diagnostic checkers rather then core.StackAddrEscapeBase, 
D78099: [analyzer][RetainCount] Tie diagnostics to osx.cocoa.RetainCount rather 
then RetainCountBase, for the most part, D77866: [analyzer][CallAndMessage] Add 
checker options for each bug category, D77474: [analyzer][MallocChecker] Make 
NewDeleteLeaks depend on DynamicMemoryModeling rather than NewDelete, D78124: 
[analyzer][ObjCGenerics] Don't emit diagnostics under the name 
core.DynamicTypePropagation, D78123: [analyzer][NSOrCFError] Don't emit 
diagnostics under the name osx.NSOrCFErrorDerefChecker, D78122: 
[analyzer][Nullability] Don't emit under the checker name NullabilityBase, 
D78121: [analyzer][DirectIvarAssignment] Turn 
DirectIvarAssignmentForAnnotatedFunctions into a checker option, D78120: 
[analyzer][StreamChecker] Don't make StreamTestChecker depend on StreamChecker 
for the time being.

The thrilling conclusion to the barrage of patches I uploaded lately! This is a 
big milestone towards the goal set out in 
http://lists.llvm.org/pipermail/cfe-dev/2019-August/063070.html. I hope to 
accompany this with a patch where the a `coreModeling` package is added, from 
which package diagnostics aren't allowed either, is an implicit dependency of 
all checkers, and the `core` package for the first time can be safely disabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78126

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h


Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -135,12 +136,22 @@
   SmallVector<FixItHint, 4> Fixits;
 
   BugReport(Kind kind, const BugType &bt, StringRef desc)
-      : K(kind), BT(bt), Description(desc) {}
+      : BugReport(kind, bt, "", desc) {}
 
   BugReport(Kind K, const BugType &BT, StringRef ShortDescription,
             StringRef Description)
       : K(K), BT(BT), ShortDescription(ShortDescription),
-        Description(Description) {}
+        Description(Description) {
+#define GET_CHECKER_DEPENDENCIES
+#define CHECKER_DEPENDENCY(FULLNAME, DEPENDENCY)                               
\
+  assert(BT.getCheckerName() != DEPENDENCY &&                                  
\
+         "Some checkers depend on this one! We don't allow dependency "        
\
+         "checkers to emit warnings, because checkers should depend on "       
\
+         "*modeling*, not *diagnostics*.");
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER_DEPENDENCY
+#undef GET_CHECKER_DEPENDENCIES
+  }
 
 public:
   virtual ~BugReport() = default;


Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -135,12 +136,22 @@
   SmallVector<FixItHint, 4> Fixits;
 
   BugReport(Kind kind, const BugType &bt, StringRef desc)
-      : K(kind), BT(bt), Description(desc) {}
+      : BugReport(kind, bt, "", desc) {}
 
   BugReport(Kind K, const BugType &BT, StringRef ShortDescription,
             StringRef Description)
       : K(K), BT(BT), ShortDescription(ShortDescription),
-        Description(Description) {}
+        Description(Description) {
+#define GET_CHECKER_DEPENDENCIES
+#define CHECKER_DEPENDENCY(FULLNAME, DEPENDENCY)                               \
+  assert(BT.getCheckerName() != DEPENDENCY &&                                  \
+         "Some checkers depend on this one! We don't allow dependency "        \
+         "checkers to emit warnings, because checkers should depend on "       \
+         "*modeling*, not *diagnostics*.");
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER_DEPENDENCY
+#undef GET_CHECKER_DEPENDENCIES
+  }
 
 public:
   virtual ~BugReport() = default;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to