1//===----- UninitializedObjectChecker.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 file defines a checker that reports uninitialized fields in objects
10// created after a constructor call.
11//
12// To read about command line options and how the checker works, refer to the
13// top of the file and inline comments in UninitializedObject.h.
14//
15// Some of the logic is implemented in UninitializedPointee.cpp, to reduce the
16// complexity of this file.
17//
18//===----------------------------------------------------------------------===//
19
20#include "UninitializedObject.h"
21#include "clang/ASTMatchers/ASTMatchFinder.h"
22#include "clang/Driver/DriverDiagnostic.h"
23#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
24#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
25#include "clang/StaticAnalyzer/Core/Checker.h"
26#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
27#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h"
28#include "llvm/ADT/STLExtras.h"
29
30using namespace clang;
31using namespace clang::ento;
32using namespace clang::ast_matchers;
33
34/// We'll mark fields (and pointee of fields) that are confirmed to be
35/// uninitialized as already analyzed.
36REGISTER_SET_WITH_PROGRAMSTATE(AnalyzedRegions, const MemRegion *)
37
38namespace {
39
40class UninitializedObjectChecker
41 : public Checker<check::EndFunction, check::DeadSymbols> {
42 const BugType BT_uninitField{this, "Uninitialized fields"};
43
44public:
45 // The fields of this struct will be initialized when registering the checker.
46 UninitObjCheckerOptions Opts;
47
48 void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const;
49 void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
50};
51
52/// A basic field type, that is not a pointer or a reference, it's dynamic and
53/// static type is the same.
54class RegularField final : public FieldNode {
55public:
56 RegularField(const FieldRegion *FR) : FieldNode(FR) {}
57
58 void printNoteMsg(llvm::raw_ostream &Out) const override {
59 Out << "uninitialized field ";
60 }
61
62 void printPrefix(llvm::raw_ostream &Out) const override {}
63
64 void printNode(llvm::raw_ostream &Out) const override {
65 Out << getVariableName(Field: getDecl());
66 }
67
68 void printSeparator(llvm::raw_ostream &Out) const override { Out << '.'; }
69};
70
71/// Represents that the FieldNode that comes after this is declared in a base
72/// of the previous FieldNode. As such, this descendant doesn't wrap a
73/// FieldRegion, and is purely a tool to describe a relation between two other
74/// FieldRegion wrapping descendants.
75class BaseClass final : public FieldNode {
76 const QualType BaseClassT;
77
78public:
79 BaseClass(const QualType &T) : FieldNode(nullptr), BaseClassT(T) {
80 assert(!T.isNull());
81 assert(T->getAsCXXRecordDecl());
82 }
83
84 void printNoteMsg(llvm::raw_ostream &Out) const override {
85 llvm_unreachable("This node can never be the final node in the "
86 "fieldchain!");
87 }
88
89 void printPrefix(llvm::raw_ostream &Out) const override {}
90
91 void printNode(llvm::raw_ostream &Out) const override {
92 Out << BaseClassT->getAsCXXRecordDecl()->getName() << "::";
93 }
94
95 void printSeparator(llvm::raw_ostream &Out) const override {}
96
97 bool isBase() const override { return true; }
98};
99
100} // end of anonymous namespace
101
102// Utility function declarations.
103
104/// Returns the region that was constructed by CtorDecl, or nullptr if that
105/// isn't possible.
106static const TypedValueRegion *
107getConstructedRegion(const CXXConstructorDecl *CtorDecl,
108 CheckerContext &Context);
109
110/// Checks whether the object constructed by \p Ctor will be analyzed later
111/// (e.g. if the object is a field of another object, in which case we'd check
112/// it multiple times).
113static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
114 CheckerContext &Context);
115
116/// Checks whether RD contains a field with a name or type name that matches
117/// \p Pattern.
118static bool shouldIgnoreRecord(const RecordDecl *RD, StringRef Pattern);
119
120/// Checks _syntactically_ whether it is possible to access FD from the record
121/// that contains it without a preceding assert (even if that access happens
122/// inside a method). This is mainly used for records that act like unions, like
123/// having multiple bit fields, with only a fraction being properly initialized.
124/// If these fields are properly guarded with asserts, this method returns
125/// false.
126///
127/// Since this check is done syntactically, this method could be inaccurate.
128static bool hasUnguardedAccess(const FieldDecl *FD, ProgramStateRef State);
129
130//===----------------------------------------------------------------------===//
131// Methods for UninitializedObjectChecker.
132//===----------------------------------------------------------------------===//
133
134void UninitializedObjectChecker::checkEndFunction(
135 const ReturnStmt *RS, CheckerContext &Context) const {
136
137 const auto *CtorDecl =
138 dyn_cast_or_null<CXXConstructorDecl>(Val: Context.getStackFrame()->getDecl());
139 if (!CtorDecl)
140 return;
141
142 if (!CtorDecl->isUserProvided())
143 return;
144
145 if (CtorDecl->getParent()->isUnion())
146 return;
147
148 // This avoids essentially the same error being reported multiple times.
149 if (willObjectBeAnalyzedLater(Ctor: CtorDecl, Context))
150 return;
151
152 const TypedValueRegion *R = getConstructedRegion(CtorDecl, Context);
153 if (!R)
154 return;
155
156 FindUninitializedFields F(Context.getState(), R, Opts);
157
158 std::pair<ProgramStateRef, const UninitFieldMap &> UninitInfo =
159 F.getResults();
160
161 ProgramStateRef UpdatedState = UninitInfo.first;
162 const UninitFieldMap &UninitFields = UninitInfo.second;
163
164 if (UninitFields.empty()) {
165 Context.addTransition(State: UpdatedState);
166 return;
167 }
168
169 // There are uninitialized fields in the record.
170
171 ExplodedNode *Node = Context.generateNonFatalErrorNode(State: UpdatedState);
172 if (!Node)
173 return;
174
175 PathDiagnosticLocation LocUsedForUniqueing;
176 const Expr *CallSite = Context.getStackFrame()->getCallSite();
177 if (CallSite)
178 LocUsedForUniqueing = PathDiagnosticLocation::createBegin(
179 S: CallSite, SM: Context.getSourceManager(), SFAC: Node->getStackFrame());
180
181 // For Plist consumers that don't support notes just yet, we'll convert notes
182 // to warnings.
183 if (Opts.ShouldConvertNotesToWarnings) {
184 for (const auto &Pair : UninitFields) {
185
186 auto Report = std::make_unique<PathSensitiveBugReport>(
187 args: BT_uninitField, args: Pair.second, args&: Node, args&: LocUsedForUniqueing,
188 args: Node->getStackFrame()->getDecl());
189 Context.emitReport(R: std::move(Report));
190 }
191 return;
192 }
193
194 SmallString<100> WarningBuf;
195 llvm::raw_svector_ostream WarningOS(WarningBuf);
196 WarningOS << UninitFields.size() << " uninitialized field"
197 << (UninitFields.size() == 1 ? "" : "s")
198 << " at the end of the constructor call";
199
200 auto Report = std::make_unique<PathSensitiveBugReport>(
201 args: BT_uninitField, args: WarningOS.str(), args&: Node, args&: LocUsedForUniqueing,
202 args: Node->getStackFrame()->getDecl());
203
204 using NoteTy = std::pair<PathDiagnosticLocation, StringRef>;
205 SmallVector<NoteTy> Notes;
206 const auto &SM = Context.getSourceManager();
207 for (const auto &[FieldRegion, NoteMsg] : UninitFields) {
208 auto FieldLoc = PathDiagnosticLocation::create(D: FieldRegion->getDecl(), SM);
209 Notes.emplace_back(Args&: FieldLoc, Args: NoteMsg);
210 }
211
212 // Make the order deterministic.
213 llvm::sort(C&: Notes, Comp: [](const NoteTy &LHS, const NoteTy &RHS) {
214 FullSourceLoc L = LHS.first.asLocation();
215 FullSourceLoc R = RHS.first.asLocation();
216 if (L != R)
217 return L.isBeforeInTranslationUnitThan(Loc: R);
218 // Comparing the field locs might not be enough so we might need a tie
219 // breaker.
220 // See the `cxx-uninitialized-object-note-order.cpp:fTwoInstances` test
221 // demonstrating this.
222 return LHS.second < RHS.second;
223 });
224
225 for (const auto &[Loc, NoteMsg] : Notes)
226 Report->addNote(Msg: NoteMsg, Pos: Loc);
227
228 Context.emitReport(R: std::move(Report));
229}
230
231void UninitializedObjectChecker::checkDeadSymbols(SymbolReaper &SR,
232 CheckerContext &C) const {
233 ProgramStateRef State = C.getState();
234 for (const MemRegion *R : State->get<AnalyzedRegions>()) {
235 if (!SR.isLiveRegion(region: R))
236 State = State->remove<AnalyzedRegions>(K: R);
237 }
238}
239
240//===----------------------------------------------------------------------===//
241// Methods for FindUninitializedFields.
242//===----------------------------------------------------------------------===//
243
244FindUninitializedFields::FindUninitializedFields(
245 ProgramStateRef State, const TypedValueRegion *const R,
246 const UninitObjCheckerOptions &Opts)
247 : State(State), ObjectR(R), Opts(Opts) {
248
249 isNonUnionUninit(R: ObjectR, LocalChain: FieldChainInfo(ChainFactory));
250
251 // In non-pedantic mode, if ObjectR doesn't contain a single initialized
252 // field, we'll assume that Object was intentionally left uninitialized.
253 if (!Opts.IsPedantic && !isAnyFieldInitialized())
254 UninitFields.clear();
255}
256
257bool FindUninitializedFields::addFieldToUninits(FieldChainInfo Chain,
258 const MemRegion *PointeeR) {
259 const FieldRegion *FR = Chain.getUninitRegion();
260
261 assert((PointeeR || !isDereferencableType(FR->getDecl()->getType())) &&
262 "One must also pass the pointee region as a parameter for "
263 "dereferenceable fields!");
264
265 if (State->getStateManager().getContext().getSourceManager().isInSystemHeader(
266 Loc: FR->getDecl()->getLocation()))
267 return false;
268
269 if (Opts.IgnoreGuardedFields && !hasUnguardedAccess(FD: FR->getDecl(), State))
270 return false;
271
272 if (State->contains<AnalyzedRegions>(key: FR))
273 return false;
274
275 if (PointeeR) {
276 if (State->contains<AnalyzedRegions>(key: PointeeR)) {
277 return false;
278 }
279 State = State->add<AnalyzedRegions>(K: PointeeR);
280 }
281
282 State = State->add<AnalyzedRegions>(K: FR);
283
284 UninitFieldMap::mapped_type NoteMsgBuf;
285 llvm::raw_svector_ostream OS(NoteMsgBuf);
286 Chain.printNoteMsg(Out&: OS);
287
288 return UninitFields.insert(x: {FR, std::move(NoteMsgBuf)}).second;
289}
290
291bool FindUninitializedFields::isNonUnionUninit(const TypedValueRegion *R,
292 FieldChainInfo LocalChain) {
293 assert(R->getValueType()->isRecordType() &&
294 !R->getValueType()->isUnionType() &&
295 "This method only checks non-union record objects!");
296
297 const RecordDecl *RD = R->getValueType()->getAsRecordDecl()->getDefinition();
298
299 if (!RD) {
300 IsAnyFieldInitialized = true;
301 return true;
302 }
303
304 if (!Opts.IgnoredRecordsWithFieldPattern.empty() &&
305 shouldIgnoreRecord(RD, Pattern: Opts.IgnoredRecordsWithFieldPattern)) {
306 IsAnyFieldInitialized = true;
307 return false;
308 }
309
310 bool ContainsUninitField = false;
311
312 // Are all of this non-union's fields initialized?
313 for (const FieldDecl *I : RD->fields()) {
314 if (I->isUnnamedBitField()) {
315 continue;
316 }
317 const auto FieldVal =
318 State->getLValue(decl: I, Base: loc::MemRegionVal(R)).castAs<loc::MemRegionVal>();
319 const auto *FR = FieldVal.getRegionAs<FieldRegion>();
320 QualType T = I->getType();
321
322 // If LocalChain already contains FR, then we encountered a cyclic
323 // reference. In this case, region FR is already under checking at an
324 // earlier node in the directed tree.
325 if (LocalChain.contains(FR))
326 return false;
327
328 if (T->isStructureOrClassType()) {
329 if (isNonUnionUninit(R: FR, LocalChain: LocalChain.add(FN: RegularField(FR))))
330 ContainsUninitField = true;
331 continue;
332 }
333
334 if (T->isUnionType()) {
335 if (isUnionUninit(R: FR)) {
336 if (addFieldToUninits(Chain: LocalChain.add(FN: RegularField(FR))))
337 ContainsUninitField = true;
338 } else
339 IsAnyFieldInitialized = true;
340 continue;
341 }
342
343 if (T->isArrayType()) {
344 IsAnyFieldInitialized = true;
345 continue;
346 }
347
348 SVal V = State->getSVal(LV: FieldVal);
349
350 if (isDereferencableType(T) || isa<nonloc::LocAsInteger>(Val: V)) {
351 if (isDereferencableUninit(FR, LocalChain))
352 ContainsUninitField = true;
353 continue;
354 }
355
356 if (isPrimitiveType(T)) {
357 if (isPrimitiveUninit(V)) {
358 if (addFieldToUninits(Chain: LocalChain.add(FN: RegularField(FR))))
359 ContainsUninitField = true;
360 }
361 continue;
362 }
363
364 llvm_unreachable("All cases are handled!");
365 }
366
367 // Checking bases. The checker will regard inherited data members as direct
368 // fields.
369 const auto *CXXRD = dyn_cast<CXXRecordDecl>(Val: RD);
370 if (!CXXRD)
371 return ContainsUninitField;
372
373 for (const CXXBaseSpecifier &BaseSpec : CXXRD->bases()) {
374 const auto *BaseRegion = State->getLValue(BaseSpec, Super: R)
375 .castAs<loc::MemRegionVal>()
376 .getRegionAs<TypedValueRegion>();
377
378 // If the head of the list is also a BaseClass, we'll overwrite it to avoid
379 // note messages like 'this->A::B::x'.
380 if (!LocalChain.isEmpty() && LocalChain.getHead().isBase()) {
381 if (isNonUnionUninit(R: BaseRegion, LocalChain: LocalChain.replaceHead(
382 FN: BaseClass(BaseSpec.getType()))))
383 ContainsUninitField = true;
384 } else {
385 if (isNonUnionUninit(R: BaseRegion,
386 LocalChain: LocalChain.add(FN: BaseClass(BaseSpec.getType()))))
387 ContainsUninitField = true;
388 }
389 }
390
391 return ContainsUninitField;
392}
393
394bool FindUninitializedFields::isUnionUninit(const TypedValueRegion *R) {
395 assert(R->getValueType()->isUnionType() &&
396 "This method only checks union objects!");
397 // TODO: Implement support for union fields.
398 return false;
399}
400
401bool FindUninitializedFields::isPrimitiveUninit(SVal V) {
402 if (V.isUndef())
403 return true;
404
405 IsAnyFieldInitialized = true;
406 return false;
407}
408
409//===----------------------------------------------------------------------===//
410// Methods for FieldChainInfo.
411//===----------------------------------------------------------------------===//
412
413bool FieldChainInfo::contains(const FieldRegion *FR) const {
414 for (const FieldNode &Node : Chain) {
415 if (Node.isSameRegion(OtherFR: FR))
416 return true;
417 }
418 return false;
419}
420
421/// Prints every element except the last to `Out`. Since ImmutableLists store
422/// elements in reverse order, and have no reverse iterators, we use a
423/// recursive function to print the fieldchain correctly. The last element in
424/// the chain is to be printed by `FieldChainInfo::print`.
425static void printTail(llvm::raw_ostream &Out,
426 const FieldChainInfo::FieldChain L);
427
428// FIXME: This function constructs an incorrect string in the following case:
429//
430// struct Base { int x; };
431// struct D1 : Base {}; struct D2 : Base {};
432//
433// struct MostDerived : D1, D2 {
434// MostDerived() {}
435// }
436//
437// A call to MostDerived::MostDerived() will cause two notes that say
438// "uninitialized field 'this->x'", but we can't refer to 'x' directly,
439// we need an explicit namespace resolution whether the uninit field was
440// 'D1::x' or 'D2::x'.
441void FieldChainInfo::printNoteMsg(llvm::raw_ostream &Out) const {
442 if (Chain.isEmpty())
443 return;
444
445 const FieldNode &LastField = getHead();
446
447 LastField.printNoteMsg(Out);
448 Out << '\'';
449
450 for (const FieldNode &Node : Chain)
451 Node.printPrefix(Out);
452
453 Out << "this->";
454 printTail(Out, L: Chain.getTail());
455 LastField.printNode(Out);
456 Out << '\'';
457}
458
459static void printTail(llvm::raw_ostream &Out,
460 const FieldChainInfo::FieldChain L) {
461 if (L.isEmpty())
462 return;
463
464 printTail(Out, L: L.getTail());
465
466 L.getHead().printNode(Out);
467 L.getHead().printSeparator(Out);
468}
469
470//===----------------------------------------------------------------------===//
471// Utility functions.
472//===----------------------------------------------------------------------===//
473
474static const SubRegion *
475getConstructedSubRegion(const CXXConstructorDecl *CtorDecl,
476 CheckerContext &Context) {
477 Loc ThisLoc =
478 Context.getSValBuilder().getCXXThis(D: CtorDecl, SF: Context.getStackFrame());
479 SVal ObjectV = Context.getState()->getSVal(LV: ThisLoc);
480 return ObjectV.getAsRegion()->getAs<SubRegion>();
481}
482
483static const TypedValueRegion *
484getConstructedRegion(const CXXConstructorDecl *CtorDecl,
485 CheckerContext &Context) {
486
487 const SubRegion *SR = getConstructedSubRegion(CtorDecl, Context);
488 if (!SR)
489 return nullptr;
490
491 if (const auto *TVR = SR->getAs<TypedValueRegion>()) {
492 return TVR->getValueType()->getAsCXXRecordDecl() ? TVR : nullptr;
493 }
494
495 QualType ThisPointeeTy = CtorDecl->getThisType()->getPointeeType();
496 if (!ThisPointeeTy->getAsCXXRecordDecl())
497 return nullptr;
498
499 auto &MemMgr = Context.getState()->getStateManager().getRegionManager();
500 auto &SVB = Context.getSValBuilder();
501
502 const auto *ElemR = MemMgr.getElementRegion(
503 elementType: ThisPointeeTy, Idx: SVB.makeZeroArrayIndex(), superRegion: SR, Ctx: Context.getASTContext());
504
505 return ElemR;
506}
507
508static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
509 CheckerContext &Context) {
510
511 const SubRegion *CurrRegion = getConstructedSubRegion(CtorDecl: Ctor, Context);
512 if (!CurrRegion)
513 return false;
514
515 // Returns true if \p Ctor was called by another constructor whose region
516 // contains CurrRegion, so CurrRegion will be analyzed during that analysis.
517 return llvm::any_of(
518 Range: Context.getStackFrame()->parents(), P: [&](const StackFrame &SF) {
519 const auto *OtherCtor = dyn_cast<CXXConstructorDecl>(Val: SF.getDecl());
520 if (!OtherCtor)
521 return false;
522
523 const SubRegion *OtherRegion =
524 getConstructedSubRegion(CtorDecl: OtherCtor, Context);
525 return OtherRegion && CurrRegion->isSubRegionOf(R: OtherRegion);
526 });
527}
528
529static bool shouldIgnoreRecord(const RecordDecl *RD, StringRef Pattern) {
530 llvm::Regex R(Pattern);
531
532 for (const FieldDecl *FD : RD->fields()) {
533 if (R.match(String: FD->getType().getAsString()))
534 return true;
535 if (R.match(String: FD->getName()))
536 return true;
537 }
538
539 return false;
540}
541
542static const Stmt *getMethodBody(const CXXMethodDecl *M) {
543 if (isa<CXXConstructorDecl>(Val: M))
544 return nullptr;
545
546 if (!M->isDefined())
547 return nullptr;
548
549 return M->getDefinition()->getBody();
550}
551
552static bool hasUnguardedAccess(const FieldDecl *FD, ProgramStateRef State) {
553
554 if (FD->getAccess() == AccessSpecifier::AS_public)
555 return true;
556
557 const auto *Parent = dyn_cast<CXXRecordDecl>(Val: FD->getParent());
558
559 if (!Parent)
560 return true;
561
562 Parent = Parent->getDefinition();
563 assert(Parent && "The record's definition must be avaible if an uninitialized"
564 " field of it was found!");
565
566 ASTContext &AC = State->getStateManager().getContext();
567
568 auto FieldAccessM = memberExpr(hasDeclaration(InnerMatcher: equalsNode(Other: FD))).bind(ID: "access");
569
570 auto AssertLikeM = callExpr(callee(InnerMatcher: functionDecl(
571 hasAnyName("exit", "panic", "error", "Assert", "assert", "ziperr",
572 "assfail", "db_error", "__assert", "__assert2", "_wassert",
573 "__assert_rtn", "__assert_fail", "dtrace_assfail",
574 "yy_fatal_error", "_XCAssertionFailureHandler",
575 "_DTAssertionFailureHandler", "_TSAssertionFailureHandler"))));
576
577 auto NoReturnFuncM = callExpr(callee(InnerMatcher: functionDecl(isNoReturn())));
578
579 auto GuardM =
580 stmt(anyOf(ifStmt(), switchStmt(), conditionalOperator(), AssertLikeM,
581 NoReturnFuncM))
582 .bind(ID: "guard");
583
584 for (const CXXMethodDecl *M : Parent->methods()) {
585 const Stmt *MethodBody = getMethodBody(M);
586 if (!MethodBody)
587 continue;
588
589 auto Accesses = match(Matcher: stmt(hasDescendant(FieldAccessM)), Node: *MethodBody, Context&: AC);
590 if (Accesses.empty())
591 continue;
592 const auto *FirstAccess = Accesses[0].getNodeAs<MemberExpr>(ID: "access");
593 assert(FirstAccess);
594
595 auto Guards = match(Matcher: stmt(hasDescendant(GuardM)), Node: *MethodBody, Context&: AC);
596 if (Guards.empty())
597 return true;
598 const auto *FirstGuard = Guards[0].getNodeAs<Stmt>(ID: "guard");
599 assert(FirstGuard);
600
601 if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
602 return true;
603 }
604
605 return false;
606}
607
608std::string clang::ento::getVariableName(const FieldDecl *Field) {
609 // If Field is a captured lambda variable, Field->getName() will return with
610 // an empty string. We can however acquire it's name from the lambda's
611 // captures.
612 const auto *CXXParent = dyn_cast<CXXRecordDecl>(Val: Field->getParent());
613
614 if (CXXParent && CXXParent->isLambda()) {
615 assert(CXXParent->captures_begin());
616 auto It = CXXParent->captures_begin() + Field->getFieldIndex();
617
618 if (It->capturesVariable())
619 return llvm::Twine("/*captured variable*/" +
620 It->getCapturedVar()->getName())
621 .str();
622
623 if (It->capturesThis())
624 return "/*'this' capture*/";
625
626 llvm_unreachable("No other capture type is expected!");
627 }
628
629 return std::string(Field->getName());
630}
631
632void ento::registerUninitializedObjectChecker(CheckerManager &Mgr) {
633 auto Chk = Mgr.registerChecker<UninitializedObjectChecker>();
634
635 const AnalyzerOptions &AnOpts = Mgr.getAnalyzerOptions();
636 UninitObjCheckerOptions &ChOpts = Chk->Opts;
637
638 ChOpts.IsPedantic = AnOpts.getCheckerBooleanOption(C: Chk, OptionName: "Pedantic");
639 ChOpts.ShouldConvertNotesToWarnings = AnOpts.getCheckerBooleanOption(
640 C: Chk, OptionName: "NotesAsWarnings");
641 ChOpts.CheckPointeeInitialization = AnOpts.getCheckerBooleanOption(
642 C: Chk, OptionName: "CheckPointeeInitialization");
643 ChOpts.IgnoredRecordsWithFieldPattern =
644 std::string(AnOpts.getCheckerStringOption(C: Chk, OptionName: "IgnoreRecordsWithField"));
645 ChOpts.IgnoreGuardedFields =
646 AnOpts.getCheckerBooleanOption(C: Chk, OptionName: "IgnoreGuardedFields");
647
648 std::string ErrorMsg;
649 if (!llvm::Regex(ChOpts.IgnoredRecordsWithFieldPattern).isValid(Error&: ErrorMsg))
650 Mgr.reportInvalidCheckerOptionValue(Checker: Chk, OptionName: "IgnoreRecordsWithField",
651 ExpectedValueDesc: "a valid regex, building failed with error message "
652 "\"" + ErrorMsg + "\"");
653}
654
655bool ento::shouldRegisterUninitializedObjectChecker(const CheckerManager &mgr) {
656 return true;
657}
658