analyzer: Fix embarrassing regression in BasicStore when invalidating struct
values passed-by-reference to unknown functions. llvm-svn: 67519
This commit is contained in:
parent
4a683478d5
commit
c7fef2ad53
|
@ -219,6 +219,8 @@ public:
|
||||||
|
|
||||||
~SymbolManager();
|
~SymbolManager();
|
||||||
|
|
||||||
|
static bool canSymbolicate(QualType T);
|
||||||
|
|
||||||
/// Make a unique symbol for MemRegion R according to its kind.
|
/// Make a unique symbol for MemRegion R according to its kind.
|
||||||
SymbolRef getRegionRValueSymbol(const MemRegion* R);
|
SymbolRef getRegionRValueSymbol(const MemRegion* R);
|
||||||
SymbolRef getConjuredSymbol(const Stmt* E, QualType T, unsigned VisitCount,
|
SymbolRef getConjuredSymbol(const Stmt* E, QualType T, unsigned VisitCount,
|
||||||
|
|
|
@ -526,6 +526,10 @@ Store BasicStoreManager::getInitialStore() {
|
||||||
if (VD->getStorageClass() == VarDecl::Static)
|
if (VD->getStorageClass() == VarDecl::Static)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Only handle simple types that we can symbolicate.
|
||||||
|
if (!SymbolManager::canSymbolicate(VD->getType()))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Initialize globals and parameters to symbolic values.
|
// Initialize globals and parameters to symbolic values.
|
||||||
// Initialize local variables to undefined.
|
// Initialize local variables to undefined.
|
||||||
const MemRegion *R = StateMgr.getRegion(VD);
|
const MemRegion *R = StateMgr.getRegion(VD);
|
||||||
|
|
|
@ -94,6 +94,10 @@ QualType SymbolRegionRValue::getType(ASTContext& C) const {
|
||||||
|
|
||||||
SymbolManager::~SymbolManager() {}
|
SymbolManager::~SymbolManager() {}
|
||||||
|
|
||||||
|
bool SymbolManager::canSymbolicate(QualType T) {
|
||||||
|
return Loc::IsLocType(T) || T->isIntegerType();
|
||||||
|
}
|
||||||
|
|
||||||
void SymbolReaper::markLive(SymbolRef sym) {
|
void SymbolReaper::markLive(SymbolRef sym) {
|
||||||
TheLiving = F.Add(TheLiving, sym);
|
TheLiving = F.Add(TheLiving, sym);
|
||||||
TheDead = F.Remove(TheDead, sym);
|
TheDead = F.Remove(TheDead, sym);
|
||||||
|
|
|
@ -24,6 +24,19 @@ extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
|
||||||
- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
|
- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
|
||||||
@end
|
@end
|
||||||
extern NSString * const NSConnectionReplyMode;
|
extern NSString * const NSConnectionReplyMode;
|
||||||
|
typedef float CGFloat;
|
||||||
|
typedef struct _NSPoint {
|
||||||
|
CGFloat x;
|
||||||
|
CGFloat y;
|
||||||
|
} NSPoint;
|
||||||
|
typedef struct _NSSize {
|
||||||
|
CGFloat width;
|
||||||
|
CGFloat height;
|
||||||
|
} NSSize;
|
||||||
|
typedef struct _NSRect {
|
||||||
|
NSPoint origin;
|
||||||
|
NSSize size;
|
||||||
|
} NSRect;
|
||||||
|
|
||||||
// Reduced test case from crash in <rdar://problem/6253157>
|
// Reduced test case from crash in <rdar://problem/6253157>
|
||||||
@interface A @end
|
@interface A @end
|
||||||
|
@ -201,3 +214,14 @@ int rdar6695527(double x) {
|
||||||
if (!x) { return 0; }
|
if (!x) { return 0; }
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <rdar://problem/6708148> - Test that we properly invalidate structs
|
||||||
|
// passed-by-reference to a function.
|
||||||
|
void pr6708148_invalidate(NSRect *x);
|
||||||
|
void pr6708148_use(NSRect x);
|
||||||
|
void pr6708148_test(void) {
|
||||||
|
NSRect x;
|
||||||
|
pr6708148_invalidate(&x);
|
||||||
|
pr6708148_use(x); // no-warning
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue