summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/overridevirtual.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-16 14:54:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-17 09:56:25 +0200
commit8e3f4317823aa83e0ad9e7dc008a1550ef3c9798 (patch)
treeb4bf7ece126d0b7838cc8d27fc1a081fe5b01abe /compilerplugins/clang/overridevirtual.cxx
parente557bd4eb73ecee802c724c7f7f16ad8b3793bed (diff)
make overrridevirtual a shared plugin
Change-Id: Ied3b772bdd54cb0e8d6214e7a51866364523b83b Reviewed-on: https://gerrit.libreoffice.org/75742 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/overridevirtual.cxx')
-rw-r--r--compilerplugins/clang/overridevirtual.cxx20
1 files changed, 13 insertions, 7 deletions
diff --git a/compilerplugins/clang/overridevirtual.cxx b/compilerplugins/clang/overridevirtual.cxx
index 9b31035d2156..8dd29ab0e426 100644
--- a/compilerplugins/clang/overridevirtual.cxx
+++ b/compilerplugins/clang/overridevirtual.cxx
@@ -6,6 +6,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
#include <algorithm>
#include <cassert>
@@ -26,6 +27,7 @@ public:
explicit OverrideVirtual(loplugin::InstantiationData const & data):
FilteringRewritePlugin(data) {}
+ virtual bool preRun() override;
virtual void run() override;
bool VisitCXXMethodDecl(CXXMethodDecl const * decl);
@@ -34,13 +36,15 @@ private:
std::set<SourceLocation> insertions_;
};
-void OverrideVirtual::run() {
- if (compiler.getLangOpts().CPlusPlus
+bool OverrideVirtual::preRun() {
+ return compiler.getLangOpts().CPlusPlus
&& compiler.getPreprocessor().getIdentifierInfo(
- "LIBO_INTERNAL_ONLY")->hasMacroDefinition())
- {
+ "LIBO_INTERNAL_ONLY")->hasMacroDefinition();
+}
+
+void OverrideVirtual::run() {
+ if (preRun())
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
- }
}
bool OverrideVirtual::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
// As a heuristic, ignore declarations where the name is spelled out in an
@@ -161,8 +165,10 @@ bool OverrideVirtual::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
return true;
}
-loplugin::Plugin::Registration<OverrideVirtual> X("overridevirtual", true);
+loplugin::Plugin::Registration<OverrideVirtual> overridevirtual("overridevirtual");
-}
+} // namespace
+
+#endif // LO_CLANG_SHARED_PLUGINS
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */