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 VisitUnaryDeref(UnaryOperator
const * op
);
29 bool DerefNullPtr::VisitUnaryDeref(UnaryOperator
const * op
) {
30 if (!ignoreLocation(op
)
31 && (op
->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
32 compiler
.getASTContext(), Expr::NPC_ValueDependentIsNotNull
/*TODO*/)
33 != Expr::NPCK_NotNull
))
36 DiagnosticsEngine::Warning
, "null pointer dereference",
37 compat::getBeginLoc(op
))
38 << op
->getSourceRange();
43 loplugin::Plugin::Registration
<DerefNullPtr
> derefnullptr("derefnullptr");
47 #endif // LO_CLANG_SHARED_PLUGINS
49 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */