[cfe-commits] r158341 - in /cfe/trunk: lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/ExprEngineC.cpp lib/StaticAnalyzer/Core/RegionStore.cpp test/Analysis/casts.cpp
Jordan Rose
jordan_rose at apple.com
Mon Jun 11 17:20:22 PDT 2012
Author: jrose
Date: Mon Jun 11 19:20:22 2012
New Revision: 158341
URL: http://llvm.org/viewvc/llvm-project?rev=158341&view=rev
Log:
Revert "[analyzer] Treat LValueBitCasts like regular pointer bit casts."
This does not actually give us the right behavior for reinterpret_cast
of references. Reverting so I can think about it some more.
This reverts commit 50a75a6e26a49011150067adac556ef978639fe6.
Removed:
cfe/trunk/test/Analysis/casts.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=158341&r1=158340&r2=158341&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Jun 11 19:20:22 2012
@@ -1641,7 +1641,7 @@
assert(!isa<NonLoc>(location) && "location cannot be a NonLoc.");
assert(!isa<loc::ObjCPropRef>(location));
- // Are we loading from a reference? This actually results in two loads; one
+ // Are we loading from a region? This actually results in two loads; one
// to fetch the address of the referenced value and one to fetch the
// referenced value.
if (const TypedValueRegion *TR =
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=158341&r1=158340&r2=158341&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Mon Jun 11 19:20:22 2012
@@ -279,7 +279,6 @@
case CK_Dependent:
case CK_ArrayToPointerDecay:
case CK_BitCast:
- case CK_LValueBitCast:
case CK_IntegralCast:
case CK_NullToPointer:
case CK_IntegralToPointer:
@@ -378,7 +377,8 @@
case CK_UserDefinedConversion:
case CK_ConstructorConversion:
case CK_VectorSplat:
- case CK_MemberPointerToBoolean: {
+ case CK_MemberPointerToBoolean:
+ case CK_LValueBitCast: {
// Recover some path-sensitivty by conjuring a new value.
QualType resultType = CastE->getType();
if (CastE->isGLValue())
Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=158341&r1=158340&r2=158341&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Mon Jun 11 19:20:22 2012
@@ -878,15 +878,10 @@
if (!ArrayR)
return UnknownVal();
- // Extract the element type from the array region's ValueType.
- // Be careful about weird things happening due to user-written casts.
- QualType T = ArrayR->getValueType();
- if (const ArrayType *AT = Ctx.getAsArrayType(T))
- T = AT->getElementType();
- else if (const PointerType *PT = T->getAs<PointerType>())
- T = PT->getPointeeType();
- else
- return UnknownVal();
+ // Strip off typedefs from the ArrayRegion's ValueType.
+ QualType T = ArrayR->getValueType().getDesugaredType(Ctx);
+ const ArrayType *AT = cast<ArrayType>(T);
+ T = AT->getElementType();
NonLoc ZeroIdx = svalBuilder.makeZeroArrayIndex();
return loc::MemRegionVal(MRMgr.getElementRegion(T, ZeroIdx, ArrayR, Ctx));
Removed: cfe/trunk/test/Analysis/casts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.cpp?rev=158340&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/casts.cpp (original)
+++ cfe/trunk/test/Analysis/casts.cpp (removed)
@@ -1,36 +0,0 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
-
-void fill_r (int * const &x);
-
-char testPointer () {
- int x[8];
- int *xp = x;
- fill_r(xp);
-
- return x[0]; // no-warning
-}
-
-char testArray () {
- int x[8];
- fill_r(x);
-
- return x[0]; // no-warning
-}
-
-char testReferenceCast () {
- int x[8];
- int *xp = x;
- fill_r(reinterpret_cast<int * const &>(xp));
-
- return x[0]; // no-warning
-}
-
-
-void fill (int *x);
-char testReferenceCastRValue () {
- int x[8];
- int *xp = x;
- fill(reinterpret_cast<int * const &>(xp));
-
- return x[0]; // no-warning
-}
More information about the cfe-commits
mailing list