SmartPtr.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //=== SmartPtr.h - Tracking smart pointer state. -------------------*- C++ -*-//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // Defines inter-checker API for the smart pointer modeling. It allows
  10. // dependent checkers to figure out if an smart pointer is null or not.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H
  14. #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H
  15. #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
  16. namespace clang {
  17. namespace ento {
  18. namespace smartptr {
  19. /// Returns true if the event call is on smart pointer.
  20. bool isStdSmartPtrCall(const CallEvent &Call);
  21. bool isStdSmartPtr(const CXXRecordDecl *RD);
  22. bool isStdSmartPtr(const Expr *E);
  23. /// Returns whether the smart pointer is null or not.
  24. bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion);
  25. const BugType *getNullDereferenceBugType();
  26. } // namespace smartptr
  27. } // namespace ento
  28. } // namespace clang
  29. #endif // LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H