xref: /llvm-project/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (revision 3d0d2fefc0a18f13e45a17be04a3da8d2b1299f8)
1 //===--- CallAndMessageChecker.cpp ------------------------------*- 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 // This defines CallAndMessageChecker, a builtin checker that checks for various
10 // errors of call and objc message expressions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/ExprCXX.h"
15 #include "clang/AST/ParentMap.h"
16 #include "clang/Basic/TargetInfo.h"
17 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
18 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
19 #include "clang/StaticAnalyzer/Core/Checker.h"
20 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
21 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
22 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
23 #include "llvm/ADT/SmallString.h"
24 #include "llvm/ADT/StringExtras.h"
25 #include "llvm/Support/Casting.h"
26 #include "llvm/Support/raw_ostream.h"
27 
28 using namespace clang;
29 using namespace ento;
30 
31 namespace {
32 
33 class CallAndMessageChecker
34     : public Checker<check::PreObjCMessage, check::ObjCMessageNil,
35                      check::PreCall> {
36   mutable std::unique_ptr<BugType> BT_call_null;
37   mutable std::unique_ptr<BugType> BT_call_undef;
38   mutable std::unique_ptr<BugType> BT_cxx_call_null;
39   mutable std::unique_ptr<BugType> BT_cxx_call_undef;
40   mutable std::unique_ptr<BugType> BT_call_arg;
41   mutable std::unique_ptr<BugType> BT_cxx_delete_undef;
42   mutable std::unique_ptr<BugType> BT_msg_undef;
43   mutable std::unique_ptr<BugType> BT_objc_prop_undef;
44   mutable std::unique_ptr<BugType> BT_objc_subscript_undef;
45   mutable std::unique_ptr<BugType> BT_msg_arg;
46   mutable std::unique_ptr<BugType> BT_msg_ret;
47   mutable std::unique_ptr<BugType> BT_call_few_args;
48 
49 public:
50   enum CheckKind { CK_CallAndMessageUnInitRefArg, CK_NumCheckKinds };
51 
52   DefaultBool ChecksEnabled[CK_NumCheckKinds];
53 
54   void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const;
55 
56   /// Fill in the return value that results from messaging nil based on the
57   /// return type and architecture and diagnose if the return value will be
58   /// garbage.
59   void checkObjCMessageNil(const ObjCMethodCall &msg, CheckerContext &C) const;
60 
61   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
62 
63 private:
64   bool PreVisitProcessArg(CheckerContext &C, SVal V, SourceRange ArgRange,
65                           const Expr *ArgEx, int ArgumentNumber,
66                           bool CheckUninitFields, const CallEvent &Call,
67                           std::unique_ptr<BugType> &BT,
68                           const ParmVarDecl *ParamDecl) const;
69 
70   static void emitBadCall(BugType *BT, CheckerContext &C, const Expr *BadE);
71   void emitNilReceiverBug(CheckerContext &C, const ObjCMethodCall &msg,
72                           ExplodedNode *N) const;
73 
74   void HandleNilReceiver(CheckerContext &C,
75                          ProgramStateRef state,
76                          const ObjCMethodCall &msg) const;
77 
78   void LazyInit_BT(const char *desc, std::unique_ptr<BugType> &BT) const {
79     if (!BT)
80       BT.reset(new BuiltinBug(this, desc));
81   }
82   bool uninitRefOrPointer(CheckerContext &C, const SVal &V,
83                           SourceRange ArgRange, const Expr *ArgEx,
84                           std::unique_ptr<BugType> &BT,
85                           const ParmVarDecl *ParamDecl, const char *BD,
86                           int ArgumentNumber) const;
87 };
88 } // end anonymous namespace
89 
90 void CallAndMessageChecker::emitBadCall(BugType *BT, CheckerContext &C,
91                                         const Expr *BadE) {
92   ExplodedNode *N = C.generateErrorNode();
93   if (!N)
94     return;
95 
96   auto R = std::make_unique<PathSensitiveBugReport>(*BT, BT->getDescription(), N);
97   if (BadE) {
98     R->addRange(BadE->getSourceRange());
99     if (BadE->isGLValue())
100       BadE = bugreporter::getDerefExpr(BadE);
101     bugreporter::trackExpressionValue(N, BadE, *R);
102   }
103   C.emitReport(std::move(R));
104 }
105 
106 static void describeUninitializedArgumentInCall(const CallEvent &Call,
107                                                 int ArgumentNumber,
108                                                 llvm::raw_svector_ostream &Os) {
109   switch (Call.getKind()) {
110   case CE_ObjCMessage: {
111     const ObjCMethodCall &Msg = cast<ObjCMethodCall>(Call);
112     switch (Msg.getMessageKind()) {
113     case OCM_Message:
114       Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
115          << " argument in message expression is an uninitialized value";
116       return;
117     case OCM_PropertyAccess:
118       assert(Msg.isSetter() && "Getters have no args");
119       Os << "Argument for property setter is an uninitialized value";
120       return;
121     case OCM_Subscript:
122       if (Msg.isSetter() && (ArgumentNumber == 0))
123         Os << "Argument for subscript setter is an uninitialized value";
124       else
125         Os << "Subscript index is an uninitialized value";
126       return;
127     }
128     llvm_unreachable("Unknown message kind.");
129   }
130   case CE_Block:
131     Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
132        << " block call argument is an uninitialized value";
133     return;
134   default:
135     Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
136        << " function call argument is an uninitialized value";
137     return;
138   }
139 }
140 
141 bool CallAndMessageChecker::uninitRefOrPointer(
142     CheckerContext &C, const SVal &V, SourceRange ArgRange, const Expr *ArgEx,
143     std::unique_ptr<BugType> &BT, const ParmVarDecl *ParamDecl, const char *BD,
144     int ArgumentNumber) const {
145   if (!ChecksEnabled[CK_CallAndMessageUnInitRefArg])
146     return false;
147 
148   // No parameter declaration available, i.e. variadic function argument.
149   if(!ParamDecl)
150     return false;
151 
152   // If parameter is declared as pointer to const in function declaration,
153   // then check if corresponding argument in function call is
154   // pointing to undefined symbol value (uninitialized memory).
155   SmallString<200> Buf;
156   llvm::raw_svector_ostream Os(Buf);
157 
158   if (ParamDecl->getType()->isPointerType()) {
159     Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
160        << " function call argument is a pointer to uninitialized value";
161   } else if (ParamDecl->getType()->isReferenceType()) {
162     Os << (ArgumentNumber + 1) << llvm::getOrdinalSuffix(ArgumentNumber + 1)
163        << " function call argument is an uninitialized value";
164   } else
165     return false;
166 
167   if(!ParamDecl->getType()->getPointeeType().isConstQualified())
168     return false;
169 
170   if (const MemRegion *SValMemRegion = V.getAsRegion()) {
171     const ProgramStateRef State = C.getState();
172     const SVal PSV = State->getSVal(SValMemRegion, C.getASTContext().CharTy);
173     if (PSV.isUndef()) {
174       if (ExplodedNode *N = C.generateErrorNode()) {
175         LazyInit_BT(BD, BT);
176         auto R = std::make_unique<PathSensitiveBugReport>(*BT, Os.str(), N);
177         R->addRange(ArgRange);
178         if (ArgEx)
179           bugreporter::trackExpressionValue(N, ArgEx, *R);
180 
181         C.emitReport(std::move(R));
182       }
183       return true;
184     }
185   }
186   return false;
187 }
188 
189 namespace {
190 class FindUninitializedField {
191 public:
192   SmallVector<const FieldDecl *, 10> FieldChain;
193 
194 private:
195   StoreManager &StoreMgr;
196   MemRegionManager &MrMgr;
197   Store store;
198 
199 public:
200   FindUninitializedField(StoreManager &storeMgr, MemRegionManager &mrMgr,
201                          Store s)
202       : StoreMgr(storeMgr), MrMgr(mrMgr), store(s) {}
203 
204   bool Find(const TypedValueRegion *R) {
205     QualType T = R->getValueType();
206     if (const RecordType *RT = T->getAsStructureType()) {
207       const RecordDecl *RD = RT->getDecl()->getDefinition();
208       assert(RD && "Referred record has no definition");
209       for (const auto *I : RD->fields()) {
210         const FieldRegion *FR = MrMgr.getFieldRegion(I, R);
211         FieldChain.push_back(I);
212         T = I->getType();
213         if (T->getAsStructureType()) {
214           if (Find(FR))
215             return true;
216         } else {
217           const SVal &V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
218           if (V.isUndef())
219             return true;
220         }
221         FieldChain.pop_back();
222       }
223     }
224 
225     return false;
226   }
227 };
228 } // namespace
229 
230 bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
231                                                SVal V,
232                                                SourceRange ArgRange,
233                                                const Expr *ArgEx,
234                                                int ArgumentNumber,
235                                                bool CheckUninitFields,
236                                                const CallEvent &Call,
237                                                std::unique_ptr<BugType> &BT,
238                                                const ParmVarDecl *ParamDecl
239                                                ) const {
240   const char *BD = "Uninitialized argument value";
241 
242   if (uninitRefOrPointer(C, V, ArgRange, ArgEx, BT, ParamDecl, BD,
243                          ArgumentNumber))
244     return true;
245 
246   if (V.isUndef()) {
247     if (ExplodedNode *N = C.generateErrorNode()) {
248       LazyInit_BT(BD, BT);
249       // Generate a report for this bug.
250       SmallString<200> Buf;
251       llvm::raw_svector_ostream Os(Buf);
252       describeUninitializedArgumentInCall(Call, ArgumentNumber, Os);
253       auto R = std::make_unique<PathSensitiveBugReport>(*BT, Os.str(), N);
254 
255       R->addRange(ArgRange);
256       if (ArgEx)
257         bugreporter::trackExpressionValue(N, ArgEx, *R);
258       C.emitReport(std::move(R));
259     }
260     return true;
261   }
262 
263   if (!CheckUninitFields)
264     return false;
265 
266   if (auto LV = V.getAs<nonloc::LazyCompoundVal>()) {
267     const LazyCompoundValData *D = LV->getCVData();
268     FindUninitializedField F(C.getState()->getStateManager().getStoreManager(),
269                              C.getSValBuilder().getRegionManager(),
270                              D->getStore());
271 
272     if (F.Find(D->getRegion())) {
273       if (ExplodedNode *N = C.generateErrorNode()) {
274         LazyInit_BT(BD, BT);
275         SmallString<512> Str;
276         llvm::raw_svector_ostream os(Str);
277         os << "Passed-by-value struct argument contains uninitialized data";
278 
279         if (F.FieldChain.size() == 1)
280           os << " (e.g., field: '" << *F.FieldChain[0] << "')";
281         else {
282           os << " (e.g., via the field chain: '";
283           bool first = true;
284           for (SmallVectorImpl<const FieldDecl *>::iterator
285                DI = F.FieldChain.begin(), DE = F.FieldChain.end(); DI!=DE;++DI){
286             if (first)
287               first = false;
288             else
289               os << '.';
290             os << **DI;
291           }
292           os << "')";
293         }
294 
295         // Generate a report for this bug.
296         auto R = std::make_unique<PathSensitiveBugReport>(*BT, os.str(), N);
297         R->addRange(ArgRange);
298 
299         if (ArgEx)
300           bugreporter::trackExpressionValue(N, ArgEx, *R);
301         // FIXME: enhance track back for uninitialized value for arbitrary
302         // memregions
303         C.emitReport(std::move(R));
304       }
305       return true;
306     }
307   }
308 
309   return false;
310 }
311 
312 void CallAndMessageChecker::checkPreCall(const CallEvent &Call,
313                                          CheckerContext &C) const {
314   ProgramStateRef State = C.getState();
315   if (const CallExpr *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr())) {
316     const Expr *Callee = CE->getCallee()->IgnoreParens();
317     const LocationContext *LCtx = C.getLocationContext();
318     SVal L = State->getSVal(Callee, LCtx);
319 
320     if (L.isUndef()) {
321       if (!BT_call_undef)
322         BT_call_undef.reset(new BuiltinBug(
323             this, "Called function pointer is an uninitialized pointer value"));
324       emitBadCall(BT_call_undef.get(), C, Callee);
325       return;
326     }
327 
328     ProgramStateRef StNonNull, StNull;
329     std::tie(StNonNull, StNull) =
330         State->assume(L.castAs<DefinedOrUnknownSVal>());
331 
332     if (StNull && !StNonNull) {
333       if (!BT_call_null)
334         BT_call_null.reset(new BuiltinBug(
335             this, "Called function pointer is null (null dereference)"));
336       emitBadCall(BT_call_null.get(), C, Callee);
337       return;
338     }
339 
340     State = StNonNull;
341   }
342 
343   // If this is a call to a C++ method, check if the callee is null or
344   // undefined.
345   if (const CXXInstanceCall *CC = dyn_cast<CXXInstanceCall>(&Call)) {
346     SVal V = CC->getCXXThisVal();
347     if (V.isUndef()) {
348       if (!BT_cxx_call_undef)
349         BT_cxx_call_undef.reset(
350             new BuiltinBug(this, "Called C++ object pointer is uninitialized"));
351       emitBadCall(BT_cxx_call_undef.get(), C, CC->getCXXThisExpr());
352       return;
353     }
354 
355     ProgramStateRef StNonNull, StNull;
356     std::tie(StNonNull, StNull) =
357         State->assume(V.castAs<DefinedOrUnknownSVal>());
358 
359     if (StNull && !StNonNull) {
360       if (!BT_cxx_call_null)
361         BT_cxx_call_null.reset(
362             new BuiltinBug(this, "Called C++ object pointer is null"));
363       emitBadCall(BT_cxx_call_null.get(), C, CC->getCXXThisExpr());
364       return;
365     }
366 
367     State = StNonNull;
368   }
369 
370   const Decl *D = Call.getDecl();
371   if (D && (isa<FunctionDecl>(D) || isa<BlockDecl>(D))) {
372     // If we have a function or block declaration, we can make sure we pass
373     // enough parameters.
374     unsigned Params = Call.parameters().size();
375     if (Call.getNumArgs() < Params) {
376       ExplodedNode *N = C.generateErrorNode();
377       if (!N)
378         return;
379 
380       LazyInit_BT("Function call with too few arguments", BT_call_few_args);
381 
382       SmallString<512> Str;
383       llvm::raw_svector_ostream os(Str);
384       if (isa<FunctionDecl>(D)) {
385         os << "Function ";
386       } else {
387         assert(isa<BlockDecl>(D));
388         os << "Block ";
389       }
390       os << "taking " << Params << " argument"
391          << (Params == 1 ? "" : "s") << " is called with fewer ("
392          << Call.getNumArgs() << ")";
393 
394       C.emitReport(std::make_unique<PathSensitiveBugReport>(*BT_call_few_args,
395                                                             os.str(), N));
396     }
397   }
398 
399   if (const auto *DC = dyn_cast<CXXDeallocatorCall>(&Call)) {
400     const CXXDeleteExpr *DE = DC->getOriginExpr();
401     assert(DE);
402     SVal Arg = C.getSVal(DE->getArgument());
403     if (Arg.isUndef()) {
404       StringRef Desc;
405       ExplodedNode *N = C.generateErrorNode();
406       if (!N)
407         return;
408       if (!BT_cxx_delete_undef)
409         BT_cxx_delete_undef.reset(
410             new BuiltinBug(this, "Uninitialized argument value"));
411       if (DE->isArrayFormAsWritten())
412         Desc = "Argument to 'delete[]' is uninitialized";
413       else
414         Desc = "Argument to 'delete' is uninitialized";
415       BugType *BT = BT_cxx_delete_undef.get();
416       auto R = std::make_unique<PathSensitiveBugReport>(*BT, Desc, N);
417       bugreporter::trackExpressionValue(N, DE, *R);
418       C.emitReport(std::move(R));
419       return;
420     }
421   }
422 
423   // Don't check for uninitialized field values in arguments if the
424   // caller has a body that is available and we have the chance to inline it.
425   // This is a hack, but is a reasonable compromise betweens sometimes warning
426   // and sometimes not depending on if we decide to inline a function.
427   const bool checkUninitFields =
428     !(C.getAnalysisManager().shouldInlineCall() && (D && D->getBody()));
429 
430   std::unique_ptr<BugType> *BT;
431   if (isa<ObjCMethodCall>(Call))
432     BT = &BT_msg_arg;
433   else
434     BT = &BT_call_arg;
435 
436   const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
437   for (unsigned i = 0, e = Call.getNumArgs(); i != e; ++i) {
438     const ParmVarDecl *ParamDecl = nullptr;
439     if(FD && i < FD->getNumParams())
440       ParamDecl = FD->getParamDecl(i);
441     if (PreVisitProcessArg(C, Call.getArgSVal(i), Call.getArgSourceRange(i),
442                            Call.getArgExpr(i), i, checkUninitFields, Call, *BT,
443                            ParamDecl))
444       return;
445   }
446 
447   // If we make it here, record our assumptions about the callee.
448   C.addTransition(State);
449 }
450 
451 void CallAndMessageChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
452                                                 CheckerContext &C) const {
453   SVal recVal = msg.getReceiverSVal();
454   if (recVal.isUndef()) {
455     if (ExplodedNode *N = C.generateErrorNode()) {
456       BugType *BT = nullptr;
457       switch (msg.getMessageKind()) {
458       case OCM_Message:
459         if (!BT_msg_undef)
460           BT_msg_undef.reset(new BuiltinBug(this,
461                                             "Receiver in message expression "
462                                             "is an uninitialized value"));
463         BT = BT_msg_undef.get();
464         break;
465       case OCM_PropertyAccess:
466         if (!BT_objc_prop_undef)
467           BT_objc_prop_undef.reset(new BuiltinBug(
468               this, "Property access on an uninitialized object pointer"));
469         BT = BT_objc_prop_undef.get();
470         break;
471       case OCM_Subscript:
472         if (!BT_objc_subscript_undef)
473           BT_objc_subscript_undef.reset(new BuiltinBug(
474               this, "Subscript access on an uninitialized object pointer"));
475         BT = BT_objc_subscript_undef.get();
476         break;
477       }
478       assert(BT && "Unknown message kind.");
479 
480       auto R = std::make_unique<PathSensitiveBugReport>(*BT, BT->getDescription(), N);
481       const ObjCMessageExpr *ME = msg.getOriginExpr();
482       R->addRange(ME->getReceiverRange());
483 
484       // FIXME: getTrackNullOrUndefValueVisitor can't handle "super" yet.
485       if (const Expr *ReceiverE = ME->getInstanceReceiver())
486         bugreporter::trackExpressionValue(N, ReceiverE, *R);
487       C.emitReport(std::move(R));
488     }
489     return;
490   }
491 }
492 
493 void CallAndMessageChecker::checkObjCMessageNil(const ObjCMethodCall &msg,
494                                                 CheckerContext &C) const {
495   HandleNilReceiver(C, C.getState(), msg);
496 }
497 
498 void CallAndMessageChecker::emitNilReceiverBug(CheckerContext &C,
499                                                const ObjCMethodCall &msg,
500                                                ExplodedNode *N) const {
501 
502   if (!BT_msg_ret)
503     BT_msg_ret.reset(
504         new BuiltinBug(this, "Receiver in message expression is 'nil'"));
505 
506   const ObjCMessageExpr *ME = msg.getOriginExpr();
507 
508   QualType ResTy = msg.getResultType();
509 
510   SmallString<200> buf;
511   llvm::raw_svector_ostream os(buf);
512   os << "The receiver of message '";
513   ME->getSelector().print(os);
514   os << "' is nil";
515   if (ResTy->isReferenceType()) {
516     os << ", which results in forming a null reference";
517   } else {
518     os << " and returns a value of type '";
519     msg.getResultType().print(os, C.getLangOpts());
520     os << "' that will be garbage";
521   }
522 
523   auto report =
524       std::make_unique<PathSensitiveBugReport>(*BT_msg_ret, os.str(), N);
525   report->addRange(ME->getReceiverRange());
526   // FIXME: This won't track "self" in messages to super.
527   if (const Expr *receiver = ME->getInstanceReceiver()) {
528     bugreporter::trackExpressionValue(N, receiver, *report);
529   }
530   C.emitReport(std::move(report));
531 }
532 
533 static bool supportsNilWithFloatRet(const llvm::Triple &triple) {
534   return (triple.getVendor() == llvm::Triple::Apple &&
535           (triple.isiOS() || triple.isWatchOS() ||
536            !triple.isMacOSXVersionLT(10,5)));
537 }
538 
539 void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
540                                               ProgramStateRef state,
541                                               const ObjCMethodCall &Msg) const {
542   ASTContext &Ctx = C.getASTContext();
543   static CheckerProgramPointTag Tag(this, "NilReceiver");
544 
545   // Check the return type of the message expression.  A message to nil will
546   // return different values depending on the return type and the architecture.
547   QualType RetTy = Msg.getResultType();
548   CanQualType CanRetTy = Ctx.getCanonicalType(RetTy);
549   const LocationContext *LCtx = C.getLocationContext();
550 
551   if (CanRetTy->isStructureOrClassType()) {
552     // Structure returns are safe since the compiler zeroes them out.
553     SVal V = C.getSValBuilder().makeZeroVal(RetTy);
554     C.addTransition(state->BindExpr(Msg.getOriginExpr(), LCtx, V), &Tag);
555     return;
556   }
557 
558   // Other cases: check if sizeof(return type) > sizeof(void*)
559   if (CanRetTy != Ctx.VoidTy && C.getLocationContext()->getParentMap()
560                                   .isConsumedExpr(Msg.getOriginExpr())) {
561     // Compute: sizeof(void *) and sizeof(return type)
562     const uint64_t voidPtrSize = Ctx.getTypeSize(Ctx.VoidPtrTy);
563     const uint64_t returnTypeSize = Ctx.getTypeSize(CanRetTy);
564 
565     if (CanRetTy.getTypePtr()->isReferenceType()||
566         (voidPtrSize < returnTypeSize &&
567          !(supportsNilWithFloatRet(Ctx.getTargetInfo().getTriple()) &&
568            (Ctx.FloatTy == CanRetTy ||
569             Ctx.DoubleTy == CanRetTy ||
570             Ctx.LongDoubleTy == CanRetTy ||
571             Ctx.LongLongTy == CanRetTy ||
572             Ctx.UnsignedLongLongTy == CanRetTy)))) {
573       if (ExplodedNode *N = C.generateErrorNode(state, &Tag))
574         emitNilReceiverBug(C, Msg, N);
575       return;
576     }
577 
578     // Handle the safe cases where the return value is 0 if the
579     // receiver is nil.
580     //
581     // FIXME: For now take the conservative approach that we only
582     // return null values if we *know* that the receiver is nil.
583     // This is because we can have surprises like:
584     //
585     //   ... = [[NSScreens screens] objectAtIndex:0];
586     //
587     // What can happen is that [... screens] could return nil, but
588     // it most likely isn't nil.  We should assume the semantics
589     // of this case unless we have *a lot* more knowledge.
590     //
591     SVal V = C.getSValBuilder().makeZeroVal(RetTy);
592     C.addTransition(state->BindExpr(Msg.getOriginExpr(), LCtx, V), &Tag);
593     return;
594   }
595 
596   C.addTransition(state);
597 }
598 
599 void ento::registerCallAndMessageChecker(CheckerManager &mgr) {
600   mgr.registerChecker<CallAndMessageChecker>();
601 }
602 
603 bool ento::shouldRegisterCallAndMessageChecker(const CheckerManager &mgr) {
604   return true;
605 }
606 
607 #define REGISTER_CHECKER(name)                                                 \
608   void ento::register##name(CheckerManager &mgr) {                             \
609     CallAndMessageChecker *checker = mgr.getChecker<CallAndMessageChecker>();  \
610     checker->ChecksEnabled[CallAndMessageChecker::CK_##name] = true;           \
611                                                                                \
612   }                                                                            \
613                                                                                \
614   bool ento::shouldRegister##name(const CheckerManager &mgr) { return true; }
615 
616 REGISTER_CHECKER(CallAndMessageUnInitRefArg)
617