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(InstantiationData
const & data
): Plugin(data
) {}
21 { TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl()); }
23 bool VisitUnaryDeref(UnaryOperator
const * op
);
26 bool DerefNullPtr::VisitUnaryDeref(UnaryOperator
const * op
) {
27 if (!ignoreLocation(op
)
28 && (op
->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
29 compiler
.getASTContext(), Expr::NPC_ValueDependentIsNotNull
/*TODO*/)
30 != Expr::NPCK_NotNull
))
33 DiagnosticsEngine::Warning
, "null pointer dereference",
35 << op
->getSourceRange();
40 loplugin::Plugin::Registration
<DerefNullPtr
> X("derefnullptr");
44 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */