summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unicodetochar.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-16 08:13:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-16 09:15:01 +0200
commit8d4fbc532e2058a906b06471501385404ff31541 (patch)
treef6e0116d76e605395bc05444e2eece0574da9ba2 /compilerplugins/clang/unicodetochar.cxx
parent5521ac4e152dc9159ac7f7d86d9d2addef443cf4 (diff)
convert some plugins to LO_CLANG_SHARED_PLUGINS
Change-Id: I7451a95377101004c7c53c918f3234415e06f555 Reviewed-on: https://gerrit.libreoffice.org/75670 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/unicodetochar.cxx')
-rw-r--r--compilerplugins/clang/unicodetochar.cxx52
1 files changed, 42 insertions, 10 deletions
diff --git a/compilerplugins/clang/unicodetochar.cxx b/compilerplugins/clang/unicodetochar.cxx
index e1e381ad2c71..3599d3081a9f 100644
--- a/compilerplugins/clang/unicodetochar.cxx
+++ b/compilerplugins/clang/unicodetochar.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef LO_CLANG_SHARED_PLUGINS
+
#include <stack>
#include "check.hxx"
@@ -24,24 +26,48 @@ public:
explicit UnicodeToChar(loplugin::InstantiationData const & data):
FilteringPlugin(data) {}
- bool TraverseCStyleCastExpr(CStyleCastExpr * expr) {
+ bool PreTraverseCStyleCastExpr(CStyleCastExpr * expr) {
subExprs_.push(expr->getSubExpr());
- bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr(expr);
+ return true;
+ }
+ bool PostTraverseCStyleCastExpr(CStyleCastExpr *, bool ) {
subExprs_.pop();
+ return true;
+ }
+ bool TraverseCStyleCastExpr(CStyleCastExpr * expr) {
+ PreTraverseCStyleCastExpr(expr);
+ bool ret = RecursiveASTVisitor::TraverseCStyleCastExpr(expr);
+ PostTraverseCStyleCastExpr(expr, ret);
return ret;
}
- bool TraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
+ bool PreTraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
subExprs_.push(expr->getSubExpr());
- bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr(expr);
+ return true;
+ }
+ bool PostTraverseCXXStaticCastExpr(CXXStaticCastExpr *, bool) {
subExprs_.pop();
+ return true;
+ }
+ bool TraverseCXXStaticCastExpr(CXXStaticCastExpr * expr) {
+ PreTraverseCXXStaticCastExpr(expr);
+ bool ret = RecursiveASTVisitor::TraverseCXXStaticCastExpr(expr);
+ PostTraverseCXXStaticCastExpr(expr, ret);
return ret;
}
- bool TraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
+ bool PreTraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
subExprs_.push(expr->getSubExpr());
- bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr(expr);
+ return true;
+ }
+ bool PostTraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr *, bool) {
subExprs_.pop();
+ return true;
+ }
+ bool TraverseCXXFunctionalCastExpr(CXXFunctionalCastExpr * expr) {
+ PreTraverseCXXFunctionalCastExpr(expr);
+ bool ret = RecursiveASTVisitor::TraverseCXXFunctionalCastExpr(expr);
+ PostTraverseCXXFunctionalCastExpr(expr, ret);
return ret;
}
@@ -72,18 +98,24 @@ public:
return true;
}
-private:
+ bool preRun() override {
+ return compiler.getLangOpts().CPlusPlus;
+ }
+
void run() override {
- if (compiler.getLangOpts().CPlusPlus) {
+ if (preRun()) {
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
}
+private:
std::stack<Expr const *> subExprs_;
};
-static loplugin::Plugin::Registration<UnicodeToChar> reg("unicodetochar");
+static loplugin::Plugin::Registration<UnicodeToChar> unicodetochar("unicodetochar");
+
+} // namespace
-}
+#endif // LO_CLANG_SHARED_PLUGINS
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */