xref: /freebsd/contrib/llvm-project/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
10b57cec5SDimitry Andric //===-- DereferenceChecker.cpp - Null dereference checker -----------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This defines NullDerefChecker, a builtin check in ExprEngine that performs
100b57cec5SDimitry Andric // checks for null pointers at loads and stores.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #include "clang/AST/ExprObjC.h"
150b57cec5SDimitry Andric #include "clang/AST/ExprOpenMP.h"
16*81ad6265SDimitry Andric #include "clang/Basic/TargetInfo.h"
17*81ad6265SDimitry Andric #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
180b57cec5SDimitry Andric #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
190b57cec5SDimitry Andric #include "clang/StaticAnalyzer/Core/Checker.h"
200b57cec5SDimitry Andric #include "clang/StaticAnalyzer/Core/CheckerManager.h"
210b57cec5SDimitry Andric #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
220b57cec5SDimitry Andric #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
230b57cec5SDimitry Andric #include "llvm/ADT/SmallString.h"
240b57cec5SDimitry Andric #include "llvm/Support/raw_ostream.h"
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric using namespace clang;
270b57cec5SDimitry Andric using namespace ento;
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric namespace {
300b57cec5SDimitry Andric class DereferenceChecker
310b57cec5SDimitry Andric     : public Checker< check::Location,
320b57cec5SDimitry Andric                       check::Bind,
330b57cec5SDimitry Andric                       EventDispatcher<ImplicitNullDerefEvent> > {
34e8d8bef9SDimitry Andric   enum DerefKind { NullPointer, UndefinedPointerValue };
350b57cec5SDimitry Andric 
36e8d8bef9SDimitry Andric   BugType BT_Null{this, "Dereference of null pointer", categories::LogicError};
37e8d8bef9SDimitry Andric   BugType BT_Undef{this, "Dereference of undefined pointer value",
38e8d8bef9SDimitry Andric                    categories::LogicError};
39e8d8bef9SDimitry Andric 
40e8d8bef9SDimitry Andric   void reportBug(DerefKind K, ProgramStateRef State, const Stmt *S,
41e8d8bef9SDimitry Andric                  CheckerContext &C) const;
420b57cec5SDimitry Andric 
43*81ad6265SDimitry Andric   bool suppressReport(CheckerContext &C, const Expr *E) const;
44*81ad6265SDimitry Andric 
450b57cec5SDimitry Andric public:
460b57cec5SDimitry Andric   void checkLocation(SVal location, bool isLoad, const Stmt* S,
470b57cec5SDimitry Andric                      CheckerContext &C) const;
480b57cec5SDimitry Andric   void checkBind(SVal L, SVal V, const Stmt *S, CheckerContext &C) const;
490b57cec5SDimitry Andric 
500b57cec5SDimitry Andric   static void AddDerefSource(raw_ostream &os,
510b57cec5SDimitry Andric                              SmallVectorImpl<SourceRange> &Ranges,
520b57cec5SDimitry Andric                              const Expr *Ex, const ProgramState *state,
530b57cec5SDimitry Andric                              const LocationContext *LCtx,
540b57cec5SDimitry Andric                              bool loadedFrom = false);
55*81ad6265SDimitry Andric 
56*81ad6265SDimitry Andric   bool SuppressAddressSpaces = false;
570b57cec5SDimitry Andric };
580b57cec5SDimitry Andric } // end anonymous namespace
590b57cec5SDimitry Andric 
600b57cec5SDimitry Andric void
610b57cec5SDimitry Andric DereferenceChecker::AddDerefSource(raw_ostream &os,
620b57cec5SDimitry Andric                                    SmallVectorImpl<SourceRange> &Ranges,
630b57cec5SDimitry Andric                                    const Expr *Ex,
640b57cec5SDimitry Andric                                    const ProgramState *state,
650b57cec5SDimitry Andric                                    const LocationContext *LCtx,
660b57cec5SDimitry Andric                                    bool loadedFrom) {
670b57cec5SDimitry Andric   Ex = Ex->IgnoreParenLValueCasts();
680b57cec5SDimitry Andric   switch (Ex->getStmtClass()) {
690b57cec5SDimitry Andric     default:
700b57cec5SDimitry Andric       break;
710b57cec5SDimitry Andric     case Stmt::DeclRefExprClass: {
720b57cec5SDimitry Andric       const DeclRefExpr *DR = cast<DeclRefExpr>(Ex);
730b57cec5SDimitry Andric       if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
740b57cec5SDimitry Andric         os << " (" << (loadedFrom ? "loaded from" : "from")
750b57cec5SDimitry Andric            << " variable '" <<  VD->getName() << "')";
760b57cec5SDimitry Andric         Ranges.push_back(DR->getSourceRange());
770b57cec5SDimitry Andric       }
780b57cec5SDimitry Andric       break;
790b57cec5SDimitry Andric     }
800b57cec5SDimitry Andric     case Stmt::MemberExprClass: {
810b57cec5SDimitry Andric       const MemberExpr *ME = cast<MemberExpr>(Ex);
820b57cec5SDimitry Andric       os << " (" << (loadedFrom ? "loaded from" : "via")
830b57cec5SDimitry Andric          << " field '" << ME->getMemberNameInfo() << "')";
840b57cec5SDimitry Andric       SourceLocation L = ME->getMemberLoc();
850b57cec5SDimitry Andric       Ranges.push_back(SourceRange(L, L));
860b57cec5SDimitry Andric       break;
870b57cec5SDimitry Andric     }
880b57cec5SDimitry Andric     case Stmt::ObjCIvarRefExprClass: {
890b57cec5SDimitry Andric       const ObjCIvarRefExpr *IV = cast<ObjCIvarRefExpr>(Ex);
900b57cec5SDimitry Andric       os << " (" << (loadedFrom ? "loaded from" : "via")
910b57cec5SDimitry Andric          << " ivar '" << IV->getDecl()->getName() << "')";
920b57cec5SDimitry Andric       SourceLocation L = IV->getLocation();
930b57cec5SDimitry Andric       Ranges.push_back(SourceRange(L, L));
940b57cec5SDimitry Andric       break;
950b57cec5SDimitry Andric     }
960b57cec5SDimitry Andric   }
970b57cec5SDimitry Andric }
980b57cec5SDimitry Andric 
990b57cec5SDimitry Andric static const Expr *getDereferenceExpr(const Stmt *S, bool IsBind=false){
1000b57cec5SDimitry Andric   const Expr *E = nullptr;
1010b57cec5SDimitry Andric 
1020b57cec5SDimitry Andric   // Walk through lvalue casts to get the original expression
1030b57cec5SDimitry Andric   // that syntactically caused the load.
1040b57cec5SDimitry Andric   if (const Expr *expr = dyn_cast<Expr>(S))
1050b57cec5SDimitry Andric     E = expr->IgnoreParenLValueCasts();
1060b57cec5SDimitry Andric 
1070b57cec5SDimitry Andric   if (IsBind) {
1080b57cec5SDimitry Andric     const VarDecl *VD;
1090b57cec5SDimitry Andric     const Expr *Init;
1100b57cec5SDimitry Andric     std::tie(VD, Init) = parseAssignment(S);
1110b57cec5SDimitry Andric     if (VD && Init)
1120b57cec5SDimitry Andric       E = Init;
1130b57cec5SDimitry Andric   }
1140b57cec5SDimitry Andric   return E;
1150b57cec5SDimitry Andric }
1160b57cec5SDimitry Andric 
117*81ad6265SDimitry Andric bool DereferenceChecker::suppressReport(CheckerContext &C,
118*81ad6265SDimitry Andric                                         const Expr *E) const {
119*81ad6265SDimitry Andric   // Do not report dereferences on memory that use address space #256, #257,
120*81ad6265SDimitry Andric   // and #258. Those address spaces are used when dereferencing address spaces
121*81ad6265SDimitry Andric   // relative to the GS, FS, and SS segments on x86/x86-64 targets.
122*81ad6265SDimitry Andric   // Dereferencing a null pointer in these address spaces is not defined
123*81ad6265SDimitry Andric   // as an error. All other null dereferences in other address spaces
124*81ad6265SDimitry Andric   // are defined as an error unless explicitly defined.
125*81ad6265SDimitry Andric   // See https://clang.llvm.org/docs/LanguageExtensions.html, the section
126*81ad6265SDimitry Andric   // "X86/X86-64 Language Extensions"
127*81ad6265SDimitry Andric 
128*81ad6265SDimitry Andric   QualType Ty = E->getType();
129*81ad6265SDimitry Andric   if (!Ty.hasAddressSpace())
130*81ad6265SDimitry Andric     return false;
131*81ad6265SDimitry Andric   if (SuppressAddressSpaces)
132*81ad6265SDimitry Andric     return true;
133*81ad6265SDimitry Andric 
134*81ad6265SDimitry Andric   const llvm::Triple::ArchType Arch =
135*81ad6265SDimitry Andric       C.getASTContext().getTargetInfo().getTriple().getArch();
136*81ad6265SDimitry Andric 
137*81ad6265SDimitry Andric   if ((Arch == llvm::Triple::x86) || (Arch == llvm::Triple::x86_64)) {
138*81ad6265SDimitry Andric     switch (toTargetAddressSpace(E->getType().getAddressSpace())) {
139*81ad6265SDimitry Andric     case 256:
140*81ad6265SDimitry Andric     case 257:
141*81ad6265SDimitry Andric     case 258:
142*81ad6265SDimitry Andric       return true;
143*81ad6265SDimitry Andric     }
144*81ad6265SDimitry Andric   }
145*81ad6265SDimitry Andric   return false;
1460b57cec5SDimitry Andric }
1470b57cec5SDimitry Andric 
1480b57cec5SDimitry Andric static bool isDeclRefExprToReference(const Expr *E) {
1490b57cec5SDimitry Andric   if (const auto *DRE = dyn_cast<DeclRefExpr>(E))
1500b57cec5SDimitry Andric     return DRE->getDecl()->getType()->isReferenceType();
1510b57cec5SDimitry Andric   return false;
1520b57cec5SDimitry Andric }
1530b57cec5SDimitry Andric 
154e8d8bef9SDimitry Andric void DereferenceChecker::reportBug(DerefKind K, ProgramStateRef State,
155e8d8bef9SDimitry Andric                                    const Stmt *S, CheckerContext &C) const {
156e8d8bef9SDimitry Andric   const BugType *BT = nullptr;
157e8d8bef9SDimitry Andric   llvm::StringRef DerefStr1;
158e8d8bef9SDimitry Andric   llvm::StringRef DerefStr2;
159e8d8bef9SDimitry Andric   switch (K) {
160e8d8bef9SDimitry Andric   case DerefKind::NullPointer:
161e8d8bef9SDimitry Andric     BT = &BT_Null;
162e8d8bef9SDimitry Andric     DerefStr1 = " results in a null pointer dereference";
163e8d8bef9SDimitry Andric     DerefStr2 = " results in a dereference of a null pointer";
164e8d8bef9SDimitry Andric     break;
165e8d8bef9SDimitry Andric   case DerefKind::UndefinedPointerValue:
166e8d8bef9SDimitry Andric     BT = &BT_Undef;
167e8d8bef9SDimitry Andric     DerefStr1 = " results in an undefined pointer dereference";
168e8d8bef9SDimitry Andric     DerefStr2 = " results in a dereference of an undefined pointer value";
169e8d8bef9SDimitry Andric     break;
170e8d8bef9SDimitry Andric   };
171e8d8bef9SDimitry Andric 
1720b57cec5SDimitry Andric   // Generate an error node.
1730b57cec5SDimitry Andric   ExplodedNode *N = C.generateErrorNode(State);
1740b57cec5SDimitry Andric   if (!N)
1750b57cec5SDimitry Andric     return;
1760b57cec5SDimitry Andric 
1770b57cec5SDimitry Andric   SmallString<100> buf;
1780b57cec5SDimitry Andric   llvm::raw_svector_ostream os(buf);
1790b57cec5SDimitry Andric 
1800b57cec5SDimitry Andric   SmallVector<SourceRange, 2> Ranges;
1810b57cec5SDimitry Andric 
1820b57cec5SDimitry Andric   switch (S->getStmtClass()) {
1830b57cec5SDimitry Andric   case Stmt::ArraySubscriptExprClass: {
1840b57cec5SDimitry Andric     os << "Array access";
1850b57cec5SDimitry Andric     const ArraySubscriptExpr *AE = cast<ArraySubscriptExpr>(S);
1860b57cec5SDimitry Andric     AddDerefSource(os, Ranges, AE->getBase()->IgnoreParenCasts(),
1870b57cec5SDimitry Andric                    State.get(), N->getLocationContext());
188e8d8bef9SDimitry Andric     os << DerefStr1;
1890b57cec5SDimitry Andric     break;
1900b57cec5SDimitry Andric   }
1910b57cec5SDimitry Andric   case Stmt::OMPArraySectionExprClass: {
1920b57cec5SDimitry Andric     os << "Array access";
1930b57cec5SDimitry Andric     const OMPArraySectionExpr *AE = cast<OMPArraySectionExpr>(S);
1940b57cec5SDimitry Andric     AddDerefSource(os, Ranges, AE->getBase()->IgnoreParenCasts(),
1950b57cec5SDimitry Andric                    State.get(), N->getLocationContext());
196e8d8bef9SDimitry Andric     os << DerefStr1;
1970b57cec5SDimitry Andric     break;
1980b57cec5SDimitry Andric   }
1990b57cec5SDimitry Andric   case Stmt::UnaryOperatorClass: {
200e8d8bef9SDimitry Andric     os << BT->getDescription();
2010b57cec5SDimitry Andric     const UnaryOperator *U = cast<UnaryOperator>(S);
2020b57cec5SDimitry Andric     AddDerefSource(os, Ranges, U->getSubExpr()->IgnoreParens(),
2030b57cec5SDimitry Andric                    State.get(), N->getLocationContext(), true);
2040b57cec5SDimitry Andric     break;
2050b57cec5SDimitry Andric   }
2060b57cec5SDimitry Andric   case Stmt::MemberExprClass: {
2070b57cec5SDimitry Andric     const MemberExpr *M = cast<MemberExpr>(S);
2080b57cec5SDimitry Andric     if (M->isArrow() || isDeclRefExprToReference(M->getBase())) {
209e8d8bef9SDimitry Andric       os << "Access to field '" << M->getMemberNameInfo() << "'" << DerefStr2;
2100b57cec5SDimitry Andric       AddDerefSource(os, Ranges, M->getBase()->IgnoreParenCasts(),
2110b57cec5SDimitry Andric                      State.get(), N->getLocationContext(), true);
2120b57cec5SDimitry Andric     }
2130b57cec5SDimitry Andric     break;
2140b57cec5SDimitry Andric   }
2150b57cec5SDimitry Andric   case Stmt::ObjCIvarRefExprClass: {
2160b57cec5SDimitry Andric     const ObjCIvarRefExpr *IV = cast<ObjCIvarRefExpr>(S);
217e8d8bef9SDimitry Andric     os << "Access to instance variable '" << *IV->getDecl() << "'" << DerefStr2;
2180b57cec5SDimitry Andric     AddDerefSource(os, Ranges, IV->getBase()->IgnoreParenCasts(),
2190b57cec5SDimitry Andric                    State.get(), N->getLocationContext(), true);
2200b57cec5SDimitry Andric     break;
2210b57cec5SDimitry Andric   }
2220b57cec5SDimitry Andric   default:
2230b57cec5SDimitry Andric     break;
2240b57cec5SDimitry Andric   }
2250b57cec5SDimitry Andric 
226a7dea167SDimitry Andric   auto report = std::make_unique<PathSensitiveBugReport>(
227fe6060f1SDimitry Andric       *BT, buf.empty() ? BT->getDescription() : buf.str(), N);
2280b57cec5SDimitry Andric 
2290b57cec5SDimitry Andric   bugreporter::trackExpressionValue(N, bugreporter::getDerefExpr(S), *report);
2300b57cec5SDimitry Andric 
2310b57cec5SDimitry Andric   for (SmallVectorImpl<SourceRange>::iterator
2320b57cec5SDimitry Andric        I = Ranges.begin(), E = Ranges.end(); I!=E; ++I)
2330b57cec5SDimitry Andric     report->addRange(*I);
2340b57cec5SDimitry Andric 
2350b57cec5SDimitry Andric   C.emitReport(std::move(report));
2360b57cec5SDimitry Andric }
2370b57cec5SDimitry Andric 
2380b57cec5SDimitry Andric void DereferenceChecker::checkLocation(SVal l, bool isLoad, const Stmt* S,
2390b57cec5SDimitry Andric                                        CheckerContext &C) const {
2400b57cec5SDimitry Andric   // Check for dereference of an undefined value.
2410b57cec5SDimitry Andric   if (l.isUndef()) {
242e8d8bef9SDimitry Andric     const Expr *DerefExpr = getDereferenceExpr(S);
243*81ad6265SDimitry Andric     if (!suppressReport(C, DerefExpr))
244e8d8bef9SDimitry Andric       reportBug(DerefKind::UndefinedPointerValue, C.getState(), DerefExpr, C);
2450b57cec5SDimitry Andric     return;
2460b57cec5SDimitry Andric   }
2470b57cec5SDimitry Andric 
2480b57cec5SDimitry Andric   DefinedOrUnknownSVal location = l.castAs<DefinedOrUnknownSVal>();
2490b57cec5SDimitry Andric 
2500b57cec5SDimitry Andric   // Check for null dereferences.
251*81ad6265SDimitry Andric   if (!isa<Loc>(location))
2520b57cec5SDimitry Andric     return;
2530b57cec5SDimitry Andric 
2540b57cec5SDimitry Andric   ProgramStateRef state = C.getState();
2550b57cec5SDimitry Andric 
2560b57cec5SDimitry Andric   ProgramStateRef notNullState, nullState;
2570b57cec5SDimitry Andric   std::tie(notNullState, nullState) = state->assume(location);
2580b57cec5SDimitry Andric 
2590b57cec5SDimitry Andric   if (nullState) {
2600b57cec5SDimitry Andric     if (!notNullState) {
261e8d8bef9SDimitry Andric       // We know that 'location' can only be null.  This is what
262e8d8bef9SDimitry Andric       // we call an "explicit" null dereference.
2630b57cec5SDimitry Andric       const Expr *expr = getDereferenceExpr(S);
264*81ad6265SDimitry Andric       if (!suppressReport(C, expr)) {
265e8d8bef9SDimitry Andric         reportBug(DerefKind::NullPointer, nullState, expr, C);
2660b57cec5SDimitry Andric         return;
2670b57cec5SDimitry Andric       }
2680b57cec5SDimitry Andric     }
2690b57cec5SDimitry Andric 
2700b57cec5SDimitry Andric     // Otherwise, we have the case where the location could either be
2710b57cec5SDimitry Andric     // null or not-null.  Record the error node as an "implicit" null
2720b57cec5SDimitry Andric     // dereference.
2730b57cec5SDimitry Andric     if (ExplodedNode *N = C.generateSink(nullState, C.getPredecessor())) {
2740b57cec5SDimitry Andric       ImplicitNullDerefEvent event = {l, isLoad, N, &C.getBugReporter(),
2750b57cec5SDimitry Andric                                       /*IsDirectDereference=*/true};
2760b57cec5SDimitry Andric       dispatchEvent(event);
2770b57cec5SDimitry Andric     }
2780b57cec5SDimitry Andric   }
2790b57cec5SDimitry Andric 
2800b57cec5SDimitry Andric   // From this point forward, we know that the location is not null.
2810b57cec5SDimitry Andric   C.addTransition(notNullState);
2820b57cec5SDimitry Andric }
2830b57cec5SDimitry Andric 
2840b57cec5SDimitry Andric void DereferenceChecker::checkBind(SVal L, SVal V, const Stmt *S,
2850b57cec5SDimitry Andric                                    CheckerContext &C) const {
2860b57cec5SDimitry Andric   // If we're binding to a reference, check if the value is known to be null.
2870b57cec5SDimitry Andric   if (V.isUndef())
2880b57cec5SDimitry Andric     return;
2890b57cec5SDimitry Andric 
2900b57cec5SDimitry Andric   const MemRegion *MR = L.getAsRegion();
2910b57cec5SDimitry Andric   const TypedValueRegion *TVR = dyn_cast_or_null<TypedValueRegion>(MR);
2920b57cec5SDimitry Andric   if (!TVR)
2930b57cec5SDimitry Andric     return;
2940b57cec5SDimitry Andric 
2950b57cec5SDimitry Andric   if (!TVR->getValueType()->isReferenceType())
2960b57cec5SDimitry Andric     return;
2970b57cec5SDimitry Andric 
2980b57cec5SDimitry Andric   ProgramStateRef State = C.getState();
2990b57cec5SDimitry Andric 
3000b57cec5SDimitry Andric   ProgramStateRef StNonNull, StNull;
3010b57cec5SDimitry Andric   std::tie(StNonNull, StNull) = State->assume(V.castAs<DefinedOrUnknownSVal>());
3020b57cec5SDimitry Andric 
3030b57cec5SDimitry Andric   if (StNull) {
3040b57cec5SDimitry Andric     if (!StNonNull) {
3050b57cec5SDimitry Andric       const Expr *expr = getDereferenceExpr(S, /*IsBind=*/true);
306*81ad6265SDimitry Andric       if (!suppressReport(C, expr)) {
307e8d8bef9SDimitry Andric         reportBug(DerefKind::NullPointer, StNull, expr, C);
3080b57cec5SDimitry Andric         return;
3090b57cec5SDimitry Andric       }
3100b57cec5SDimitry Andric     }
3110b57cec5SDimitry Andric 
3120b57cec5SDimitry Andric     // At this point the value could be either null or non-null.
3130b57cec5SDimitry Andric     // Record this as an "implicit" null dereference.
3140b57cec5SDimitry Andric     if (ExplodedNode *N = C.generateSink(StNull, C.getPredecessor())) {
3150b57cec5SDimitry Andric       ImplicitNullDerefEvent event = {V, /*isLoad=*/true, N,
3160b57cec5SDimitry Andric                                       &C.getBugReporter(),
3170b57cec5SDimitry Andric                                       /*IsDirectDereference=*/true};
3180b57cec5SDimitry Andric       dispatchEvent(event);
3190b57cec5SDimitry Andric     }
3200b57cec5SDimitry Andric   }
3210b57cec5SDimitry Andric 
3220b57cec5SDimitry Andric   // Unlike a regular null dereference, initializing a reference with a
3230b57cec5SDimitry Andric   // dereferenced null pointer does not actually cause a runtime exception in
3240b57cec5SDimitry Andric   // Clang's implementation of references.
3250b57cec5SDimitry Andric   //
3260b57cec5SDimitry Andric   //   int &r = *p; // safe??
3270b57cec5SDimitry Andric   //   if (p != NULL) return; // uh-oh
3280b57cec5SDimitry Andric   //   r = 5; // trap here
3290b57cec5SDimitry Andric   //
3300b57cec5SDimitry Andric   // The standard says this is invalid as soon as we try to create a "null
3310b57cec5SDimitry Andric   // reference" (there is no such thing), but turning this into an assumption
3320b57cec5SDimitry Andric   // that 'p' is never null will not match our actual runtime behavior.
3330b57cec5SDimitry Andric   // So we do not record this assumption, allowing us to warn on the last line
3340b57cec5SDimitry Andric   // of this example.
3350b57cec5SDimitry Andric   //
3360b57cec5SDimitry Andric   // We do need to add a transition because we may have generated a sink for
3370b57cec5SDimitry Andric   // the "implicit" null dereference.
3380b57cec5SDimitry Andric   C.addTransition(State, this);
3390b57cec5SDimitry Andric }
3400b57cec5SDimitry Andric 
3410b57cec5SDimitry Andric void ento::registerDereferenceChecker(CheckerManager &mgr) {
342*81ad6265SDimitry Andric   auto *Chk = mgr.registerChecker<DereferenceChecker>();
343*81ad6265SDimitry Andric   Chk->SuppressAddressSpaces = mgr.getAnalyzerOptions().getCheckerBooleanOption(
344*81ad6265SDimitry Andric       mgr.getCurrentCheckerName(), "SuppressAddressSpaces");
3450b57cec5SDimitry Andric }
3460b57cec5SDimitry Andric 
3475ffd83dbSDimitry Andric bool ento::shouldRegisterDereferenceChecker(const CheckerManager &mgr) {
3480b57cec5SDimitry Andric   return true;
3490b57cec5SDimitry Andric }
350