blob: 92e21f9cce9c60a145a0c28914c5523a80f51b3c [file] [log] [blame]
Kristof Umann30f08652018-06-18 11:50:17 +00001//===----- UninitializedObjectChecker.cpp ------------------------*- C++ -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines a checker that reports uninitialized fields in objects
11// created after a constructor call.
12//
Kristof Umann6cec6c42018-09-14 09:39:26 +000013// To read about command line options and how the checker works, refer to the
14// top of the file and inline comments in UninitializedObject.h.
Kristof Umann56963ae2018-08-13 18:17:05 +000015//
16// Some of the logic is implemented in UninitializedPointee.cpp, to reduce the
17// complexity of this file.
18//
Kristof Umann30f08652018-06-18 11:50:17 +000019//===----------------------------------------------------------------------===//
20
Richard Smith651d6832018-08-13 22:07:11 +000021#include "../ClangSACheckers.h"
Kristof Umanna37bba42018-08-13 18:22:22 +000022#include "UninitializedObject.h"
Kristof Umann30f08652018-06-18 11:50:17 +000023#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
24#include "clang/StaticAnalyzer/Core/Checker.h"
25#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
Kristof Umannef9af052018-08-08 13:18:53 +000026#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
Kristof Umann30f08652018-06-18 11:50:17 +000027
28using namespace clang;
29using namespace clang::ento;
30
31namespace {
32
33class UninitializedObjectChecker : public Checker<check::EndFunction> {
34 std::unique_ptr<BuiltinBug> BT_uninitField;
35
36public:
Kristof Umann6cec6c42018-09-14 09:39:26 +000037 // The fields of this struct will be initialized when registering the checker.
38 UninitObjCheckerOptions Opts;
Kristof Umann30f08652018-06-18 11:50:17 +000039
40 UninitializedObjectChecker()
41 : BT_uninitField(new BuiltinBug(this, "Uninitialized fields")) {}
Reka Kovacsed8c05c2018-07-16 20:47:45 +000042 void checkEndFunction(const ReturnStmt *RS, CheckerContext &C) const;
Kristof Umann30f08652018-06-18 11:50:17 +000043};
44
Kristof Umann015b0592018-08-13 18:43:08 +000045/// A basic field type, that is not a pointer or a reference, it's dynamic and
46/// static type is the same.
Richard Smith651d6832018-08-13 22:07:11 +000047class RegularField final : public FieldNode {
Kristof Umann015b0592018-08-13 18:43:08 +000048public:
49 RegularField(const FieldRegion *FR) : FieldNode(FR) {}
50
51 virtual void printNoteMsg(llvm::raw_ostream &Out) const override {
52 Out << "uninitialized field ";
53 }
54
55 virtual void printPrefix(llvm::raw_ostream &Out) const override {}
56
Richard Smith651d6832018-08-13 22:07:11 +000057 virtual void printNode(llvm::raw_ostream &Out) const override {
Kristof Umann015b0592018-08-13 18:43:08 +000058 Out << getVariableName(getDecl());
59 }
60
61 virtual void printSeparator(llvm::raw_ostream &Out) const override {
62 Out << '.';
63 }
64};
65
Kristof Umannb59b45e2018-08-21 12:16:59 +000066/// Represents that the FieldNode that comes after this is declared in a base
Kristof Umannceb5f652018-09-14 09:07:40 +000067/// of the previous FieldNode. As such, this descendant doesn't wrap a
68/// FieldRegion, and is purely a tool to describe a relation between two other
69/// FieldRegion wrapping descendants.
Kristof Umannb59b45e2018-08-21 12:16:59 +000070class BaseClass final : public FieldNode {
71 const QualType BaseClassT;
72
73public:
74 BaseClass(const QualType &T) : FieldNode(nullptr), BaseClassT(T) {
75 assert(!T.isNull());
76 assert(T->getAsCXXRecordDecl());
77 }
78
79 virtual void printNoteMsg(llvm::raw_ostream &Out) const override {
80 llvm_unreachable("This node can never be the final node in the "
81 "fieldchain!");
82 }
83
84 virtual void printPrefix(llvm::raw_ostream &Out) const override {}
85
86 virtual void printNode(llvm::raw_ostream &Out) const override {
87 Out << BaseClassT->getAsCXXRecordDecl()->getName() << "::";
88 }
89
90 virtual void printSeparator(llvm::raw_ostream &Out) const override {}
91
Kristof Umann06209cb2018-08-21 15:09:22 +000092 virtual bool isBase() const override { return true; }
Kristof Umannb59b45e2018-08-21 12:16:59 +000093};
94
Kristof Umanncc852442018-07-12 13:13:46 +000095} // end of anonymous namespace
96
Kristof Umann30f08652018-06-18 11:50:17 +000097// Utility function declarations.
98
99/// Returns the object that was constructed by CtorDecl, or None if that isn't
100/// possible.
Kristof Umann0735cfb2018-08-08 12:23:02 +0000101// TODO: Refactor this function so that it returns the constructed object's
102// region.
Kristof Umanncc852442018-07-12 13:13:46 +0000103static Optional<nonloc::LazyCompoundVal>
Kristof Umann30f08652018-06-18 11:50:17 +0000104getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context);
105
Kristof Umann0735cfb2018-08-08 12:23:02 +0000106/// Checks whether the object constructed by \p Ctor will be analyzed later
107/// (e.g. if the object is a field of another object, in which case we'd check
108/// it multiple times).
109static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
Kristof Umanna37bba42018-08-13 18:22:22 +0000110 CheckerContext &Context);
Kristof Umann30f08652018-06-18 11:50:17 +0000111
Kristof Umann30f08652018-06-18 11:50:17 +0000112//===----------------------------------------------------------------------===//
113// Methods for UninitializedObjectChecker.
114//===----------------------------------------------------------------------===//
115
116void UninitializedObjectChecker::checkEndFunction(
Reka Kovacsed8c05c2018-07-16 20:47:45 +0000117 const ReturnStmt *RS, CheckerContext &Context) const {
Kristof Umann30f08652018-06-18 11:50:17 +0000118
119 const auto *CtorDecl = dyn_cast_or_null<CXXConstructorDecl>(
120 Context.getLocationContext()->getDecl());
121 if (!CtorDecl)
122 return;
123
124 if (!CtorDecl->isUserProvided())
125 return;
126
127 if (CtorDecl->getParent()->isUnion())
128 return;
129
130 // This avoids essentially the same error being reported multiple times.
Kristof Umann0735cfb2018-08-08 12:23:02 +0000131 if (willObjectBeAnalyzedLater(CtorDecl, Context))
Kristof Umann30f08652018-06-18 11:50:17 +0000132 return;
133
134 Optional<nonloc::LazyCompoundVal> Object = getObjectVal(CtorDecl, Context);
135 if (!Object)
136 return;
137
Kristof Umann6cec6c42018-09-14 09:39:26 +0000138 FindUninitializedFields F(Context.getState(), Object->getRegion(), Opts);
Kristof Umann30f08652018-06-18 11:50:17 +0000139
Kristof Umann015b0592018-08-13 18:43:08 +0000140 const UninitFieldMap &UninitFields = F.getUninitFields();
Kristof Umann30f08652018-06-18 11:50:17 +0000141
142 if (UninitFields.empty())
143 return;
144
145 // There are uninitialized fields in the record.
146
147 ExplodedNode *Node = Context.generateNonFatalErrorNode(Context.getState());
148 if (!Node)
149 return;
150
151 PathDiagnosticLocation LocUsedForUniqueing;
152 const Stmt *CallSite = Context.getStackFrame()->getCallSite();
153 if (CallSite)
154 LocUsedForUniqueing = PathDiagnosticLocation::createBegin(
155 CallSite, Context.getSourceManager(), Node->getLocationContext());
156
Kristof Umann9bd44392018-06-29 11:25:24 +0000157 // For Plist consumers that don't support notes just yet, we'll convert notes
158 // to warnings.
Kristof Umann6cec6c42018-09-14 09:39:26 +0000159 if (Opts.ShouldConvertNotesToWarnings) {
Kristof Umann015b0592018-08-13 18:43:08 +0000160 for (const auto &Pair : UninitFields) {
Kristof Umann9bd44392018-06-29 11:25:24 +0000161
162 auto Report = llvm::make_unique<BugReport>(
Kristof Umann015b0592018-08-13 18:43:08 +0000163 *BT_uninitField, Pair.second, Node, LocUsedForUniqueing,
Kristof Umann9bd44392018-06-29 11:25:24 +0000164 Node->getLocationContext()->getDecl());
165 Context.emitReport(std::move(Report));
166 }
167 return;
168 }
169
Kristof Umann30f08652018-06-18 11:50:17 +0000170 SmallString<100> WarningBuf;
171 llvm::raw_svector_ostream WarningOS(WarningBuf);
172 WarningOS << UninitFields.size() << " uninitialized field"
173 << (UninitFields.size() == 1 ? "" : "s")
174 << " at the end of the constructor call";
175
176 auto Report = llvm::make_unique<BugReport>(
177 *BT_uninitField, WarningOS.str(), Node, LocUsedForUniqueing,
178 Node->getLocationContext()->getDecl());
179
Kristof Umann015b0592018-08-13 18:43:08 +0000180 for (const auto &Pair : UninitFields) {
181 Report->addNote(Pair.second,
182 PathDiagnosticLocation::create(Pair.first->getDecl(),
Kristof Umann30f08652018-06-18 11:50:17 +0000183 Context.getSourceManager()));
184 }
Kristof Umann30f08652018-06-18 11:50:17 +0000185 Context.emitReport(std::move(Report));
186}
187
188//===----------------------------------------------------------------------===//
189// Methods for FindUninitializedFields.
190//===----------------------------------------------------------------------===//
191
192FindUninitializedFields::FindUninitializedFields(
Kristof Umann23ca9662018-08-13 18:48:34 +0000193 ProgramStateRef State, const TypedValueRegion *const R,
Kristof Umann6cec6c42018-09-14 09:39:26 +0000194 const UninitObjCheckerOptions &Opts)
195 : State(State), ObjectR(R), Opts(Opts) {
Kristof Umann30f08652018-06-18 11:50:17 +0000196
Kristof Umann015b0592018-08-13 18:43:08 +0000197 isNonUnionUninit(ObjectR, FieldChainInfo(ChainFactory));
Kristof Umann6cec6c42018-09-14 09:39:26 +0000198
199 // In non-pedantic mode, if ObjectR doesn't contain a single initialized
200 // field, we'll assume that Object was intentionally left uninitialized.
201 if (!Opts.IsPedantic && !isAnyFieldInitialized())
202 UninitFields.clear();
Kristof Umann30f08652018-06-18 11:50:17 +0000203}
204
205bool FindUninitializedFields::addFieldToUninits(FieldChainInfo Chain) {
206 if (State->getStateManager().getContext().getSourceManager().isInSystemHeader(
Kristof Umann015b0592018-08-13 18:43:08 +0000207 Chain.getUninitRegion()->getDecl()->getLocation()))
Kristof Umann30f08652018-06-18 11:50:17 +0000208 return false;
209
Kristof Umann015b0592018-08-13 18:43:08 +0000210 UninitFieldMap::mapped_type NoteMsgBuf;
211 llvm::raw_svector_ostream OS(NoteMsgBuf);
212 Chain.printNoteMsg(OS);
213 return UninitFields
214 .insert(std::make_pair(Chain.getUninitRegion(), std::move(NoteMsgBuf)))
215 .second;
Kristof Umann30f08652018-06-18 11:50:17 +0000216}
217
218bool FindUninitializedFields::isNonUnionUninit(const TypedValueRegion *R,
219 FieldChainInfo LocalChain) {
220 assert(R->getValueType()->isRecordType() &&
221 !R->getValueType()->isUnionType() &&
222 "This method only checks non-union record objects!");
223
Kristof Umannf0dd1012018-09-14 08:58:21 +0000224 const RecordDecl *RD = R->getValueType()->getAsRecordDecl()->getDefinition();
225
226 if (!RD) {
227 IsAnyFieldInitialized = true;
228 return true;
229 }
Kristof Umann30f08652018-06-18 11:50:17 +0000230
231 bool ContainsUninitField = false;
232
233 // Are all of this non-union's fields initialized?
234 for (const FieldDecl *I : RD->fields()) {
235
236 const auto FieldVal =
237 State->getLValue(I, loc::MemRegionVal(R)).castAs<loc::MemRegionVal>();
238 const auto *FR = FieldVal.getRegionAs<FieldRegion>();
239 QualType T = I->getType();
240
241 // If LocalChain already contains FR, then we encountered a cyclic
242 // reference. In this case, region FR is already under checking at an
243 // earlier node in the directed tree.
244 if (LocalChain.contains(FR))
245 return false;
246
247 if (T->isStructureOrClassType()) {
Kristof Umann015b0592018-08-13 18:43:08 +0000248 if (isNonUnionUninit(FR, LocalChain.add(RegularField(FR))))
Kristof Umann30f08652018-06-18 11:50:17 +0000249 ContainsUninitField = true;
250 continue;
251 }
252
253 if (T->isUnionType()) {
254 if (isUnionUninit(FR)) {
Kristof Umann015b0592018-08-13 18:43:08 +0000255 if (addFieldToUninits(LocalChain.add(RegularField(FR))))
Kristof Umann30f08652018-06-18 11:50:17 +0000256 ContainsUninitField = true;
257 } else
258 IsAnyFieldInitialized = true;
259 continue;
260 }
261
262 if (T->isArrayType()) {
263 IsAnyFieldInitialized = true;
264 continue;
265 }
266
Kristof Umannf0dd1012018-09-14 08:58:21 +0000267 if (isDereferencableType(T)) {
Kristof Umannceb5f652018-09-14 09:07:40 +0000268 if (isDereferencableUninit(FR, LocalChain))
Kristof Umann30f08652018-06-18 11:50:17 +0000269 ContainsUninitField = true;
270 continue;
271 }
272
Kristof Umann20e85ba2018-06-19 08:35:02 +0000273 if (isPrimitiveType(T)) {
274 SVal V = State->getSVal(FieldVal);
Kristof Umann30f08652018-06-18 11:50:17 +0000275
Kristof Umann20e85ba2018-06-19 08:35:02 +0000276 if (isPrimitiveUninit(V)) {
Kristof Umann015b0592018-08-13 18:43:08 +0000277 if (addFieldToUninits(LocalChain.add(RegularField(FR))))
Kristof Umann20e85ba2018-06-19 08:35:02 +0000278 ContainsUninitField = true;
279 }
280 continue;
Kristof Umann30f08652018-06-18 11:50:17 +0000281 }
Kristof Umann20e85ba2018-06-19 08:35:02 +0000282
283 llvm_unreachable("All cases are handled!");
Kristof Umann30f08652018-06-18 11:50:17 +0000284 }
285
Kristof Umannceb5f652018-09-14 09:07:40 +0000286 // Checking bases. The checker will regard inherited data members as direct
287 // fields.
Kristof Umann30f08652018-06-18 11:50:17 +0000288 const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD);
289 if (!CXXRD)
290 return ContainsUninitField;
291
292 for (const CXXBaseSpecifier &BaseSpec : CXXRD->bases()) {
293 const auto *BaseRegion = State->getLValue(BaseSpec, R)
294 .castAs<loc::MemRegionVal>()
295 .getRegionAs<TypedValueRegion>();
296
Kristof Umannb59b45e2018-08-21 12:16:59 +0000297 // If the head of the list is also a BaseClass, we'll overwrite it to avoid
298 // note messages like 'this->A::B::x'.
299 if (!LocalChain.isEmpty() && LocalChain.getHead().isBase()) {
300 if (isNonUnionUninit(BaseRegion, LocalChain.replaceHead(
301 BaseClass(BaseSpec.getType()))))
302 ContainsUninitField = true;
303 } else {
304 if (isNonUnionUninit(BaseRegion,
305 LocalChain.add(BaseClass(BaseSpec.getType()))))
306 ContainsUninitField = true;
307 }
Kristof Umann30f08652018-06-18 11:50:17 +0000308 }
309
310 return ContainsUninitField;
311}
312
313bool FindUninitializedFields::isUnionUninit(const TypedValueRegion *R) {
314 assert(R->getValueType()->isUnionType() &&
315 "This method only checks union objects!");
316 // TODO: Implement support for union fields.
317 return false;
318}
319
Kristof Umann30f08652018-06-18 11:50:17 +0000320bool FindUninitializedFields::isPrimitiveUninit(const SVal &V) {
321 if (V.isUndef())
322 return true;
323
324 IsAnyFieldInitialized = true;
325 return false;
326}
327
328//===----------------------------------------------------------------------===//
329// Methods for FieldChainInfo.
330//===----------------------------------------------------------------------===//
331
Kristof Umann015b0592018-08-13 18:43:08 +0000332const FieldRegion *FieldChainInfo::getUninitRegion() const {
Kristof Umann30f08652018-06-18 11:50:17 +0000333 assert(!Chain.isEmpty() && "Empty fieldchain!");
Kristof Umannceb5f652018-09-14 09:07:40 +0000334
335 // ImmutableList::getHead() isn't a const method, hence the not too nice
336 // implementation.
Kristof Umann015b0592018-08-13 18:43:08 +0000337 return (*Chain.begin()).getRegion();
Kristof Umann30f08652018-06-18 11:50:17 +0000338}
339
Kristof Umann015b0592018-08-13 18:43:08 +0000340bool FieldChainInfo::contains(const FieldRegion *FR) const {
341 for (const FieldNode &Node : Chain) {
342 if (Node.isSameRegion(FR))
343 return true;
344 }
345 return false;
Kristof Umann30f08652018-06-18 11:50:17 +0000346}
347
Kristof Umanna37bba42018-08-13 18:22:22 +0000348/// Prints every element except the last to `Out`. Since ImmutableLists store
349/// elements in reverse order, and have no reverse iterators, we use a
350/// recursive function to print the fieldchain correctly. The last element in
Kristof Umannceb5f652018-09-14 09:07:40 +0000351/// the chain is to be printed by `FieldChainInfo::print`.
Kristof Umanna37bba42018-08-13 18:22:22 +0000352static void printTail(llvm::raw_ostream &Out,
353 const FieldChainInfo::FieldChainImpl *L);
354
Kristof Umannceb5f652018-09-14 09:07:40 +0000355// FIXME: This function constructs an incorrect string in the following case:
Kristof Umann30f08652018-06-18 11:50:17 +0000356//
357// struct Base { int x; };
358// struct D1 : Base {}; struct D2 : Base {};
359//
360// struct MostDerived : D1, D2 {
361// MostDerived() {}
362// }
363//
364// A call to MostDerived::MostDerived() will cause two notes that say
365// "uninitialized field 'this->x'", but we can't refer to 'x' directly,
366// we need an explicit namespace resolution whether the uninit field was
367// 'D1::x' or 'D2::x'.
Kristof Umann015b0592018-08-13 18:43:08 +0000368void FieldChainInfo::printNoteMsg(llvm::raw_ostream &Out) const {
Kristof Umann30f08652018-06-18 11:50:17 +0000369 if (Chain.isEmpty())
370 return;
371
Kristof Umanna37bba42018-08-13 18:22:22 +0000372 const FieldChainImpl *L = Chain.getInternalPointer();
Kristof Umann015b0592018-08-13 18:43:08 +0000373 const FieldNode &LastField = L->getHead();
374
375 LastField.printNoteMsg(Out);
376 Out << '\'';
377
378 for (const FieldNode &Node : Chain)
379 Node.printPrefix(Out);
380
381 Out << "this->";
Kristof Umann30f08652018-06-18 11:50:17 +0000382 printTail(Out, L->getTail());
Kristof Umann015b0592018-08-13 18:43:08 +0000383 LastField.printNode(Out);
384 Out << '\'';
Kristof Umann30f08652018-06-18 11:50:17 +0000385}
386
Kristof Umanna37bba42018-08-13 18:22:22 +0000387static void printTail(llvm::raw_ostream &Out,
388 const FieldChainInfo::FieldChainImpl *L) {
Kristof Umann30f08652018-06-18 11:50:17 +0000389 if (!L)
390 return;
391
392 printTail(Out, L->getTail());
Kristof Umann015b0592018-08-13 18:43:08 +0000393
394 L->getHead().printNode(Out);
395 L->getHead().printSeparator(Out);
Kristof Umann30f08652018-06-18 11:50:17 +0000396}
397
398//===----------------------------------------------------------------------===//
399// Utility functions.
400//===----------------------------------------------------------------------===//
401
Kristof Umanncc852442018-07-12 13:13:46 +0000402static Optional<nonloc::LazyCompoundVal>
Kristof Umann30f08652018-06-18 11:50:17 +0000403getObjectVal(const CXXConstructorDecl *CtorDecl, CheckerContext &Context) {
404
405 Loc ThisLoc = Context.getSValBuilder().getCXXThis(CtorDecl->getParent(),
406 Context.getStackFrame());
407 // Getting the value for 'this'.
408 SVal This = Context.getState()->getSVal(ThisLoc);
409
410 // Getting the value for '*this'.
411 SVal Object = Context.getState()->getSVal(This.castAs<Loc>());
412
413 return Object.getAs<nonloc::LazyCompoundVal>();
414}
415
Kristof Umann0735cfb2018-08-08 12:23:02 +0000416static bool willObjectBeAnalyzedLater(const CXXConstructorDecl *Ctor,
Kristof Umanna37bba42018-08-13 18:22:22 +0000417 CheckerContext &Context) {
Kristof Umann30f08652018-06-18 11:50:17 +0000418
Kristof Umann0735cfb2018-08-08 12:23:02 +0000419 Optional<nonloc::LazyCompoundVal> CurrentObject = getObjectVal(Ctor, Context);
420 if (!CurrentObject)
421 return false;
422
423 const LocationContext *LC = Context.getLocationContext();
424 while ((LC = LC->getParent())) {
425
426 // If \p Ctor was called by another constructor.
427 const auto *OtherCtor = dyn_cast<CXXConstructorDecl>(LC->getDecl());
428 if (!OtherCtor)
429 continue;
430
431 Optional<nonloc::LazyCompoundVal> OtherObject =
432 getObjectVal(OtherCtor, Context);
433 if (!OtherObject)
434 continue;
435
436 // If the CurrentObject is a subregion of OtherObject, it will be analyzed
437 // during the analysis of OtherObject.
438 if (CurrentObject->getRegion()->isSubRegionOf(OtherObject->getRegion()))
Kristof Umann30f08652018-06-18 11:50:17 +0000439 return true;
Kristof Umann30f08652018-06-18 11:50:17 +0000440 }
Kristof Umann0735cfb2018-08-08 12:23:02 +0000441
Kristof Umann30f08652018-06-18 11:50:17 +0000442 return false;
443}
444
Kristof Umannf0dd1012018-09-14 08:58:21 +0000445std::string clang::ento::getVariableName(const FieldDecl *Field) {
Kristof Umann8c119092018-07-13 12:54:47 +0000446 // If Field is a captured lambda variable, Field->getName() will return with
447 // an empty string. We can however acquire it's name from the lambda's
448 // captures.
449 const auto *CXXParent = dyn_cast<CXXRecordDecl>(Field->getParent());
450
451 if (CXXParent && CXXParent->isLambda()) {
452 assert(CXXParent->captures_begin());
453 auto It = CXXParent->captures_begin() + Field->getFieldIndex();
Kristof Umannf0dd1012018-09-14 08:58:21 +0000454
455 if (It->capturesVariable())
456 return llvm::Twine("/*captured variable*/" +
457 It->getCapturedVar()->getName())
458 .str();
459
460 if (It->capturesThis())
461 return "/*'this' capture*/";
462
463 llvm_unreachable("No other capture type is expected!");
Kristof Umann8c119092018-07-13 12:54:47 +0000464 }
465
466 return Field->getName();
467}
468
Kristof Umann30f08652018-06-18 11:50:17 +0000469void ento::registerUninitializedObjectChecker(CheckerManager &Mgr) {
470 auto Chk = Mgr.registerChecker<UninitializedObjectChecker>();
Kristof Umannceb5f652018-09-14 09:07:40 +0000471
Kristof Umann6cec6c42018-09-14 09:39:26 +0000472 AnalyzerOptions &AnOpts = Mgr.getAnalyzerOptions();
473 UninitObjCheckerOptions &ChOpts = Chk->Opts;
474
475 ChOpts.IsPedantic = AnOpts.getBooleanOption(
Kristof Umann30f08652018-06-18 11:50:17 +0000476 "Pedantic", /*DefaultVal*/ false, Chk);
Kristof Umann6cec6c42018-09-14 09:39:26 +0000477 ChOpts.ShouldConvertNotesToWarnings = AnOpts.getBooleanOption(
Kristof Umann9bd44392018-06-29 11:25:24 +0000478 "NotesAsWarnings", /*DefaultVal*/ false, Chk);
Kristof Umann6cec6c42018-09-14 09:39:26 +0000479 ChOpts.CheckPointeeInitialization = AnOpts.getBooleanOption(
Kristof Umanna3f7b582018-08-07 12:55:26 +0000480 "CheckPointeeInitialization", /*DefaultVal*/ false, Chk);
Kristof Umann30f08652018-06-18 11:50:17 +0000481}