[cfe-commits] r67519 - in /cfe/trunk: include/clang/Analysis/PathSensitive/SymbolManager.h lib/Analysis/BasicStore.cpp lib/Analysis/SymbolManager.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Mon Mar 23 08:43:00 PDT 2009
Author: kremenek
Date: Mon Mar 23 10:42:58 2009
New Revision: 67519
URL: http://llvm.org/viewvc/llvm-project?rev=67519&view=rev
Log:
analyzer: Fix embarrassing regression in BasicStore when invalidating struct
values passed-by-reference to unknown functions.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h
cfe/trunk/lib/Analysis/BasicStore.cpp
cfe/trunk/lib/Analysis/SymbolManager.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h?rev=67519&r1=67518&r2=67519&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h Mon Mar 23 10:42:58 2009
@@ -218,6 +218,8 @@
: 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);
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=67519&r1=67518&r2=67519&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Mon Mar 23 10:42:58 2009
@@ -525,6 +525,10 @@
// 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.
Modified: cfe/trunk/lib/Analysis/SymbolManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SymbolManager.cpp?rev=67519&r1=67518&r2=67519&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/SymbolManager.cpp (original)
+++ cfe/trunk/lib/Analysis/SymbolManager.cpp Mon Mar 23 10:42:58 2009
@@ -94,6 +94,10 @@
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);
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=67519&r1=67518&r2=67519&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Mon Mar 23 10:42:58 2009
@@ -24,6 +24,19 @@
- (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 @@
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
+}
+
More information about the cfe-commits
mailing list