[cfe-commits] r57777 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Sat Oct 18 15:20:20 PDT 2008


Author: kremenek
Date: Sat Oct 18 17:20:20 2008
New Revision: 57777

URL: http://llvm.org/viewvc/llvm-project?rev=57777&view=rev
Log:
Add support in GRExprEngine for UnaryOperator::AlignOf.  This fixes one crash report in PR 2796.

Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=57777&r1=57776&r2=57777&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Sat Oct 18 17:20:20 2008
@@ -1780,6 +1780,23 @@
       
       return;
     }
+     
+    case UnaryOperator::AlignOf: {
+      
+      QualType T = U->getSubExpr()->getType();
+      
+      // FIXME: Add support for VLAs.
+      
+      if (!T.getTypePtr()->isConstantSizeType())
+        return;
+      
+      uint64_t size = getContext().getTypeAlign(T) / 8;                
+      const GRState* St = GetState(Pred);
+      St = SetSVal(St, U, NonLoc::MakeVal(getBasicVals(), size, U->getType()));
+      
+      MakeNode(Dst, U, Pred, St);
+      return;
+    }
       
     case UnaryOperator::SizeOf: {
             

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=57777&r1=57776&r2=57777&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Sat Oct 18 17:20:20 2008
@@ -9,3 +9,7 @@
 }
 @end
 
+// Reduced test case from crash in PR 2796;
+//  http://llvm.org/bugs/show_bug.cgi?id=2796
+
+unsigned foo(unsigned x) { return __alignof__((x)) + sizeof(x); }





More information about the cfe-commits mailing list