[PATCH] D51322: [analyzer] [NFC] Do not define a class inside a function
George Karpenkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 29 13:31:37 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340964: [analyzer] [NFC] Move class definition out of the function (authored by george.karpenkov, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D51322?vs=162745&id=163179#toc
Repository:
rL LLVM
https://reviews.llvm.org/D51322
Files:
cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -196,6 +196,45 @@
return false;
}
+class FindUninitializedField {
+public:
+ SmallVector<const FieldDecl *, 10> FieldChain;
+
+private:
+ StoreManager &StoreMgr;
+ MemRegionManager &MrMgr;
+ Store store;
+
+public:
+ FindUninitializedField(StoreManager &storeMgr, MemRegionManager &mrMgr,
+ Store s)
+ : StoreMgr(storeMgr), MrMgr(mrMgr), store(s) {}
+
+ bool Find(const TypedValueRegion *R) {
+ QualType T = R->getValueType();
+ if (const RecordType *RT = T->getAsStructureType()) {
+ const RecordDecl *RD = RT->getDecl()->getDefinition();
+ assert(RD && "Referred record has no definition");
+ for (const auto *I : RD->fields()) {
+ const FieldRegion *FR = MrMgr.getFieldRegion(I, R);
+ FieldChain.push_back(I);
+ T = I->getType();
+ if (T->getAsStructureType()) {
+ if (Find(FR))
+ return true;
+ } else {
+ const SVal &V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
+ if (V.isUndef())
+ return true;
+ }
+ FieldChain.pop_back();
+ }
+ }
+
+ return false;
+ }
+};
+
bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
SVal V,
SourceRange ArgRange,
@@ -232,47 +271,7 @@
if (!CheckUninitFields)
return false;
- if (Optional<nonloc::LazyCompoundVal> LV =
- V.getAs<nonloc::LazyCompoundVal>()) {
-
- class FindUninitializedField {
- public:
- SmallVector<const FieldDecl *, 10> FieldChain;
- private:
- StoreManager &StoreMgr;
- MemRegionManager &MrMgr;
- Store store;
- public:
- FindUninitializedField(StoreManager &storeMgr,
- MemRegionManager &mrMgr, Store s)
- : StoreMgr(storeMgr), MrMgr(mrMgr), store(s) {}
-
- bool Find(const TypedValueRegion *R) {
- QualType T = R->getValueType();
- if (const RecordType *RT = T->getAsStructureType()) {
- const RecordDecl *RD = RT->getDecl()->getDefinition();
- assert(RD && "Referred record has no definition");
- for (const auto *I : RD->fields()) {
- const FieldRegion *FR = MrMgr.getFieldRegion(I, R);
- FieldChain.push_back(I);
- T = I->getType();
- if (T->getAsStructureType()) {
- if (Find(FR))
- return true;
- }
- else {
- const SVal &V = StoreMgr.getBinding(store, loc::MemRegionVal(FR));
- if (V.isUndef())
- return true;
- }
- FieldChain.pop_back();
- }
- }
-
- return false;
- }
- };
-
+ if (auto LV = V.getAs<nonloc::LazyCompoundVal>()) {
const LazyCompoundValData *D = LV->getCVData();
FindUninitializedField F(C.getState()->getStateManager().getStoreManager(),
C.getSValBuilder().getRegionManager(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51322.163179.patch
Type: text/x-patch
Size: 3292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180829/fd728a5d/attachment.bin>
More information about the llvm-commits
mailing list