bump product version to 6.3.0.0.beta1
[LibreOffice.git] / compilerplugins / clang / charrightshift.cxx
blob6f3027002daa76a96da6a7e8436ec98d49e315d8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef LO_CLANG_SHARED_PLUGINS
12 #include "check.hxx"
13 #include "plugin.hxx"
15 namespace {
17 class CharRightShift:
18 public loplugin::FilteringPlugin<CharRightShift>
20 public:
21 explicit CharRightShift(loplugin::InstantiationData const & data):
22 FilteringPlugin(data) {}
24 void run() override
25 { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
27 bool VisitBinShr(BinaryOperator const * expr) {
28 if (ignoreLocation(expr)) {
29 return true;
31 auto t = expr->getLHS()->IgnoreParenImpCasts()->getType();
32 if (!loplugin::TypeCheck(t).Char()) {
33 return true;
35 if (!expr->getRHS()->getType()->isBuiltinType()) {
36 //TODO: in which case the expression should be an
37 // CXXOperatorCallExpr instead of a BinaryOperator? but at least
38 // recent Clang trunk reports
40 // '(' >> orExpression
42 // (connectivity/source/commontools/RowFunctionParser.cxx, the RHS
43 // being of type boost::spirit::rule<ScannerT>) here
44 return true;
46 report(
47 DiagnosticsEngine::Warning,
48 ("right shift of %0 is implementation-defined when 'char' is signed"
49 " and value is negative"),
50 expr->getLHS()->getExprLoc())
51 << t << expr->getSourceRange();
52 return true;
56 loplugin::Plugin::Registration<CharRightShift> charrightshift("charrightshift");
60 #endif // LO_CLANG_SHARED_PLUGINS
62 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */