[cfe-commits] r66211 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/casts.m
Ted Kremenek
kremenek at apple.com
Thu Mar 5 14:47:06 PST 2009
Author: kremenek
Date: Thu Mar 5 16:47:06 2009
New Revision: 66211
URL: http://llvm.org/viewvc/llvm-project?rev=66211&view=rev
Log:
Fix another GRExprEngine::VisitCast regression: handle casts of void* to function pointers.
Modified:
cfe/trunk/lib/Analysis/GRExprEngine.cpp
cfe/trunk/test/Analysis/casts.m
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=66211&r1=66210&r2=66211&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Thu Mar 5 16:47:06 2009
@@ -1818,7 +1818,14 @@
}
// Check for casts from a region to a specific type.
- if (loc::MemRegionVal *RV = dyn_cast<loc::MemRegionVal>(&V)) {
+ if (loc::MemRegionVal *RV = dyn_cast<loc::MemRegionVal>(&V)) {
+ // FIXME: For TypedViewRegions, we should handle the case where the
+ // underlying symbolic pointer is a function pointer or
+ // block pointer.
+
+ // FIXME: We should handle the case where we strip off view layers to get
+ // to a desugared type.
+
assert(Loc::IsLocType(T));
assert(Loc::IsLocType(ExTy));
@@ -1848,6 +1855,14 @@
// Just pass through symbols that are function or block pointers.
if (SymTy->isFunctionPointerType() || SymTy->isBlockPointerType())
goto PassThrough;
+
+ // Are we casting to a function or block pointer?
+ if (T->isFunctionPointerType() || T->isBlockPointerType()) {
+ // FIXME: We should verify that the underlying type of the symbolic
+ // pointer is a void* (or maybe char*). Other things are an abuse
+ // of the type system.
+ goto PassThrough;
+ }
StoreManager& StoreMgr = getStoreManager();
const MemRegion* R =
Modified: cfe/trunk/test/Analysis/casts.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.m?rev=66211&r1=66210&r2=66211&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/casts.m (original)
+++ cfe/trunk/test/Analysis/casts.m Thu Mar 5 16:47:06 2009
@@ -4,8 +4,7 @@
// Test function pointer casts. Currently we track function addresses using
// loc::FunctionVal. Because casts can be arbitrary, do we need to model
// functions with regions?
-
-typedef void (*MyFuncTest1)(void);
+typedef void* (*MyFuncTest1)(void);
MyFuncTest1 test1_aux(void);
void test1(void) {
@@ -14,3 +13,10 @@
p = ((void*) test1_aux());
if (p != ((void*) 0)) x = (*p)();
}
+
+// Test casts from void* to function pointers. Same issue as above:
+// should we eventually model function pointers using regions?
+void* test2(void *p) {
+ MyFuncTest1 fp = (MyFuncTest1) p;
+ return (*fp)();
+}
More information about the cfe-commits
mailing list