analyzer: Fix embarrassing regression in BasicStore when invalidating struct

values passed-by-reference to unknown functions.

llvm-svn: 67519
This commit is contained in:
Ted Kremenek 2009-03-23 15:42:58 +00:00
parent 4a683478d5
commit c7fef2ad53
4 changed files with 34 additions and 0 deletions

View File

@ -219,6 +219,8 @@ public:
~SymbolManager();
static bool canSymbolicate(QualType T);
/// Make a unique symbol for MemRegion R according to its kind.
SymbolRef getRegionRValueSymbol(const MemRegion* R);
SymbolRef getConjuredSymbol(const Stmt* E, QualType T, unsigned VisitCount,

View File

@ -526,6 +526,10 @@ Store BasicStoreManager::getInitialStore() {
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.
const MemRegion *R = StateMgr.getRegion(VD);

View File

@ -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);

View File

@ -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
}