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/.
10 #ifndef LO_CLANG_SHARED_PLUGINS
17 public loplugin::FilteringPlugin
<DerefNullPtr
>
20 explicit DerefNullPtr(loplugin::InstantiationData
const & data
):
21 FilteringPlugin(data
) {}
24 { TraverseDecl(compiler
.getASTContext().getTranslationUnitDecl()); }
26 bool VisitUnaryOperator(UnaryOperator
const * op
);
29 bool DerefNullPtr::VisitUnaryOperator(UnaryOperator
const * op
) {
30 if (op
->getOpcode() != UO_Deref
) {
33 if (!ignoreLocation(op
)
34 && (op
->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
35 compiler
.getASTContext(), Expr::NPC_ValueDependentIsNotNull
/*TODO*/)
36 != Expr::NPCK_NotNull
))
39 DiagnosticsEngine::Warning
, "null pointer dereference",
41 << op
->getSourceRange();
46 loplugin::Plugin::Registration
<DerefNullPtr
> derefnullptr("derefnullptr");
50 #endif // LO_CLANG_SHARED_PLUGINS
52 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */