UninitializedObjectChecker.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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. #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
  20. #include "UninitializedObject.h"
  21. #include "clang/ASTMatchers/ASTMatchFinder.h"
  22. #include "clang/Driver/DriverDiagnostic.h"
  23. #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
  24. #include "clang/StaticAnalyzer/Core/Checker.h"
  25. #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
  26. #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h"
  27. using namespace clang;
  28. using namespace clang::ento;
  29. using namespace clang::ast_matchers;
  30. /// We'll mark fields (and pointee of fields) that are confirmed to be
  31. /// uninitialized as already analyzed.
  32. REGISTER_SET_WITH_PROGRAMSTATE(AnalyzedRegions, const MemRegion *)
  33. namespace {
  34. class UninitializedObjectChecker
  35. : public Checker<check::EndFunction, check::DeadSymbols> {
  36. std::unique_ptr<BuiltinBug> BT_uninitField;
  37. public:
  38. // The fields of this struct will be initialized when registering the checker.
  39. UninitObjCheckerOptions Opts;
  40. UninitializedObjectChecker()
  41. : BT_uninitField(new BuiltinBug(this, "Uninitialized fields")) {}
  42. void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const;
  43. void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
  44. };
  45. /// A basic field type, that is not a pointer or a reference, it's dynamic and
  46. /// static type is the same.
  47. class RegularField final : public FieldNode {
  48. public:
  49. RegularField(const FieldRegion *FR) : FieldNode(FR) {}
  50. virtual void printNoteMsg(llvm::raw_ostream &Out) const override {
  51. Out << "uninitialized field ";
  52. }
  53. virtual void printPrefix(llvm::raw_ostream &Out) const override {}
  54. virtual void printNode(llvm::raw_ostream &Out) const override {
  55. Out << getVariableName(getDecl());
  56. }
  57. virtual void printSeparator(llvm::raw_ostream &Out) const override {
  58. Out << '.';
  59. }
  60. };
  61. /// Represents that the FieldNode that comes after this is declared in a base
  62. /// of the previous FieldNode. As such, this descendant doesn't wrap a
  63. /// FieldRegion, and is purely a tool to describe a relation between two other
  64. /// FieldRegion wrapping descendants.
  65. class BaseClass final : public FieldNode {
  66. const QualType BaseClassT;
  67. public:
  68. BaseClass(const QualType &T) : FieldNode(nullptr), BaseClassT(T) {
  69. assert(!T.isNull());
  70. assert(T->getAsCXXRecordDecl());
  71. }
  72. virtual void printNoteMsg(llvm::raw_ostream &Out) const override {
  73. llvm_unreachable("This node can never be the final node in the "
  74. "fieldchain!");
  75. }
  76. virtual void printPrefix(llvm::raw_ostream &Out) const override {}
  77. virtual void printNode(llvm::raw_ostream &Out) const override {
  78. Out << BaseClassT->getAsCXXRecordDecl()->getName() << "::";
  79. }
  80. virtual void printSeparator(llvm::raw_ostream &Out) const override {}
  81. virtual bool isBase() const override { return true; }
  82. };
  83. } // end of anonymous namespace
  84. // Utility function declarations.
  85. /// Returns the region that was constructed by CtorDecl, or nullptr if that
  86. /// isn't possible.
  87. static const TypedValueRegion *
  88. getConstructedRegion(const CXXConstructorDecl *CtorDecl,
  89. CheckerContext &Context);
  90. /// Checks whether the object constructed by \p Ctor will be analyzed later
  91. /// (e.g. if the object is a field of another object, in which case we'd check
  92. /// it multiple times).
  93. static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
  94. CheckerContext &Context);
  95. /// Checks whether RD contains a field with a name or type name that matches
  96. /// \p Pattern.
  97. static bool shouldIgnoreRecord(const RecordDecl *RD, StringRef Pattern);
  98. /// Checks _syntactically_ whether it is possible to access FD from the record
  99. /// that contains it without a preceding assert (even if that access happens
  100. /// inside a method). This is mainly used for records that act like unions, like
  101. /// having multiple bit fields, with only a fraction being properly initialized.
  102. /// If these fields are properly guarded with asserts, this method returns
  103. /// false.
  104. ///
  105. /// Since this check is done syntactically, this method could be inaccurate.
  106. static bool hasUnguardedAccess(const FieldDecl *FD, ProgramStateRef State);
  107. //===----------------------------------------------------------------------===//
  108. // Methods for UninitializedObjectChecker.
  109. //===----------------------------------------------------------------------===//
  110. void UninitializedObjectChecker::checkEndFunction(
  111. const ReturnStmt *RS, CheckerContext &Context) const {
  112. const auto *CtorDecl = dyn_cast_or_null<CXXConstructorDecl>(
  113. Context.getLocationContext()->getDecl());
  114. if (!CtorDecl)
  115. return;
  116. if (!CtorDecl->isUserProvided())
  117. return;
  118. if (CtorDecl->getParent()->isUnion())
  119. return;
  120. // This avoids essentially the same error being reported multiple times.
  121. if (willObjectBeAnalyzedLater(CtorDecl, Context))
  122. return;
  123. const TypedValueRegion *R = getConstructedRegion(CtorDecl, Context);
  124. if (!R)
  125. return;
  126. FindUninitializedFields F(Context.getState(), R, Opts);
  127. std::pair<ProgramStateRef, const UninitFieldMap &> UninitInfo =
  128. F.getResults();
  129. ProgramStateRef UpdatedState = UninitInfo.first;
  130. const UninitFieldMap &UninitFields = UninitInfo.second;
  131. if (UninitFields.empty()) {
  132. Context.addTransition(UpdatedState);
  133. return;
  134. }
  135. // There are uninitialized fields in the record.
  136. ExplodedNode *Node = Context.generateNonFatalErrorNode(UpdatedState);
  137. if (!Node)
  138. return;
  139. PathDiagnosticLocation LocUsedForUniqueing;
  140. const Stmt *CallSite = Context.getStackFrame()->getCallSite();
  141. if (CallSite)
  142. LocUsedForUniqueing = PathDiagnosticLocation::createBegin(
  143. CallSite, Context.getSourceManager(), Node->getLocationContext());
  144. // For Plist consumers that don't support notes just yet, we'll convert notes
  145. // to warnings.
  146. if (Opts.ShouldConvertNotesToWarnings) {
  147. for (const auto &Pair : UninitFields) {
  148. auto Report = std::make_unique<PathSensitiveBugReport>(
  149. *BT_uninitField, Pair.second, Node, LocUsedForUniqueing,
  150. Node->getLocationContext()->getDecl());
  151. Context.emitReport(std::move(Report));
  152. }
  153. return;
  154. }
  155. SmallString<100> WarningBuf;
  156. llvm::raw_svector_ostream WarningOS(WarningBuf);
  157. WarningOS << UninitFields.size() << " uninitialized field"
  158. << (UninitFields.size() == 1 ? "" : "s")
  159. << " at the end of the constructor call";
  160. auto Report = std::make_unique<PathSensitiveBugReport>(
  161. *BT_uninitField, WarningOS.str(), Node, LocUsedForUniqueing,
  162. Node->getLocationContext()->getDecl());
  163. for (const auto &Pair : UninitFields) {
  164. Report->addNote(Pair.second,
  165. PathDiagnosticLocation::create(Pair.first->getDecl(),
  166. Context.getSourceManager()));
  167. }
  168. Context.emitReport(std::move(Report));
  169. }
  170. void UninitializedObjectChecker::checkDeadSymbols(SymbolReaper &SR,
  171. CheckerContext &C) const {
  172. ProgramStateRef State = C.getState();
  173. for (const MemRegion *R : State->get<AnalyzedRegions>()) {
  174. if (!SR.isLiveRegion(R))
  175. State = State->remove<AnalyzedRegions>(R);
  176. }
  177. }
  178. //===----------------------------------------------------------------------===//
  179. // Methods for FindUninitializedFields.
  180. //===----------------------------------------------------------------------===//
  181. FindUninitializedFields::FindUninitializedFields(
  182. ProgramStateRef State, const TypedValueRegion *const R,
  183. const UninitObjCheckerOptions &Opts)
  184. : State(State), ObjectR(R), Opts(Opts) {
  185. isNonUnionUninit(ObjectR, FieldChainInfo(ChainFactory));
  186. // In non-pedantic mode, if ObjectR doesn't contain a single initialized
  187. // field, we'll assume that Object was intentionally left uninitialized.
  188. if (!Opts.IsPedantic && !isAnyFieldInitialized())
  189. UninitFields.clear();
  190. }
  191. bool FindUninitializedFields::addFieldToUninits(FieldChainInfo Chain,
  192. const MemRegion *PointeeR) {
  193. const FieldRegion *FR = Chain.getUninitRegion();
  194. assert((PointeeR || !isDereferencableType(FR->getDecl()->getType())) &&
  195. "One must also pass the pointee region as a parameter for "
  196. "dereferenceable fields!");
  197. if (State->getStateManager().getContext().getSourceManager().isInSystemHeader(
  198. FR->getDecl()->getLocation()))
  199. return false;
  200. if (Opts.IgnoreGuardedFields && !hasUnguardedAccess(FR->getDecl(), State))
  201. return false;
  202. if (State->contains<AnalyzedRegions>(FR))
  203. return false;
  204. if (PointeeR) {
  205. if (State->contains<AnalyzedRegions>(PointeeR)) {
  206. return false;
  207. }
  208. State = State->add<AnalyzedRegions>(PointeeR);
  209. }
  210. State = State->add<AnalyzedRegions>(FR);
  211. UninitFieldMap::mapped_type NoteMsgBuf;
  212. llvm::raw_svector_ostream OS(NoteMsgBuf);
  213. Chain.printNoteMsg(OS);
  214. return UninitFields.insert({FR, std::move(NoteMsgBuf)}).second;
  215. }
  216. bool FindUninitializedFields::isNonUnionUninit(const TypedValueRegion *R,
  217. FieldChainInfo LocalChain) {
  218. assert(R->getValueType()->isRecordType() &&
  219. !R->getValueType()->isUnionType() &&
  220. "This method only checks non-union record objects!");
  221. const RecordDecl *RD = R->getValueType()->getAsRecordDecl()->getDefinition();
  222. if (!RD) {
  223. IsAnyFieldInitialized = true;
  224. return true;
  225. }
  226. if (!Opts.IgnoredRecordsWithFieldPattern.empty() &&
  227. shouldIgnoreRecord(RD, Opts.IgnoredRecordsWithFieldPattern)) {
  228. IsAnyFieldInitialized = true;
  229. return false;
  230. }
  231. bool ContainsUninitField = false;
  232. // Are all of this non-union's fields initialized?
  233. for (const FieldDecl *I : RD->fields()) {
  234. const auto FieldVal =
  235. State->getLValue(I, loc::MemRegionVal(R)).castAs<loc::MemRegionVal>();
  236. const auto *FR = FieldVal.getRegionAs<FieldRegion>();
  237. QualType T = I->getType();
  238. // If LocalChain already contains FR, then we encountered a cyclic
  239. // reference. In this case, region FR is already under checking at an
  240. // earlier node in the directed tree.
  241. if (LocalChain.contains(FR))
  242. return false;
  243. if (T->isStructureOrClassType()) {
  244. if (isNonUnionUninit(FR, LocalChain.add(RegularField(FR))))
  245. ContainsUninitField = true;
  246. continue;
  247. }
  248. if (T->isUnionType()) {
  249. if (isUnionUninit(FR)) {
  250. if (addFieldToUninits(LocalChain.add(RegularField(FR))))
  251. ContainsUninitField = true;
  252. } else
  253. IsAnyFieldInitialized = true;
  254. continue;
  255. }
  256. if (T->isArrayType()) {
  257. IsAnyFieldInitialized = true;
  258. continue;
  259. }
  260. SVal V = State->getSVal(FieldVal);
  261. if (isDereferencableType(T) || V.getAs<nonloc::LocAsInteger>()) {
  262. if (isDereferencableUninit(FR, LocalChain))
  263. ContainsUninitField = true;
  264. continue;
  265. }
  266. if (isPrimitiveType(T)) {
  267. if (isPrimitiveUninit(V)) {
  268. if (addFieldToUninits(LocalChain.add(RegularField(FR))))
  269. ContainsUninitField = true;
  270. }
  271. continue;
  272. }
  273. llvm_unreachable("All cases are handled!");
  274. }
  275. // Checking bases. The checker will regard inherited data members as direct
  276. // fields.
  277. const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD);
  278. if (!CXXRD)
  279. return ContainsUninitField;
  280. for (const CXXBaseSpecifier &BaseSpec : CXXRD->bases()) {
  281. const auto *BaseRegion = State->getLValue(BaseSpec, R)
  282. .castAs<loc::MemRegionVal>()
  283. .getRegionAs<TypedValueRegion>();
  284. // If the head of the list is also a BaseClass, we'll overwrite it to avoid
  285. // note messages like 'this->A::B::x'.
  286. if (!LocalChain.isEmpty() && LocalChain.getHead().isBase()) {
  287. if (isNonUnionUninit(BaseRegion, LocalChain.replaceHead(
  288. BaseClass(BaseSpec.getType()))))
  289. ContainsUninitField = true;
  290. } else {
  291. if (isNonUnionUninit(BaseRegion,
  292. LocalChain.add(BaseClass(BaseSpec.getType()))))
  293. ContainsUninitField = true;
  294. }
  295. }
  296. return ContainsUninitField;
  297. }
  298. bool FindUninitializedFields::isUnionUninit(const TypedValueRegion *R) {
  299. assert(R->getValueType()->isUnionType() &&
  300. "This method only checks union objects!");
  301. // TODO: Implement support for union fields.
  302. return false;
  303. }
  304. bool FindUninitializedFields::isPrimitiveUninit(const SVal &V) {
  305. if (V.isUndef())
  306. return true;
  307. IsAnyFieldInitialized = true;
  308. return false;
  309. }
  310. //===----------------------------------------------------------------------===//
  311. // Methods for FieldChainInfo.
  312. //===----------------------------------------------------------------------===//
  313. bool FieldChainInfo::contains(const FieldRegion *FR) const {
  314. for (const FieldNode &Node : Chain) {
  315. if (Node.isSameRegion(FR))
  316. return true;
  317. }
  318. return false;
  319. }
  320. /// Prints every element except the last to `Out`. Since ImmutableLists store
  321. /// elements in reverse order, and have no reverse iterators, we use a
  322. /// recursive function to print the fieldchain correctly. The last element in
  323. /// the chain is to be printed by `FieldChainInfo::print`.
  324. static void printTail(llvm::raw_ostream &Out,
  325. const FieldChainInfo::FieldChain L);
  326. // FIXME: This function constructs an incorrect string in the following case:
  327. //
  328. // struct Base { int x; };
  329. // struct D1 : Base {}; struct D2 : Base {};
  330. //
  331. // struct MostDerived : D1, D2 {
  332. // MostDerived() {}
  333. // }
  334. //
  335. // A call to MostDerived::MostDerived() will cause two notes that say
  336. // "uninitialized field 'this->x'", but we can't refer to 'x' directly,
  337. // we need an explicit namespace resolution whether the uninit field was
  338. // 'D1::x' or 'D2::x'.
  339. void FieldChainInfo::printNoteMsg(llvm::raw_ostream &Out) const {
  340. if (Chain.isEmpty())
  341. return;
  342. const FieldNode &LastField = getHead();
  343. LastField.printNoteMsg(Out);
  344. Out << '\'';
  345. for (const FieldNode &Node : Chain)
  346. Node.printPrefix(Out);
  347. Out << "this->";
  348. printTail(Out, Chain.getTail());
  349. LastField.printNode(Out);
  350. Out << '\'';
  351. }
  352. static void printTail(llvm::raw_ostream &Out,
  353. const FieldChainInfo::FieldChain L) {
  354. if (L.isEmpty())
  355. return;
  356. printTail(Out, L.getTail());
  357. L.getHead().printNode(Out);
  358. L.getHead().printSeparator(Out);
  359. }
  360. //===----------------------------------------------------------------------===//
  361. // Utility functions.
  362. //===----------------------------------------------------------------------===//
  363. static const TypedValueRegion *
  364. getConstructedRegion(const CXXConstructorDecl *CtorDecl,
  365. CheckerContext &Context) {
  366. Loc ThisLoc =
  367. Context.getSValBuilder().getCXXThis(CtorDecl, Context.getStackFrame());
  368. SVal ObjectV = Context.getState()->getSVal(ThisLoc);
  369. auto *R = ObjectV.getAsRegion()->getAs<TypedValueRegion>();
  370. if (R && !R->getValueType()->getAsCXXRecordDecl())
  371. return nullptr;
  372. return R;
  373. }
  374. static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
  375. CheckerContext &Context) {
  376. const TypedValueRegion *CurrRegion = getConstructedRegion(Ctor, Context);
  377. if (!CurrRegion)
  378. return false;
  379. const LocationContext *LC = Context.getLocationContext();
  380. while ((LC = LC->getParent())) {
  381. // If \p Ctor was called by another constructor.
  382. const auto *OtherCtor = dyn_cast<CXXConstructorDecl>(LC->getDecl());
  383. if (!OtherCtor)
  384. continue;
  385. const TypedValueRegion *OtherRegion =
  386. getConstructedRegion(OtherCtor, Context);
  387. if (!OtherRegion)
  388. continue;
  389. // If the CurrRegion is a subregion of OtherRegion, it will be analyzed
  390. // during the analysis of OtherRegion.
  391. if (CurrRegion->isSubRegionOf(OtherRegion))
  392. return true;
  393. }
  394. return false;
  395. }
  396. static bool shouldIgnoreRecord(const RecordDecl *RD, StringRef Pattern) {
  397. llvm::Regex R(Pattern);
  398. for (const FieldDecl *FD : RD->fields()) {
  399. if (R.match(FD->getType().getAsString()))
  400. return true;
  401. if (R.match(FD->getName()))
  402. return true;
  403. }
  404. return false;
  405. }
  406. static const Stmt *getMethodBody(const CXXMethodDecl *M) {
  407. if (isa<CXXConstructorDecl>(M))
  408. return nullptr;
  409. if (!M->isDefined())
  410. return nullptr;
  411. return M->getDefinition()->getBody();
  412. }
  413. static bool hasUnguardedAccess(const FieldDecl *FD, ProgramStateRef State) {
  414. if (FD->getAccess() == AccessSpecifier::AS_public)
  415. return true;
  416. const auto *Parent = dyn_cast<CXXRecordDecl>(FD->getParent());
  417. if (!Parent)
  418. return true;
  419. Parent = Parent->getDefinition();
  420. assert(Parent && "The record's definition must be avaible if an uninitialized"
  421. " field of it was found!");
  422. ASTContext &AC = State->getStateManager().getContext();
  423. auto FieldAccessM = memberExpr(hasDeclaration(equalsNode(FD))).bind("access");
  424. auto AssertLikeM = callExpr(callee(functionDecl(
  425. hasAnyName("exit", "panic", "error", "Assert", "assert", "ziperr",
  426. "assfail", "db_error", "__assert", "__assert2", "_wassert",
  427. "__assert_rtn", "__assert_fail", "dtrace_assfail",
  428. "yy_fatal_error", "_XCAssertionFailureHandler",
  429. "_DTAssertionFailureHandler", "_TSAssertionFailureHandler"))));
  430. auto NoReturnFuncM = callExpr(callee(functionDecl(isNoReturn())));
  431. auto GuardM =
  432. stmt(anyOf(ifStmt(), switchStmt(), conditionalOperator(), AssertLikeM,
  433. NoReturnFuncM))
  434. .bind("guard");
  435. for (const CXXMethodDecl *M : Parent->methods()) {
  436. const Stmt *MethodBody = getMethodBody(M);
  437. if (!MethodBody)
  438. continue;
  439. auto Accesses = match(stmt(hasDescendant(FieldAccessM)), *MethodBody, AC);
  440. if (Accesses.empty())
  441. continue;
  442. const auto *FirstAccess = Accesses[0].getNodeAs<MemberExpr>("access");
  443. assert(FirstAccess);
  444. auto Guards = match(stmt(hasDescendant(GuardM)), *MethodBody, AC);
  445. if (Guards.empty())
  446. return true;
  447. const auto *FirstGuard = Guards[0].getNodeAs<Stmt>("guard");
  448. assert(FirstGuard);
  449. if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
  450. return true;
  451. }
  452. return false;
  453. }
  454. std::string clang::ento::getVariableName(const FieldDecl *Field) {
  455. // If Field is a captured lambda variable, Field->getName() will return with
  456. // an empty string. We can however acquire it's name from the lambda's
  457. // captures.
  458. const auto *CXXParent = dyn_cast<CXXRecordDecl>(Field->getParent());
  459. if (CXXParent && CXXParent->isLambda()) {
  460. assert(CXXParent->captures_begin());
  461. auto It = CXXParent->captures_begin() + Field->getFieldIndex();
  462. if (It->capturesVariable())
  463. return llvm::Twine("/*captured variable*/" +
  464. It->getCapturedVar()->getName())
  465. .str();
  466. if (It->capturesThis())
  467. return "/*'this' capture*/";
  468. llvm_unreachable("No other capture type is expected!");
  469. }
  470. return std::string(Field->getName());
  471. }
  472. void ento::registerUninitializedObjectChecker(CheckerManager &Mgr) {
  473. auto Chk = Mgr.registerChecker<UninitializedObjectChecker>();
  474. const AnalyzerOptions &AnOpts = Mgr.getAnalyzerOptions();
  475. UninitObjCheckerOptions &ChOpts = Chk->Opts;
  476. ChOpts.IsPedantic = AnOpts.getCheckerBooleanOption(Chk, "Pedantic");
  477. ChOpts.ShouldConvertNotesToWarnings = AnOpts.getCheckerBooleanOption(
  478. Chk, "NotesAsWarnings");
  479. ChOpts.CheckPointeeInitialization = AnOpts.getCheckerBooleanOption(
  480. Chk, "CheckPointeeInitialization");
  481. ChOpts.IgnoredRecordsWithFieldPattern =
  482. std::string(AnOpts.getCheckerStringOption(Chk, "IgnoreRecordsWithField"));
  483. ChOpts.IgnoreGuardedFields =
  484. AnOpts.getCheckerBooleanOption(Chk, "IgnoreGuardedFields");
  485. std::string ErrorMsg;
  486. if (!llvm::Regex(ChOpts.IgnoredRecordsWithFieldPattern).isValid(ErrorMsg))
  487. Mgr.reportInvalidCheckerOptionValue(Chk, "IgnoreRecordsWithField",
  488. "a valid regex, building failed with error message "
  489. "\"" + ErrorMsg + "\"");
  490. }
  491. bool ento::shouldRegisterUninitializedObjectChecker(const CheckerManager &mgr) {
  492. return true;
  493. }