[PATCH] [clang-tidy] Support for Static Analyzer plugins (clang part)

Gábor Horváth xazax.hun at gmail.com
Thu May 7 05:39:10 PDT 2015


Hi alexfh, klimek, djasper,

This is the clang part of http://reviews.llvm.org/D9555.

http://reviews.llvm.org/D9556

Files:
  include/clang/StaticAnalyzer/Core/CheckerRegistry.h
  include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
  lib/StaticAnalyzer/Core/CheckerRegistry.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp

Index: include/clang/StaticAnalyzer/Core/CheckerRegistry.h
===================================================================
--- include/clang/StaticAnalyzer/Core/CheckerRegistry.h
+++ include/clang/StaticAnalyzer/Core/CheckerRegistry.h
@@ -13,6 +13,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include <vector>
+#include <string>
 
 // FIXME: move this information to an HTML file in docs/.
 // At the very least, a checker plugin is a dynamic library that exports
@@ -122,6 +123,9 @@
   /// This output is not intended to be machine-parseable.
   void printHelp(raw_ostream &out, size_t maxNameChars = 30) const ;
 
+  /// Get the list of every registered checker.
+  std::vector<std::string> getCheckerList() const;
+
 private:
   mutable CheckerInfoList Checkers;
   mutable llvm::StringMap<size_t> Packages;
Index: include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
===================================================================
--- include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
+++ include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
@@ -13,6 +13,7 @@
 #include "clang/Basic/LLVM.h"
 #include <memory>
 #include <string>
+#include <vector>
 
 namespace clang {
   class AnalyzerOptions;
@@ -26,6 +27,7 @@
   createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts,
                        ArrayRef<std::string> plugins, DiagnosticsEngine &diags);
 
+  std::vector<std::string> getCheckerList(ArrayRef<std::string> plugins);
 } // end ento namespace
 
 } // end namespace clang
Index: lib/StaticAnalyzer/Core/CheckerRegistry.cpp
===================================================================
--- lib/StaticAnalyzer/Core/CheckerRegistry.cpp
+++ lib/StaticAnalyzer/Core/CheckerRegistry.cpp
@@ -150,3 +150,14 @@
     out << '\n';
   }
 }
+
+std::vector<std::string> CheckerRegistry::getCheckerList() const {
+  std::vector<std::string> result;
+  std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
+
+  for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end();
+       i != e; ++i) {
+    result.push_back(i->FullName);
+  }
+  return result;
+}
Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===================================================================
--- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -134,3 +134,7 @@
 
   ClangCheckerRegistry(plugins).printHelp(out);
 }
+
+std::vector<std::string> ento::getCheckerList(ArrayRef<std::string> plugins){
+  return ClangCheckerRegistry(plugins).getCheckerList();
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9556.25169.patch
Type: text/x-patch
Size: 2640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150507/584af157/attachment.bin>


More information about the cfe-commits mailing list