1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
15 public RecursiveASTVisitor
<DerefNullPtr
>, public loplugin::Plugin
18 explicit DerefNullPtr(loplugin::InstantiationData
const & data
):
22 { TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl()); }
24 bool VisitUnaryDeref(UnaryOperator
const * op
);
27 bool DerefNullPtr::VisitUnaryDeref(UnaryOperator
const * op
) {
28 if (!ignoreLocation(op
)
29 && (op
->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
30 compiler
.getASTContext(), Expr::NPC_ValueDependentIsNotNull
/*TODO*/)
31 != Expr::NPCK_NotNull
))
34 DiagnosticsEngine::Warning
, "null pointer dereference",
36 << op
->getSourceRange();
41 loplugin::Plugin::Registration
<DerefNullPtr
> X("derefnullptr");
45 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */