[cfe-dev] Checker Plugins

Jordy Rose jediknil at belkadan.com
Wed Jul 27 13:48:54 PDT 2011


Okay, I've come up with a naming-based version of this, probably not final but working fairly well. The plugin client's job is fairly simple:

using clang::ento::CheckerInfo;
extern "C" clang_getCheckersForPackage_PACKAGE (CheckerInfo::List &out) {
  // First include checkers from subpackages.
  clang_getCheckersForPackage_SUBPACKAGE1(out);
  clang_getCheckersForPackage_SUBPACKAGE2(out);
  CheckerInfo::markAllSubpackage(out);

  // Then add checkers from this package.
  out.push_back(CheckerInfo::create<MyChecker>("MyChecker",
    "short description"));
  // The name of the checker class does not have to match the name the
  // client uses to enable your checker.
  out.push_back(CheckerInfo::create<MyOtherChecker>("OtherChecker",
    "short description"));
  // "Hidden" checkers are only enabled if they or their package is
  // explicitly requested, not if they are in a subpackage.
  out.push_back(CheckerInfo::create<HiddenChecker>("HiddenChecker",
    "short description", true));
}

The use of a clang_getCheckersForPackage_PACKAGE function means that we could eventually migrate all internal checkers to this format as well.

The main thing that this doesn't handle is that -analyzer-checker-help doesn't know what packages a plugin might have, so it just uses the basename of the plugin you're loading. The next step would be to look for a clang_checkerPackages_PLUGIN array that contains the names of any packages in PLUGIN.dylib. (Or maybe libPLUGIN.dylib.)

Where should I be going with this?
Jordy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CheckerPlugins.3.patch
Type: application/octet-stream
Size: 23745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110727/fa9f7c89/attachment.obj>
-------------- next part --------------



More information about the cfe-dev mailing list