diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-12-22 11:02:29 +0000 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-12-22 11:02:29 +0000 |
commit | d594ec359afce1fd6ee68f9bfbba30a75d8306cb (patch) | |
tree | af4e07649e2eb4f07acb4f2a3924dbd2dd6ab534 /clang-plugin | |
parent | 2b4bc24677474e24ddf7668ec0fe39ad1c6f6622 (diff) |
plugin: Hoist the GIR manager to be a global
It was previously local to the Plugin instance. However, it needs to be
shared between path-sensitive and path-insensitive checkers, which have
different APIs. Path-sensitive checkers cannot be instantiated with any
custom constructor arguments, so need to use a global GIR manager.
Diffstat (limited to 'clang-plugin')
-rw-r--r-- | clang-plugin/checker.h | 2 | ||||
-rw-r--r-- | clang-plugin/plugin.cpp | 29 |
2 files changed, 17 insertions, 14 deletions
diff --git a/clang-plugin/checker.h b/clang-plugin/checker.h index b9dfaf7..faea4fa 100644 --- a/clang-plugin/checker.h +++ b/clang-plugin/checker.h @@ -37,6 +37,8 @@ namespace tartan { using namespace clang; +extern std::shared_ptr<GirManager> global_gir_manager; + class Checker { public: virtual const std::string get_name () const = 0; diff --git a/clang-plugin/plugin.cpp b/clang-plugin/plugin.cpp index 329fd66..ad9acda 100644 --- a/clang-plugin/plugin.cpp +++ b/clang-plugin/plugin.cpp @@ -42,14 +42,15 @@ using namespace clang; namespace tartan { +/* Global GIR manager shared between AST and path-sensitive checkers. */ +std::shared_ptr<GirManager> global_gir_manager = + std::make_shared<GirManager> (); + /** * Plugin core. */ class TartanAction : public PluginASTAction { private: - std::shared_ptr<GirManager> _gir_manager = - std::make_shared<GirManager> (); - /* Enabling/Disabling checkers is implemented as a blacklist: all * checkers are enabled by default, unless a --disable-checker argument * specifically disables them (by listing their name in this set). */ @@ -76,26 +77,26 @@ protected: /* Annotaters. */ consumers.push_back (std::unique_ptr<ASTConsumer> ( - new GirAttributesConsumer (this->_gir_manager))); + new GirAttributesConsumer (global_gir_manager))); consumers.push_back (std::unique_ptr<ASTConsumer> ( new GAssertAttributesConsumer ())); /* Checkers. */ consumers.push_back (std::unique_ptr<ASTConsumer> ( new NullabilityConsumer (compiler, - this->_gir_manager, + global_gir_manager, this->_disabled_checkers))); consumers.push_back (std::unique_ptr<ASTConsumer> ( new GVariantConsumer (compiler, - this->_gir_manager, + global_gir_manager, this->_disabled_checkers))); consumers.push_back (std::unique_ptr<ASTConsumer> ( new GSignalConsumer (compiler, - this->_gir_manager, + global_gir_manager, this->_disabled_checkers))); consumers.push_back (std::unique_ptr<ASTConsumer> ( new GirAttributesChecker (compiler, - this->_gir_manager, + global_gir_manager, this->_disabled_checkers))); return llvm::make_unique<MultiplexConsumer> (std::move (consumers)); @@ -108,26 +109,26 @@ protected: /* Annotaters. */ consumers.push_back ( - new GirAttributesConsumer (this->_gir_manager)); + new GirAttributesConsumer (global_gir_manager)); consumers.push_back ( new GAssertAttributesConsumer ()); /* Checkers. */ consumers.push_back ( new NullabilityConsumer (compiler, - this->_gir_manager, + global_gir_manager, this->_disabled_checkers)); consumers.push_back ( new GVariantConsumer (compiler, - this->_gir_manager, + global_gir_manager, this->_disabled_checkers)); consumers.push_back ( new GSignalConsumer (compiler, - this->_gir_manager, + global_gir_manager, this->_disabled_checkers)); consumers.push_back ( new GirAttributesChecker (compiler, - this->_gir_manager, + global_gir_manager, this->_disabled_checkers)); return new MultiplexConsumer (consumers); @@ -156,7 +157,7 @@ private: /* Load the repository. */ GError *error = NULL; - this->_gir_manager.get ()->load_namespace (gi_namespace, + global_gir_manager.get ()->load_namespace (gi_namespace, gi_version, &error); if (error != NULL && |