diff options
Diffstat (limited to 'compilerplugins/clang/unsignedcompare.cxx')
-rw-r--r-- | compilerplugins/clang/unsignedcompare.cxx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/compilerplugins/clang/unsignedcompare.cxx b/compilerplugins/clang/unsignedcompare.cxx index 7337f45223d4..5b55edea2843 100644 --- a/compilerplugins/clang/unsignedcompare.cxx +++ b/compilerplugins/clang/unsignedcompare.cxx @@ -7,15 +7,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef LO_CLANG_SHARED_PLUGINS + // Find explicit casts from signed to unsigned integer in comparison against unsigned integer, where // the cast is presumably used to avoid warnings about signed vs. unsigned comparisons, and could // thus be replaced with o3tl::make_unsigned for clarity. #include <cassert> -#include "config_clang.h" - -#include "compat.hxx" #include "plugin.hxx" namespace @@ -126,9 +125,7 @@ public: // be, so lets keep it here at least for now): switch (expr->getOpcode()) { -#if CLANG_VERSION >= 60000 case BO_Cmp: -#endif case BO_LT: case BO_GT: case BO_LE: @@ -163,7 +160,6 @@ public: return true; } -private: bool preRun() override { return compiler.getLangOpts().CPlusPlus @@ -180,6 +176,7 @@ private: } } +private: ExplicitCastExpr const* isCastToUnsigned(Expr const* expr) { auto const e = dyn_cast<ExplicitCastExpr>(expr->IgnoreParenImpCasts()); @@ -201,7 +198,7 @@ private: // Filter out e.g. `size_t(-1)`: if (!e2->isValueDependent()) { - if (auto const val = compat::getIntegerConstantExpr(e2, compiler.getASTContext())) + if (auto const val = e2->getIntegerConstantExpr(compiler.getASTContext())) { if (val->isNegative()) { @@ -209,7 +206,7 @@ private: } } } - auto loc = compat::getBeginLoc(e); + auto loc = e->getBeginLoc(); while (compiler.getSourceManager().isMacroArgExpansion(loc)) { loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); @@ -230,4 +227,6 @@ private: loplugin::Plugin::Registration<UnsignedCompare> unsignedcompare("unsignedcompare"); } +#endif // LO_CLANG_SHARED_PLUGINS + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |