xref: /freebsd/contrib/llvm-project/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h (revision 0eae32dcef82f6f06de6419a0d623d7def0cc8f6)
15ffd83dbSDimitry Andric //=== SmartPtr.h - Tracking smart pointer state. -------------------*- C++ -*-//
25ffd83dbSDimitry Andric //
35ffd83dbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45ffd83dbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55ffd83dbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65ffd83dbSDimitry Andric //
75ffd83dbSDimitry Andric //===----------------------------------------------------------------------===//
85ffd83dbSDimitry Andric //
95ffd83dbSDimitry Andric // Defines inter-checker API for the smart pointer modeling. It allows
105ffd83dbSDimitry Andric // dependent checkers to figure out if an smart pointer is null or not.
115ffd83dbSDimitry Andric //
125ffd83dbSDimitry Andric //===----------------------------------------------------------------------===//
135ffd83dbSDimitry Andric 
145ffd83dbSDimitry Andric #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H
155ffd83dbSDimitry Andric #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H
165ffd83dbSDimitry Andric 
175ffd83dbSDimitry Andric #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
185ffd83dbSDimitry Andric 
195ffd83dbSDimitry Andric namespace clang {
205ffd83dbSDimitry Andric namespace ento {
215ffd83dbSDimitry Andric namespace smartptr {
225ffd83dbSDimitry Andric 
235ffd83dbSDimitry Andric /// Returns true if the event call is on smart pointer.
245ffd83dbSDimitry Andric bool isStdSmartPtrCall(const CallEvent &Call);
25*fe6060f1SDimitry Andric bool isStdSmartPtr(const CXXRecordDecl *RD);
26*fe6060f1SDimitry Andric bool isStdSmartPtr(const Expr *E);
27*fe6060f1SDimitry Andric 
285ffd83dbSDimitry Andric /// Returns whether the smart pointer is null or not.
295ffd83dbSDimitry Andric bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion);
305ffd83dbSDimitry Andric 
31e8d8bef9SDimitry Andric const BugType *getNullDereferenceBugType();
32e8d8bef9SDimitry Andric 
335ffd83dbSDimitry Andric } // namespace smartptr
345ffd83dbSDimitry Andric } // namespace ento
355ffd83dbSDimitry Andric } // namespace clang
365ffd83dbSDimitry Andric 
375ffd83dbSDimitry Andric #endif // LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H
38