1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
16 public RecursiveASTVisitor
<CharRightShift
>, public loplugin::Plugin
19 explicit CharRightShift(loplugin::InstantiationData
const & data
):
23 { TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl()); }
25 bool VisitBinShr(BinaryOperator
const * expr
) {
26 if (ignoreLocation(expr
)) {
29 auto t
= expr
->getLHS()->IgnoreParenImpCasts()->getType();
30 if (!loplugin::TypeCheck(t
).Char()) {
33 if (!expr
->getRHS()->getType()->isBuiltinType()) {
34 //TODO: in which case the expression should be an
35 // CXXOperatorCallExpr instead of a BinaryOperator? but at least
36 // recent Clang trunk reports
38 // '(' >> orExpression
40 // (connectivity/source/commontools/RowFunctionParser.cxx, the RHS
41 // being of type boost::spirit::rule<ScannerT>) here
45 DiagnosticsEngine::Warning
,
46 ("right shift of %0 is implementation-defined when 'char' is signed"
47 " and value is negative"),
48 expr
->getLHS()->getExprLoc())
49 << t
<< expr
->getSourceRange();
54 loplugin::Plugin::Registration
<CharRightShift
> X("charrightshift");
58 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */