[llvm-branch-commits] [cfe-branch] r195228 - Merging r195174:
Bill Wendling
isanbard at gmail.com
Tue Nov 19 22:47:05 PST 2013
Author: void
Date: Wed Nov 20 00:47:04 2013
New Revision: 195228
URL: http://llvm.org/viewvc/llvm-project?rev=195228&view=rev
Log:
Merging r195174:
------------------------------------------------------------------------
r195174 | zaks | 2013-11-19 16:11:42 -0800 (Tue, 19 Nov 2013) | 1 line
[analyzer] Fix an infinite recursion in region invalidation by adding block count to the BlockDataRegion.
------------------------------------------------------------------------
Modified:
cfe/branches/release_34/ (props changed)
cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
cfe/branches/release_34/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/branches/release_34/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/branches/release_34/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/branches/release_34/test/Analysis/blocks.m
Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 20 00:47:04 2013
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=195228&r1=195227&r2=195228&view=diff
==============================================================================
--- cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original)
+++ cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Wed Nov 20 00:47:04 2013
@@ -635,12 +635,14 @@ class BlockDataRegion : public TypedRegi
friend class MemRegionManager;
const BlockTextRegion *BC;
const LocationContext *LC; // Can be null */
+ unsigned BlockCount;
void *ReferencedVars;
void *OriginalVars;
BlockDataRegion(const BlockTextRegion *bc, const LocationContext *lc,
- const MemRegion *sreg)
+ unsigned count, const MemRegion *sreg)
: TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
+ BlockCount(count),
ReferencedVars(0), OriginalVars(0) {}
public:
@@ -692,7 +694,8 @@ public:
void Profile(llvm::FoldingSetNodeID& ID) const;
static void ProfileRegion(llvm::FoldingSetNodeID&, const BlockTextRegion *,
- const LocationContext *, const MemRegion *);
+ const LocationContext *, unsigned,
+ const MemRegion *);
static bool classof(const MemRegion* R) {
return R->getKind() == BlockDataRegionKind;
@@ -1270,7 +1273,8 @@ public:
/// argument is allowed to be NULL for cases where we have no known
/// context.
const BlockDataRegion *getBlockDataRegion(const BlockTextRegion *bc,
- const LocationContext *lc = NULL);
+ const LocationContext *lc,
+ unsigned blockCount);
/// Create a CXXTempObjectRegion for temporaries which are lifetime-extended
/// by static references. This differs from getCXXTempObjectRegion in the
Modified: cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=195228&r1=195227&r2=195228&view=diff
==============================================================================
--- cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h (original)
+++ cfe/branches/release_34/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Wed Nov 20 00:47:04 2013
@@ -200,7 +200,8 @@ public:
DefinedSVal getFunctionPointer(const FunctionDecl *func);
DefinedSVal getBlockPointer(const BlockDecl *block, CanQualType locTy,
- const LocationContext *locContext);
+ const LocationContext *locContext,
+ unsigned blockCount);
/// Returns the value of \p E, if it can be determined in a non-path-sensitive
/// manner.
Modified: cfe/branches/release_34/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=195228&r1=195227&r2=195228&view=diff
==============================================================================
--- cfe/branches/release_34/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/branches/release_34/lib/StaticAnalyzer/Core/ExprEngineC.cpp Wed Nov 20 00:47:04 2013
@@ -184,7 +184,8 @@ void ExprEngine::VisitBlockExpr(const Bl
// Get the value of the block itself.
SVal V = svalBuilder.getBlockPointer(BE->getBlockDecl(), T,
- Pred->getLocationContext());
+ Pred->getLocationContext(),
+ currBldrCtx->blockCount());
ProgramStateRef State = Pred->getState();
Modified: cfe/branches/release_34/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=195228&r1=195227&r2=195228&view=diff
==============================================================================
--- cfe/branches/release_34/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/branches/release_34/lib/StaticAnalyzer/Core/MemRegion.cpp Wed Nov 20 00:47:04 2013
@@ -383,15 +383,17 @@ void BlockTextRegion::Profile(llvm::Fold
void BlockDataRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
const BlockTextRegion *BC,
const LocationContext *LC,
+ unsigned BlkCount,
const MemRegion *sReg) {
ID.AddInteger(MemRegion::BlockDataRegionKind);
ID.AddPointer(BC);
ID.AddPointer(LC);
+ ID.AddInteger(BlkCount);
ID.AddPointer(sReg);
}
void BlockDataRegion::Profile(llvm::FoldingSetNodeID& ID) const {
- BlockDataRegion::ProfileRegion(ID, BC, LC, getSuperRegion());
+ BlockDataRegion::ProfileRegion(ID, BC, LC, BlockCount, getSuperRegion());
}
void CXXTempObjectRegion::ProfileRegion(llvm::FoldingSetNodeID &ID,
@@ -464,7 +466,14 @@ void BlockTextRegion::dumpToStream(raw_o
}
void BlockDataRegion::dumpToStream(raw_ostream &os) const {
- os << "block_data{" << BC << '}';
+ os << "block_data{" << BC;
+ os << "; ";
+ for (BlockDataRegion::referenced_vars_iterator
+ I = referenced_vars_begin(),
+ E = referenced_vars_end(); I != E; ++I)
+ os << "(" << I.getCapturedRegion() << "," <<
+ I.getOriginalRegion() << ") ";
+ os << '}';
}
void CompoundLiteralRegion::dumpToStream(raw_ostream &os) const {
@@ -839,7 +848,8 @@ const VarRegion *MemRegionManager::getVa
const BlockDataRegion *
MemRegionManager::getBlockDataRegion(const BlockTextRegion *BC,
- const LocationContext *LC) {
+ const LocationContext *LC,
+ unsigned blockCount) {
const MemRegion *sReg = 0;
const BlockDecl *BD = BC->getDecl();
if (!BD->hasCaptures()) {
@@ -861,7 +871,7 @@ MemRegionManager::getBlockDataRegion(con
}
}
- return getSubRegion<BlockDataRegion>(BC, LC, sReg);
+ return getSubRegion<BlockDataRegion>(BC, LC, blockCount, sReg);
}
const CXXTempObjectRegion *
Modified: cfe/branches/release_34/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=195228&r1=195227&r2=195228&view=diff
==============================================================================
--- cfe/branches/release_34/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/branches/release_34/lib/StaticAnalyzer/Core/SValBuilder.cpp Wed Nov 20 00:47:04 2013
@@ -202,10 +202,12 @@ DefinedSVal SValBuilder::getFunctionPoin
DefinedSVal SValBuilder::getBlockPointer(const BlockDecl *block,
CanQualType locTy,
- const LocationContext *locContext) {
+ const LocationContext *locContext,
+ unsigned blockCount) {
const BlockTextRegion *BC =
MemMgr.getBlockTextRegion(block, locTy, locContext->getAnalysisDeclContext());
- const BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, locContext);
+ const BlockDataRegion *BD = MemMgr.getBlockDataRegion(BC, locContext,
+ blockCount);
return loc::MemRegionVal(BD);
}
Modified: cfe/branches/release_34/test/Analysis/blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/Analysis/blocks.m?rev=195228&r1=195227&r2=195228&view=diff
==============================================================================
--- cfe/branches/release_34/test/Analysis/blocks.m (original)
+++ cfe/branches/release_34/test/Analysis/blocks.m Wed Nov 20 00:47:04 2013
@@ -146,3 +146,19 @@ void testReturnVariousSignatures() {
return 42;
}();
}
+
+// This test used to cause infinite loop in the region invalidation.
+void blockCapturesItselfInTheLoop(int x, int m) {
+ void (^assignData)(int) = ^(int x){
+ x++;
+ };
+ while (m < 0) {
+ void (^loop)(int);
+ loop = ^(int x) {
+ assignData(x);
+ };
+ assignData = loop;
+ m++;
+ }
+ assignData(x);
+}
More information about the llvm-branch-commits
mailing list