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
|
@ -218,6 +218,8 @@ public:
|
|||
: SymbolCounter(0), BPAlloc(bpalloc), Ctx(ctx) {}
|
||||
|
||||
~SymbolManager();
|
||||
|
||||
static bool canSymbolicate(QualType T);
|
||||
|
||||
/// Make a unique symbol for MemRegion R according to its kind.
|
||||
SymbolRef getRegionRValueSymbol(const MemRegion* R);
|
||||
|
|
|
@ -525,6 +525,10 @@ Store BasicStoreManager::getInitialStore() {
|
|||
// Punt on static variables for now.
|
||||
if (VD->getStorageClass() == VarDecl::Static)
|
||||
continue;
|
||||
|
||||
// Only handle simple types that we can symbolicate.
|
||||
if (!SymbolManager::canSymbolicate(VD->getType()))
|
||||
continue;
|
||||
|
||||
// Initialize globals and parameters to symbolic values.
|
||||
// Initialize local variables to undefined.
|
||||
|
|
|
@ -94,6 +94,10 @@ QualType SymbolRegionRValue::getType(ASTContext& C) const {
|
|||
|
||||
SymbolManager::~SymbolManager() {}
|
||||
|
||||
bool SymbolManager::canSymbolicate(QualType T) {
|
||||
return Loc::IsLocType(T) || T->isIntegerType();
|
||||
}
|
||||
|
||||
void SymbolReaper::markLive(SymbolRef sym) {
|
||||
TheLiving = F.Add(TheLiving, 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,...;
|
||||
@end
|
||||
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>
|
||||
@interface A @end
|
||||
|
@ -201,3 +214,14 @@ int rdar6695527(double x) {
|
|||
if (!x) { return 0; }
|
||||
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