clang 24.0.0git
CheckerManager.cpp
Go to the documentation of this file.
1//===- CheckerManager.cpp - Static Analyzer Checker Manager ---------------===//
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 the Static Analyzer Checker Manager.
10//
11//===----------------------------------------------------------------------===//
12
14#include "clang/AST/DeclBase.h"
15#include "clang/AST/Stmt.h"
18#include "clang/Basic/LLVM.h"
26#include "llvm/ADT/STLExtras.h"
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/Support/ErrorHandling.h"
29#include "llvm/Support/FormatVariadic.h"
30#include "llvm/Support/TimeProfiler.h"
31#include <cassert>
32#include <optional>
33#include <vector>
34
35using namespace clang;
36using namespace ento;
37
39 const auto IfAnyAreNonEmpty = [](const auto &...Callbacks) -> bool {
40 return (!Callbacks.empty() || ...);
41 };
42 return IfAnyAreNonEmpty(
43 StmtCheckers, PreObjCMessageCheckers, ObjCMessageNilCheckers,
44 PostObjCMessageCheckers, PreCallCheckers, PostCallCheckers,
45 LifetimeEndCheckers, LocationCheckers, BindCheckers,
46 BlockEntranceCheckers, EndAnalysisCheckers, BeginFunctionCheckers,
47 EndFunctionCheckers, BranchConditionCheckers, NewAllocatorCheckers,
48 LiveSymbolsCheckers, DeadSymbolsCheckers, RegionChangesCheckers,
49 PointerEscapeCheckers, EvalAssumeCheckers, EvalCallCheckers,
50 EndOfTranslationUnitCheckers);
51}
52
54 const CheckerFrontend *Checker, StringRef OptionName,
55 StringRef ExpectedValueDesc) const {
56
57 getDiagnostics().Report(diag::err_analyzer_checker_option_invalid_input)
58 << (llvm::Twine(Checker->getName()) + ":" + OptionName).str()
59 << ExpectedValueDesc;
60}
61
62//===----------------------------------------------------------------------===//
63// Functions for running checkers for AST traversing..
64//===----------------------------------------------------------------------===//
65
67 BugReporter &BR) {
68 assert(D);
69
70 unsigned DeclKind = D->getKind();
71 auto [CCI, Inserted] = CachedDeclCheckersMap.try_emplace(DeclKind);
72 CachedDeclCheckers *checkers = &(CCI->second);
73 if (Inserted) {
74 // Find the checkers that should run for this Decl and cache them.
75 for (const auto &info : DeclCheckers)
76 if (info.IsForDeclFn(D))
77 checkers->push_back(info.CheckFn);
78 }
79
80 assert(checkers);
81 for (const auto &checker : *checkers)
82 checker(D, mgr, BR);
83}
84
86 BugReporter &BR) {
87 assert(D && D->hasBody());
88
89 for (const auto &BodyChecker : BodyCheckers)
90 BodyChecker(D, mgr, BR);
91}
92
93//===----------------------------------------------------------------------===//
94// Functions for running checkers for path-sensitive checking.
95//===----------------------------------------------------------------------===//
96
97template <typename CHECK_CTX>
98static void expandGraphWithCheckers(CHECK_CTX checkCtx, ExplodedNodeSet &Dst,
99 const ExplodedNodeSet &Src) {
100 if (Src.empty())
101 return;
102
103 typename CHECK_CTX::CheckersTy::const_iterator
104 I = checkCtx.checkers_begin(), E = checkCtx.checkers_end();
105 if (I == E) {
106 Dst.insert(Src);
107 return;
108 }
109
110 ExplodedNodeSet Tmp1, Tmp2;
111 const ExplodedNodeSet *PrevSet = &Src;
112
113 for (; I != E; ++I) {
114 ExplodedNodeSet *CurrSet = nullptr;
115 if (I+1 == E)
116 CurrSet = &Dst;
117 else {
118 CurrSet = (PrevSet == &Tmp1) ? &Tmp2 : &Tmp1;
119 CurrSet->clear();
120 }
121
122 CurrSet->insert(*PrevSet);
123 for (const auto &NI : *PrevSet)
124 checkCtx.runChecker(*I, NI, *CurrSet);
125
126 // If all the produced transitions are sinks, stop.
127 if (CurrSet->empty())
128 return;
129
130 // Update which NodeSet is the current one.
131 PrevSet = CurrSet;
132 }
133}
134
135namespace {
136
137/// A time trace scope that only exists when -ftime-trace is enabled.
138using CheckerTimeTraceScope = std::optional<llvm::TimeTraceScope>;
139
140template <typename... ArgTys>
141CheckerTimeTraceScope timeTraceScope(const CheckerManager &Mgr,
142 ArgTys &&...Args) {
143 if (!Mgr.isTimeTraceEnabled())
144 return std::nullopt;
145 return CheckerTimeTraceScope(std::in_place, std::forward<ArgTys>(Args)...);
146}
147
148/// Like timeTraceScope, but names the scope after the checker. The name is
149/// only built when -ftime-trace is enabled, because getDebugTag is virtual.
150CheckerTimeTraceScope checkerTimeTraceScope(const ExprEngine &Eng,
151 StringRef Name,
152 const CheckerBackend *Checker) {
154 return std::nullopt;
155 StringRef CheckerTag = Checker ? Checker->getDebugTag() : "<unknown>";
156 return CheckerTimeTraceScope(std::in_place, (Name + ":" + CheckerTag).str());
157}
158
159 struct CheckStmtContext {
160 using CheckersTy = SmallVectorImpl<CheckerManager::CheckStmtFunc>;
161
162 bool IsPreVisit;
163 const CheckersTy &Checkers;
164 const Stmt *S;
165 ExprEngine &Eng;
166 bool WasInlined;
167
168 CheckStmtContext(bool isPreVisit, const CheckersTy &checkers,
169 const Stmt *s, ExprEngine &eng, bool wasInlined = false)
170 : IsPreVisit(isPreVisit), Checkers(checkers), S(s), Eng(eng),
171 WasInlined(wasInlined) {}
172
173 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
174 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
175
176 void runChecker(CheckerManager::CheckStmtFunc checkFn, ExplodedNode *Pred,
177 ExplodedNodeSet &Dst) {
178 auto TimeScope = checkerTimeTraceScope(Eng, "Stmt", checkFn.Checker);
179 // FIXME: Remove respondsToCallback from CheckerContext;
183 S, K, Pred->getStackFrame(), checkFn.Checker);
184 CheckerContext C(Eng, Pred, Dst, L, WasInlined);
185 checkFn(S, C);
186 }
187 };
188
189} // namespace
190
191/// Run checkers for visiting Stmts.
193 ExplodedNodeSet &Dst,
194 const ExplodedNodeSet &Src,
195 const Stmt *S,
196 ExprEngine &Eng,
197 bool WasInlined) {
198 CheckStmtContext C(isPreVisit, getCachedStmtCheckersFor(S, isPreVisit),
199 S, Eng, WasInlined);
200 auto TimeScope = timeTraceScope(
201 *this, isPreVisit ? "CheckerManager::runCheckersForStmt (Pre)"
202 : "CheckerManager::runCheckersForStmt (Post)");
203 expandGraphWithCheckers(C, Dst, Src);
204}
205
206namespace {
207
208 struct CheckObjCMessageContext {
209 using CheckersTy = std::vector<CheckerManager::CheckObjCMessageFunc>;
210
212 bool WasInlined;
213 const CheckersTy &Checkers;
214 const ObjCMethodCall &Msg;
215 ExprEngine &Eng;
216
217 CheckObjCMessageContext(ObjCMessageVisitKind visitKind,
218 const CheckersTy &checkers,
219 const ObjCMethodCall &msg, ExprEngine &eng,
220 bool wasInlined)
221 : Kind(visitKind), WasInlined(wasInlined), Checkers(checkers), Msg(msg),
222 Eng(eng) {}
223
224 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
225 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
226
227 void runChecker(CheckerManager::CheckObjCMessageFunc checkFn,
228 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
229 auto TimeScope = checkerTimeTraceScope(Eng, "ObjCMsg", checkFn.Checker);
230 bool IsPreVisit;
231
232 switch (Kind) {
233 case ObjCMessageVisitKind::Pre:
234 IsPreVisit = true;
235 break;
236 case ObjCMessageVisitKind::MessageNil:
237 case ObjCMessageVisitKind::Post:
238 IsPreVisit = false;
239 break;
240 }
241
242 const ProgramPoint &L = Msg.getProgramPoint(IsPreVisit,checkFn.Checker);
243 CheckerContext C(Eng, Pred, Dst, L, WasInlined);
244
245 checkFn(*Msg.cloneWithState<ObjCMethodCall>(Pred->getState()), C);
246 }
247 };
248
249} // namespace
250
251/// Run checkers for visiting obj-c messages.
253 ExplodedNodeSet &Dst,
254 const ExplodedNodeSet &Src,
255 const ObjCMethodCall &msg,
256 ExprEngine &Eng,
257 bool WasInlined) {
258 const auto &checkers = getObjCMessageCheckers(visitKind);
259 CheckObjCMessageContext C(visitKind, checkers, msg, Eng, WasInlined);
260 auto TimeScope =
261 timeTraceScope(*this, "CheckerManager::runCheckersForObjCMessage");
262 expandGraphWithCheckers(C, Dst, Src);
263}
264
265const std::vector<CheckerManager::CheckObjCMessageFunc> &
266CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) const {
267 switch (Kind) {
269 return PreObjCMessageCheckers;
270 break;
272 return PostObjCMessageCheckers;
274 return ObjCMessageNilCheckers;
275 }
276 llvm_unreachable("Unknown Kind");
277}
278
279namespace {
280
281 // FIXME: This has all the same signatures as CheckObjCMessageContext.
282 // Is there a way we can merge the two?
283 struct CheckCallContext {
284 using CheckersTy = std::vector<CheckerManager::CheckCallFunc>;
285
286 bool IsPreVisit, WasInlined;
287 const CheckersTy &Checkers;
288 const CallEvent &Call;
289 ExprEngine &Eng;
290
291 CheckCallContext(bool isPreVisit, const CheckersTy &checkers,
292 const CallEvent &call, ExprEngine &eng,
293 bool wasInlined)
294 : IsPreVisit(isPreVisit), WasInlined(wasInlined), Checkers(checkers),
295 Call(call), Eng(eng) {}
296
297 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
298 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
299
300 void runChecker(CheckerManager::CheckCallFunc checkFn, ExplodedNode *Pred,
301 ExplodedNodeSet &Dst) {
302 auto TimeScope = checkerTimeTraceScope(Eng, "Call", checkFn.Checker);
303 const ProgramPoint &L = Call.getProgramPoint(IsPreVisit,checkFn.Checker);
304 CheckerContext C(Eng, Pred, Dst, L, WasInlined);
305
306 checkFn(*Call.cloneWithState(Pred->getState()), C);
307 }
308 };
309
310} // namespace
311
312/// Run checkers for visiting an abstract call event.
314 ExplodedNodeSet &Dst,
315 const ExplodedNodeSet &Src,
316 const CallEvent &Call,
317 ExprEngine &Eng,
318 bool WasInlined) {
319 CheckCallContext C(isPreVisit,
320 isPreVisit ? PreCallCheckers
321 : PostCallCheckers,
322 Call, Eng, WasInlined);
323 auto TimeScope = timeTraceScope(
324 *this, isPreVisit ? "CheckerManager::runCheckersForCallEvent (Pre)"
325 : "CheckerManager::runCheckersForCallEvent (Post)");
326 expandGraphWithCheckers(C, Dst, Src);
327}
328
329namespace {
330
331struct CheckLifetimeEndContext {
332 using CheckersTy = std::vector<CheckerManager::CheckLifetimeEndFunc>;
333
334 const CheckersTy &Checkers;
335 const VarDecl *Decl;
336 ExprEngine &Eng;
337
338 CheckLifetimeEndContext(const CheckersTy &checkers, const VarDecl *decl,
339 ExprEngine &eng)
340 : Checkers(checkers), Decl(decl), Eng(eng) {}
341
342 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
343 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
344
345 void runChecker(CheckerManager::CheckLifetimeEndFunc checkFn,
346 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
347 assert(Pred->getLocation().getAs<LifetimeEnd>().has_value());
348 const ProgramPoint L = Pred->getLocation().withTag(checkFn.Checker);
349 CheckerContext C(Eng, Pred, Dst, L);
350 checkFn(Decl, C);
351 }
352};
353
354} // namespace
355
356/// Run checkers for end of variable lifetime
358 const ExplodedNodeSet &Src,
359 const VarDecl *Decl,
360 ExprEngine &Eng) {
361 auto TimeScope =
362 timeTraceScope(*this, "CheckerManager::runCheckersForLifetimeEnd");
363 CheckLifetimeEndContext C(LifetimeEndCheckers, Decl, Eng);
364 expandGraphWithCheckers(C, Dst, Src);
365}
366
367namespace {
368
369 struct CheckLocationContext {
370 using CheckersTy = std::vector<CheckerManager::CheckLocationFunc>;
371
372 const CheckersTy &Checkers;
373 SVal Loc;
374 bool IsLoad;
375 const Stmt *NodeEx; /* Will become a CFGStmt */
376 const Stmt *BoundEx;
377 ExprEngine &Eng;
378
379 CheckLocationContext(const CheckersTy &checkers,
380 SVal loc, bool isLoad, const Stmt *NodeEx,
381 const Stmt *BoundEx,
382 ExprEngine &eng)
383 : Checkers(checkers), Loc(loc), IsLoad(isLoad), NodeEx(NodeEx),
384 BoundEx(BoundEx), Eng(eng) {}
385
386 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
387 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
388
389 void runChecker(CheckerManager::CheckLocationFunc checkFn,
390 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
391 auto TimeScope = checkerTimeTraceScope(Eng, "Loc", checkFn.Checker);
395 NodeEx, K, Pred->getStackFrame(), checkFn.Checker);
396 CheckerContext C(Eng, Pred, Dst, L);
397 checkFn(Loc, IsLoad, BoundEx, C);
398 }
399 };
400
401} // namespace
402
403/// Run checkers for load/store of a location.
404
406 const ExplodedNodeSet &Src,
407 SVal location, bool isLoad,
408 const Stmt *NodeEx,
409 const Stmt *BoundEx,
410 ExprEngine &Eng) {
411 CheckLocationContext C(LocationCheckers, location, isLoad, NodeEx,
412 BoundEx, Eng);
413 auto TimeScope = timeTraceScope(
414 *this, isLoad ? "CheckerManager::runCheckersForLocation (Load)"
415 : "CheckerManager::runCheckersForLocation (Store)");
416 expandGraphWithCheckers(C, Dst, Src);
417}
418
419namespace {
420
421 struct CheckBindContext {
422 using CheckersTy = std::vector<CheckerManager::CheckBindFunc>;
423
424 const CheckersTy &Checkers;
425 SVal Loc;
426 SVal Val;
427 const Stmt *S;
428 ExprEngine &Eng;
429 const ProgramPoint &PP;
430 bool AtDeclInit;
431
432 CheckBindContext(const CheckersTy &checkers, SVal loc, SVal val,
433 const Stmt *s, bool AtDeclInit, ExprEngine &eng,
434 const ProgramPoint &pp)
435 : Checkers(checkers), Loc(loc), Val(val), S(s), Eng(eng), PP(pp),
436 AtDeclInit(AtDeclInit) {}
437
438 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
439 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
440
441 void runChecker(CheckerManager::CheckBindFunc checkFn, ExplodedNode *Pred,
442 ExplodedNodeSet &Dst) {
443 auto TimeScope = checkerTimeTraceScope(Eng, "Bind", checkFn.Checker);
444 const ProgramPoint &L = PP.withTag(checkFn.Checker);
445 CheckerContext C(Eng, Pred, Dst, L);
446
447 checkFn(Loc, Val, S, AtDeclInit, C);
448 }
449 };
450
451 llvm::TimeTraceMetadata getTimeTraceBindMetadata(SVal Val) {
452 assert(llvm::timeTraceProfilerEnabled());
453 std::string Name;
454 llvm::raw_string_ostream OS(Name);
455 Val.dumpToStream(OS);
456 return llvm::TimeTraceMetadata{OS.str(), ""};
457 }
458
459} // namespace
460
461/// Run checkers for binding of a value to a location.
463 const ExplodedNodeSet &Src,
464 SVal location, SVal val, const Stmt *S,
465 bool AtDeclInit, ExprEngine &Eng,
466 const ProgramPoint &PP) {
467 CheckBindContext C(BindCheckers, location, val, S, AtDeclInit, Eng, PP);
468 auto TimeScope =
469 timeTraceScope(*this, "CheckerManager::runCheckersForBind",
470 [&val]() { return getTimeTraceBindMetadata(val); });
471 expandGraphWithCheckers(C, Dst, Src);
472}
473
474namespace {
475struct CheckBlockEntranceContext {
476 using CheckBlockEntranceFunc = CheckerManager::CheckBlockEntranceFunc;
477 using CheckersTy = std::vector<CheckBlockEntranceFunc>;
478
479 const CheckersTy &Checkers;
480 const BlockEntrance &Entrance;
481 ExprEngine &Eng;
482
483 CheckBlockEntranceContext(const CheckersTy &Checkers,
484 const BlockEntrance &Entrance, ExprEngine &Eng)
485 : Checkers(Checkers), Entrance(Entrance), Eng(Eng) {}
486
487 auto checkers_begin() const { return Checkers.begin(); }
488 auto checkers_end() const { return Checkers.end(); }
489
490 void runChecker(CheckBlockEntranceFunc CheckFn, ExplodedNode *Pred,
491 ExplodedNodeSet &Dst) {
492 auto TimeScope =
493 checkerTimeTraceScope(Eng, "BlockEntrance", CheckFn.Checker);
494 CheckerContext C(Eng, Pred, Dst, Entrance.withTag(CheckFn.Checker));
495 CheckFn(Entrance, C);
496 }
497};
498
499} // namespace
500
502 const ExplodedNodeSet &Src,
503 const BlockEntrance &Entrance,
504 ExprEngine &Eng) const {
505 CheckBlockEntranceContext C(BlockEntranceCheckers, Entrance, Eng);
506 auto TimeScope =
507 timeTraceScope(*this, "CheckerManager::runCheckersForBlockEntrance");
508 expandGraphWithCheckers(C, Dst, Src);
509}
510
512 BugReporter &BR,
513 ExprEngine &Eng) {
514 for (const auto &EndAnalysisChecker : EndAnalysisCheckers)
515 EndAnalysisChecker(G, BR, Eng);
516}
517
518namespace {
519
520struct CheckBeginFunctionContext {
521 using CheckersTy = std::vector<CheckerManager::CheckBeginFunctionFunc>;
522
523 const CheckersTy &Checkers;
524 ExprEngine &Eng;
525 const ProgramPoint &PP;
526
527 CheckBeginFunctionContext(const CheckersTy &Checkers, ExprEngine &Eng,
528 const ProgramPoint &PP)
529 : Checkers(Checkers), Eng(Eng), PP(PP) {}
530
531 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
532 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
533
534 void runChecker(CheckerManager::CheckBeginFunctionFunc checkFn,
535 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
536 auto TimeScope = checkerTimeTraceScope(Eng, "Begin", checkFn.Checker);
537 const ProgramPoint &L = PP.withTag(checkFn.Checker);
538 CheckerContext C(Eng, Pred, Dst, L);
539
540 checkFn(C);
541 }
542};
543
544} // namespace
545
547 const BlockEdge &L,
548 ExplodedNode *Pred,
549 ExprEngine &Eng) {
550 ExplodedNodeSet Src;
551 Src.insert(Pred);
552 CheckBeginFunctionContext C(BeginFunctionCheckers, Eng, L);
553 auto TimeScope =
554 timeTraceScope(*this, "CheckerManager::runCheckersForBeginFunction");
555 expandGraphWithCheckers(C, Dst, Src);
556}
557
558namespace {
559
560struct CheckEndFunctionContext {
561 using CheckersTy = std::vector<CheckerManager::CheckEndFunctionFunc>;
562
563 const CheckersTy &Checkers;
564 const ReturnStmt *RS;
565 ExprEngine &Eng;
566
567 CheckEndFunctionContext(const CheckersTy &Checkers, const ReturnStmt *RS,
568 ExprEngine &Eng)
569 : Checkers(Checkers), RS(RS), Eng(Eng) {}
570
571 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
572 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
573
574 void runChecker(CheckerManager::CheckEndFunctionFunc checkFn,
575 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
576 auto TimeScope = checkerTimeTraceScope(Eng, "End", checkFn.Checker);
577 const ProgramPoint &L =
578 FunctionExitPoint(RS, Pred->getStackFrame(), checkFn.Checker);
579 CheckerContext C(Eng, Pred, Dst, L);
580
581 checkFn(RS, C);
582 }
583};
584
585} // namespace
586
587/// Run checkers for end of a function (either the entrypoint or another
588/// function that was inlined).
590 ExplodedNode *Pred,
591 ExprEngine &Eng,
592 const ReturnStmt *RS) {
593 ExplodedNodeSet Src;
594 Src.insert(Pred);
595 CheckEndFunctionContext C(EndFunctionCheckers, RS, Eng);
596 auto TimeScope =
597 timeTraceScope(*this, "CheckerManager::runCheckersForEndFunction");
598 expandGraphWithCheckers(C, Dst, Src);
599}
600
601namespace {
602
603 struct CheckBranchConditionContext {
604 using CheckersTy = std::vector<CheckerManager::CheckBranchConditionFunc>;
605
606 const CheckersTy &Checkers;
607 const Stmt *Condition;
608 ExprEngine &Eng;
609
610 CheckBranchConditionContext(const CheckersTy &checkers,
611 const Stmt *Cond, ExprEngine &eng)
612 : Checkers(checkers), Condition(Cond), Eng(eng) {}
613
614 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
615 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
616
617 void runChecker(CheckerManager::CheckBranchConditionFunc checkFn,
618 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
619 auto TimeScope =
620 checkerTimeTraceScope(Eng, "BranchCond", checkFn.Checker);
621 ProgramPoint L =
622 PostCondition(Condition, Pred->getStackFrame(), checkFn.Checker);
623 CheckerContext C(Eng, Pred, Dst, L);
624 checkFn(Condition, C);
625 }
626 };
627
628} // namespace
629
630/// Run checkers for branch condition.
632 ExplodedNodeSet &Dst,
633 ExplodedNode *Pred,
634 ExprEngine &Eng) {
635 ExplodedNodeSet Src;
636 Src.insert(Pred);
637 CheckBranchConditionContext C(BranchConditionCheckers, Condition, Eng);
638 auto TimeScope =
639 timeTraceScope(*this, "CheckerManager::runCheckersForBranchCondition");
640 expandGraphWithCheckers(C, Dst, Src);
641}
642
643namespace {
644
645 struct CheckNewAllocatorContext {
646 using CheckersTy = std::vector<CheckerManager::CheckNewAllocatorFunc>;
647
648 const CheckersTy &Checkers;
649 const CXXAllocatorCall &Call;
650 bool WasInlined;
651 ExprEngine &Eng;
652
653 CheckNewAllocatorContext(const CheckersTy &Checkers,
654 const CXXAllocatorCall &Call, bool WasInlined,
655 ExprEngine &Eng)
656 : Checkers(Checkers), Call(Call), WasInlined(WasInlined), Eng(Eng) {}
657
658 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
659 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
660
661 void runChecker(CheckerManager::CheckNewAllocatorFunc checkFn,
662 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
663 auto TimeScope = checkerTimeTraceScope(Eng, "Allocator", checkFn.Checker);
664 ProgramPoint L = PostAllocatorCall(
665 Call.getOriginExpr(), Pred->getStackFrame(), checkFn.Checker);
666 CheckerContext C(Eng, Pred, Dst, L, WasInlined);
667 checkFn(cast<CXXAllocatorCall>(*Call.cloneWithState(Pred->getState())),
668 C);
669 }
670 };
671
672} // namespace
673
675 ExplodedNodeSet &Dst,
676 ExplodedNode *Pred,
677 ExprEngine &Eng,
678 bool WasInlined) {
679 ExplodedNodeSet Src;
680 Src.insert(Pred);
681 CheckNewAllocatorContext C(NewAllocatorCheckers, Call, WasInlined, Eng);
682 auto TimeScope =
683 timeTraceScope(*this, "CheckerManager::runCheckersForNewAllocator");
684 expandGraphWithCheckers(C, Dst, Src);
685}
686
687/// Run checkers for live symbols.
689 SymbolReaper &SymReaper) {
690 for (const auto &LiveSymbolsChecker : LiveSymbolsCheckers)
691 LiveSymbolsChecker(state, SymReaper);
692}
693
694namespace {
695
696 struct CheckDeadSymbolsContext {
697 using CheckersTy = std::vector<CheckerManager::CheckDeadSymbolsFunc>;
698
699 const CheckersTy &Checkers;
700 SymbolReaper &SR;
701 const Stmt *S;
702 ExprEngine &Eng;
703 ProgramPoint::Kind ProgramPointKind;
704
705 CheckDeadSymbolsContext(const CheckersTy &checkers, SymbolReaper &sr,
706 const Stmt *s, ExprEngine &eng,
708 : Checkers(checkers), SR(sr), S(s), Eng(eng), ProgramPointKind(K) {}
709
710 CheckersTy::const_iterator checkers_begin() { return Checkers.begin(); }
711 CheckersTy::const_iterator checkers_end() { return Checkers.end(); }
712
713 void runChecker(CheckerManager::CheckDeadSymbolsFunc checkFn,
714 ExplodedNode *Pred, ExplodedNodeSet &Dst) {
715 auto TimeScope =
716 checkerTimeTraceScope(Eng, "DeadSymbols", checkFn.Checker);
718 S, ProgramPointKind, Pred->getStackFrame(), checkFn.Checker);
719 CheckerContext C(Eng, Pred, Dst, L);
720
721 // Note, do not pass the statement to the checkers without letting them
722 // differentiate if we ran remove dead bindings before or after the
723 // statement.
724 checkFn(SR, C);
725 }
726 };
727
728} // namespace
729
730/// Run checkers for dead symbols.
732 const ExplodedNodeSet &Src,
733 SymbolReaper &SymReaper,
734 const Stmt *S,
735 ExprEngine &Eng,
737 CheckDeadSymbolsContext C(DeadSymbolsCheckers, SymReaper, S, Eng, K);
738 auto TimeScope =
739 timeTraceScope(*this, "CheckerManager::runCheckersForDeadSymbols");
740 expandGraphWithCheckers(C, Dst, Src);
741}
742
743/// Run checkers for region changes.
745 ProgramStateRef state, const InvalidatedSymbols *invalidated,
746 ArrayRef<const MemRegion *> ExplicitRegions,
747 ArrayRef<const MemRegion *> Regions, const StackFrame *SF,
748 const CallEvent *Call) {
749 for (const auto &RegionChangesChecker : RegionChangesCheckers) {
750 // If any checker declares the state infeasible (or if it starts that way),
751 // bail out.
752 if (!state)
753 return nullptr;
754 state = RegionChangesChecker(state, invalidated, ExplicitRegions, Regions,
755 SF, Call);
756 }
757 return state;
758}
759
760/// Run checkers to process symbol escape event.
763 const InvalidatedSymbols &Escaped,
764 const CallEvent *Call,
767 assert((Call != nullptr ||
768 (Kind != PSK_DirectEscapeOnCall &&
769 Kind != PSK_IndirectEscapeOnCall)) &&
770 "Call must not be NULL when escaping on call");
771 for (const auto &PointerEscapeChecker : PointerEscapeCheckers) {
772 // If any checker declares the state infeasible (or if it starts that
773 // way), bail out.
774 if (!State)
775 return nullptr;
776 State = PointerEscapeChecker(State, Escaped, Call, Kind, ETraits);
777 }
778 return State;
779}
780
781/// Run checkers for handling assumptions on symbolic values.
784 SVal Cond, bool Assumption) {
785 for (const auto &EvalAssumeChecker : EvalAssumeCheckers) {
786 // If any checker declares the state infeasible (or if it starts that way),
787 // bail out.
788 if (!state)
789 return nullptr;
790 state = EvalAssumeChecker(state, Cond, Assumption);
791 }
792 return state;
793}
794
795/// Run checkers for evaluating a call.
796/// Only one checker will evaluate the call.
798 const ExplodedNodeSet &Src,
799 const CallEvent &Call,
800 ExprEngine &Eng,
801 const EvalCallOptions &CallOpts) {
802 for (auto *const Pred : Src) {
803 std::optional<StringRef> evaluatorChecker;
804
805 ExplodedNodeSet checkDst{Pred};
806
807 ProgramStateRef State = Pred->getState();
808 CallEventRef<> UpdatedCall = Call.cloneWithState(State);
809
810 // Check if any of the EvalCall callbacks can evaluate the call.
811 for (const auto &EvalCallChecker : EvalCallCheckers) {
812 // TODO: Support the situation when the call doesn't correspond
813 // to any Expr.
815 UpdatedCall->getOriginExpr(), ProgramPoint::PostStmtKind,
816 Pred->getStackFrame(), EvalCallChecker.Checker);
817
818 CheckerContext C(Eng, Pred, checkDst, L);
819 bool evaluated = EvalCallChecker(*UpdatedCall, C);
820#ifndef NDEBUG
821 if (evaluated && evaluatorChecker) {
822 const auto toString = [](const CallEvent &Call) -> std::string {
823 std::string Buf;
824 llvm::raw_string_ostream OS(Buf);
825 Call.dump(OS);
826 return Buf;
827 };
828 std::string AssertionMessage = llvm::formatv(
829 "The '{0}' call has been already evaluated by the {1} checker, "
830 "while the {2} checker also tried to evaluate the same call. At "
831 "most one checker supposed to evaluate a call.",
832 toString(Call), evaluatorChecker,
833 EvalCallChecker.Checker->getDebugTag());
834 llvm_unreachable(AssertionMessage.c_str());
835 }
836#endif
837 if (evaluated) {
838 evaluatorChecker = EvalCallChecker.Checker->getDebugTag();
839 Dst.insert(checkDst);
840#ifdef NDEBUG
841 break; // on release don't check that no other checker also evals.
842#endif
843 }
844 }
845
846 // If none of the checkers evaluated the call, ask ExprEngine to handle it.
847 if (!evaluatorChecker)
848 Eng.defaultEvalCall(Dst, Pred, *UpdatedCall, CallOpts);
849 }
850}
851
852/// Run checkers for the entire Translation Unit.
854 const TranslationUnitDecl *TU,
855 AnalysisManager &mgr,
856 BugReporter &BR) {
857 for (const auto &EndOfTranslationUnitChecker : EndOfTranslationUnitCheckers)
858 EndOfTranslationUnitChecker(TU, mgr, BR);
859}
860
862 ProgramStateRef State,
863 const char *NL,
864 unsigned int Space,
865 bool IsDot) const {
866 Indent(Out, Space, IsDot) << "\"checker_messages\": ";
867
868 // Create a temporary stream to see whether we have any message.
869 SmallString<1024> TempBuf;
870 llvm::raw_svector_ostream TempOut(TempBuf);
871 unsigned int InnerSpace = Space + 2;
872
873 // Create the new-line in JSON with enough space.
874 SmallString<128> NewLine;
875 llvm::raw_svector_ostream NLOut(NewLine);
876 NLOut << "\", " << NL; // Inject the ending and a new line
877 Indent(NLOut, InnerSpace, IsDot) << "\""; // then begin the next message.
878
879 ++Space;
880
881 std::vector<std::pair<std::string, std::string>> CheckerMsgs;
882 for (const auto &CT : CheckerTags) {
883 CT.second->printState(TempOut, State, /*NL=*/NewLine.c_str(), /*Sep=*/"");
884 const std::string Msg = TempBuf.str().trim().str();
885 TempBuf.clear();
886
887 if (!Msg.empty())
888 CheckerMsgs.push_back({CT.second->getDebugTag().str(), Msg});
889 }
890 llvm::sort(CheckerMsgs);
891
892 if (!CheckerMsgs.empty())
893 Out << '[' << NL;
894
895 llvm::interleave(
896 CheckerMsgs,
897 [&](const std::pair<std::string, std::string> &CM) {
898 Indent(Out, Space, IsDot)
899 << "{ \"checker\": \"" << CM.first << "\", \"messages\": [" << NL;
900 Indent(Out, InnerSpace, IsDot) << '\"' << CM.second << '\"' << NL;
901 Indent(Out, Space, IsDot) << "]}";
902 },
903 [&] { Out << ',' << NL; });
904
905 // It is the last element of the 'program_state' so do not add a comma.
906 if (!CheckerMsgs.empty()) {
907 Out << NL;
908 Indent(Out, --Space, IsDot) << "]";
909 } else {
910 Out << "null";
911 }
912
913 Out << NL;
914}
915
916//===----------------------------------------------------------------------===//
917// Internal registration functions for AST traversing.
918//===----------------------------------------------------------------------===//
919
921 HandlesDeclFunc isForDeclFn) {
922 DeclCheckerInfo info = { checkfn, isForDeclFn };
923 DeclCheckers.push_back(info);
924}
925
927 BodyCheckers.push_back(checkfn);
928}
929
930//===----------------------------------------------------------------------===//
931// Internal registration functions for path-sensitive checking.
932//===----------------------------------------------------------------------===//
933
935 HandlesStmtFunc isForStmtFn) {
936 StmtCheckerInfo info = { checkfn, isForStmtFn, /*IsPreVisit*/true };
937 StmtCheckers.push_back(info);
938}
939
941 HandlesStmtFunc isForStmtFn) {
942 StmtCheckerInfo info = { checkfn, isForStmtFn, /*IsPreVisit*/false };
943 StmtCheckers.push_back(info);
944}
945
947 PreObjCMessageCheckers.push_back(checkfn);
948}
949
951 ObjCMessageNilCheckers.push_back(checkfn);
952}
953
955 PostObjCMessageCheckers.push_back(checkfn);
956}
957
959 PreCallCheckers.push_back(checkfn);
960}
962 PostCallCheckers.push_back(checkfn);
963}
964
966 LifetimeEndCheckers.push_back(checkfn);
967}
968
970 LocationCheckers.push_back(checkfn);
971}
972
974 BindCheckers.push_back(checkfn);
975}
976
978 BlockEntranceCheckers.push_back(checkfn);
979}
980
982 EndAnalysisCheckers.push_back(checkfn);
983}
984
986 BeginFunctionCheckers.push_back(checkfn);
987}
988
990 EndFunctionCheckers.push_back(checkfn);
991}
992
994 CheckBranchConditionFunc checkfn) {
995 BranchConditionCheckers.push_back(checkfn);
996}
997
999 NewAllocatorCheckers.push_back(checkfn);
1000}
1001
1003 LiveSymbolsCheckers.push_back(checkfn);
1004}
1005
1007 DeadSymbolsCheckers.push_back(checkfn);
1008}
1009
1011 RegionChangesCheckers.push_back(checkfn);
1012}
1013
1015 PointerEscapeCheckers.push_back(checkfn);
1016}
1017
1019 CheckPointerEscapeFunc checkfn) {
1020 PointerEscapeCheckers.push_back(checkfn);
1021}
1022
1024 EvalAssumeCheckers.push_back(checkfn);
1025}
1026
1028 EvalCallCheckers.push_back(checkfn);
1029}
1030
1032 CheckEndOfTranslationUnit checkfn) {
1033 EndOfTranslationUnitCheckers.push_back(checkfn);
1034}
1035
1036//===----------------------------------------------------------------------===//
1037// Implementation details.
1038//===----------------------------------------------------------------------===//
1039
1040const CheckerManager::CachedStmtCheckers &
1041CheckerManager::getCachedStmtCheckersFor(const Stmt *S, bool isPreVisit) {
1042 assert(S);
1043
1044 unsigned Key = (S->getStmtClass() << 1) | unsigned(isPreVisit);
1045 auto [CCI, Inserted] = CachedStmtCheckersMap.try_emplace(Key);
1046 CachedStmtCheckers &Checkers = CCI->second;
1047 if (Inserted) {
1048 // Find the checkers that should run for this Stmt and cache them.
1049 for (const auto &Info : StmtCheckers)
1050 if (Info.IsPreVisit == isPreVisit && Info.IsForStmtFn(S))
1051 Checkers.push_back(Info.CheckFn);
1052 }
1053 return Checkers;
1054}
static void expandGraphWithCheckers(CHECK_CTX checkCtx, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
Definition DeclBase.h:1111
Kind getKind() const
Definition DeclBase.h:451
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
static ProgramPoint getProgramPoint(const Stmt *S, ProgramPoint::Kind K, const StackFrame *SF, const ProgramPointTag *tag)
ProgramPoint withTag(const ProgramPointTag *NewTag) const
Create a new ProgramPoint object that is the same as the original except for using the specified tag ...
std::optional< T > getAs() const
Convert to the specified ProgramPoint type, returning std::nullopt if this ProgramPoint is not of the...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3173
It represents a stack frame of the call stack.
Stmt - This represents one statement.
Definition Stmt.h:85
StmtClass getStmtClass() const
Definition Stmt.h:1504
The top declaration context.
Definition Decl.h:107
Represents a variable declaration or definition.
Definition Decl.h:934
BugReporter is a utility class for generating PathDiagnostics for analysis.
Represents the memory allocation call in a C++ new-expression.
Definition CallEvent.h:1117
Represents an abstract call to a function or method along a particular path.
Definition CallEvent.h:152
CallEventRef< T > cloneWithState(ProgramStateRef NewState) const
Returns a copy of this CallEvent, but using the given state.
Definition CallEvent.h:1470
ProgramPoint getProgramPoint(bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
Returns an appropriate ProgramPoint for this call.
CheckerBackend is an abstract base class that serves as the common ancestor of all the Checker<....
Definition Checker.h:544
StringRef getDebugTag() const override
Attached to nodes created by this checker class when the ExplodedGraph is dumped for debugging.
Definition Checker.cpp:21
A CheckerFrontend instance is what the user recognizes as "one checker": it has a public canonical na...
Definition Checker.h:526
CheckerNameRef getName() const
Definition Checker.h:536
void _registerForLiveSymbols(CheckLiveSymbolsFunc checkfn)
void _registerForEndOfTranslationUnit(CheckEndOfTranslationUnit checkfn)
ProgramStateRef runCheckersForRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const StackFrame *SF, const CallEvent *Call)
Run checkers for region changes.
void _registerForBeginFunction(CheckBeginFunctionFunc checkfn)
void _registerForNewAllocator(CheckNewAllocatorFunc checkfn)
CheckerFn< void(const Decl *, AnalysisManager &, BugReporter &)> CheckDeclFunc
void _registerForPreCall(CheckCallFunc checkfn)
CheckerFn< ProgramStateRef(ProgramStateRef, SVal cond, bool assumption)> EvalAssumeFunc
void _registerForObjCMessageNil(CheckObjCMessageFunc checkfn)
CheckerFn< ProgramStateRef(ProgramStateRef, const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind, RegionAndSymbolInvalidationTraits *ITraits)> CheckPointerEscapeFunc
bool(*)(const Decl *D) HandlesDeclFunc
void runCheckersForObjCMessage(ObjCMessageVisitKind visitKind, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting obj-c messages.
void runCheckersOnASTDecl(const Decl *D, AnalysisManager &mgr, BugReporter &BR)
Run checkers handling Decls.
void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn)
CheckerFn< void(const ReturnStmt *, CheckerContext &)> CheckEndFunctionFunc
CheckerFn< void(const Stmt *, CheckerContext &)> CheckBranchConditionFunc
void _registerForPreObjCMessage(CheckObjCMessageFunc checkfn)
void runCheckersOnEndOfTranslationUnit(const TranslationUnitDecl *TU, AnalysisManager &mgr, BugReporter &BR)
Run checkers for the entire Translation Unit.
CheckerFn< bool(const CallEvent &, CheckerContext &)> EvalCallFunc
CheckerFn< void(CheckerContext &)> CheckBeginFunctionFunc
CheckerFn< void(ExplodedGraph &, BugReporter &, ExprEngine &)> CheckEndAnalysisFunc
void _registerForEvalAssume(EvalAssumeFunc checkfn)
void _registerForEndAnalysis(CheckEndAnalysisFunc checkfn)
void _registerForBody(CheckDeclFunc checkfn)
DiagnosticsEngine & getDiagnostics() const
void runCheckersForLocation(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, bool isLoad, const Stmt *NodeEx, const Stmt *BoundEx, ExprEngine &Eng)
Run checkers for load/store of a location.
CheckerFn< void(const Stmt *, CheckerContext &)> CheckStmtFunc
CheckerFn< void(SVal location, SVal val, const Stmt *S, bool AtDeclInit, CheckerContext &)> CheckBindFunc
void runCheckersForBind(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, SVal val, const Stmt *S, bool AtDeclInit, ExprEngine &Eng, const ProgramPoint &PP)
Run checkers for binding of a value to a location.
void reportInvalidCheckerOptionValue(const CheckerFrontend *Checker, StringRef OptionName, StringRef ExpectedValueDesc) const
Emits an error through a DiagnosticsEngine about an invalid user supplied checker option value.
void runCheckersForEndAnalysis(ExplodedGraph &G, BugReporter &BR, ExprEngine &Eng)
Run checkers for end of analysis.
CheckerFn< void(const CXXAllocatorCall &Call, CheckerContext &)> CheckNewAllocatorFunc
CheckerFn< void(const VarDecl *, CheckerContext &)> CheckLifetimeEndFunc
void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State, const char *NL="\n", unsigned int Space=0, bool IsDot=false) const
Run checkers for debug-printing a ProgramState.
void _registerForDeadSymbols(CheckDeadSymbolsFunc checkfn)
void runCheckersForDeadSymbols(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SymbolReaper &SymReaper, const Stmt *S, ExprEngine &Eng, ProgramPoint::Kind K)
Run checkers for dead symbols.
void _registerForPostObjCMessage(CheckObjCMessageFunc checkfn)
void _registerForRegionChanges(CheckRegionChangesFunc checkfn)
void runCheckersForEndFunction(ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, const ReturnStmt *RS)
Run checkers on end of function.
void _registerForBind(CheckBindFunc checkfn)
void runCheckersForLiveSymbols(ProgramStateRef state, SymbolReaper &SymReaper)
Run checkers for live symbols.
void _registerForPointerEscape(CheckPointerEscapeFunc checkfn)
CheckerFn< void(const TranslationUnitDecl *, AnalysisManager &, BugReporter &)> CheckEndOfTranslationUnit
void _registerForPreStmt(CheckStmtFunc checkfn, HandlesStmtFunc isForStmtFn)
void runCheckersForEvalCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &CE, ExprEngine &Eng, const EvalCallOptions &CallOpts)
Run checkers for evaluating a call.
void _registerForPostStmt(CheckStmtFunc checkfn, HandlesStmtFunc isForStmtFn)
void runCheckersForBeginFunction(ExplodedNodeSet &Dst, const BlockEdge &L, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers on beginning of function.
void runCheckersForNewAllocator(const CXXAllocatorCall &Call, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng, bool wasInlined=false)
Run checkers between C++ operator new and constructor calls.
CheckerFn< void(const CallEvent &, CheckerContext &)> CheckCallFunc
void _registerForBranchCondition(CheckBranchConditionFunc checkfn)
CheckerFn< void(SymbolReaper &, CheckerContext &)> CheckDeadSymbolsFunc
CheckerFn< void(SVal location, bool isLoad, const Stmt *S, CheckerContext &)> CheckLocationFunc
void runCheckersForBlockEntrance(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const BlockEntrance &Entrance, ExprEngine &Eng) const
Run checkers after taking a control flow edge.
void runCheckersForStmt(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting Stmts.
void _registerForEvalCall(EvalCallFunc checkfn)
void _registerForEndFunction(CheckEndFunctionFunc checkfn)
void _registerForBlockEntrance(CheckBlockEntranceFunc checkfn)
CheckerFn< ProgramStateRef( ProgramStateRef, const InvalidatedSymbols *symbols, ArrayRef< const MemRegion * > ExplicitRegions, ArrayRef< const MemRegion * > Regions, const StackFrame *SF, const CallEvent *Call)> CheckRegionChangesFunc
void runCheckersForBranchCondition(const Stmt *condition, ExplodedNodeSet &Dst, ExplodedNode *Pred, ExprEngine &Eng)
Run checkers for branch condition.
CheckerFn< void(const ObjCMethodCall &, CheckerContext &)> CheckObjCMessageFunc
void _registerForLocation(CheckLocationFunc checkfn)
ProgramStateRef runCheckersForPointerEscape(ProgramStateRef State, const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind, RegionAndSymbolInvalidationTraits *ITraits)
Run checkers when pointers escape.
void _registerForConstPointerEscape(CheckPointerEscapeFunc checkfn)
CheckerFn< void(const BlockEntrance &, CheckerContext &)> CheckBlockEntranceFunc
CheckerFn< void(ProgramStateRef, SymbolReaper &)> CheckLiveSymbolsFunc
void runCheckersForCallEvent(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for visiting function calls (including methods, constructors, destructors etc.
bool(*)(const Stmt *D) HandlesStmtFunc
void _registerForPostCall(CheckCallFunc checkfn)
void runCheckersOnASTBody(const Decl *D, AnalysisManager &mgr, BugReporter &BR)
Run checkers handling Decls containing a Stmt body.
void runCheckersForLifetimeEnd(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const VarDecl *Decl, ExprEngine &Eng)
Run checkers for the end of a variable's lifetime.
void _registerForLifetimeEnd(CheckLifetimeEndFunc checkfn)
ProgramStateRef runCheckersForEvalAssume(ProgramStateRef state, SVal Cond, bool Assumption)
Run checkers for handling assumptions on symbolic values.
Simple checker classes that implement one frontend (i.e.
Definition Checker.h:565
ExplodedNodeSet is a set of ExplodedNode * elements with the invariant that its elements cannot be nu...
void insert(ExplodedNode *N)
const ProgramStateRef & getState() const
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
const StackFrame * getStackFrame() const
void defaultEvalCall(ExplodedNodeSet &Dst, ExplodedNode *Pred, const CallEvent &Call, const EvalCallOptions &CallOpts={})
Default implementation of call evaluation.
CheckerManager & getCheckerManager() const
Definition ExprEngine.h:201
Represents any expression that calls an Objective-C method.
Definition CallEvent.h:1244
Information about invalidation for a particular region/symbol.
Definition MemRegion.h:1664
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Definition SVals.h:57
void dumpToStream(raw_ostream &OS) const
Definition SVals.cpp:293
A class responsible for cleaning up unused symbols.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
@ PSK_DirectEscapeOnCall
The pointer has been passed to a function call directly.
@ PSK_IndirectEscapeOnCall
The pointer has been passed to a function indirectly.
llvm::DenseSet< SymbolRef > InvalidatedSymbols
Definition Store.h:50
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
Definition Facts.h:158
Top level wrappers for InstallAPI frontend operations.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
Definition JsonSupport.h:21
U cast(CodeGen::Address addr)
Definition Address.h:327
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 unsigned
Hints for figuring out if a call should be inlined during evalCall().
Definition ExprEngine.h:92