[cfe-commits] r101238 - in /cfe/trunk: include/clang/Checker/PathSensitive/ValueManager.h lib/Checker/Environment.cpp lib/Checker/GRExprEngine.cpp

Zhongxing Xu xuzhongxing at gmail.com
Tue Apr 13 23:29:30 PDT 2010


Author: zhongxingxu
Date: Wed Apr 14 01:29:29 2010
New Revision: 101238

URL: http://llvm.org/viewvc/llvm-project?rev=101238&view=rev
Log:
Add support for CXXBoolLiteralExpr.

Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h
    cfe/trunk/lib/Checker/Environment.cpp
    cfe/trunk/lib/Checker/GRExprEngine.cpp

Modified: cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h?rev=101238&r1=101237&r2=101238&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h Wed Apr 14 01:29:29 2010
@@ -22,6 +22,7 @@
 #include "clang/Checker/PathSensitive/BasicValueFactory.h"
 #include "clang/Checker/PathSensitive/SymbolManager.h"
 #include "clang/Checker/PathSensitive/SValuator.h"
+#include "clang/AST/ExprCXX.h"
 
 namespace llvm { class BumpPtrAllocator; }
 
@@ -133,6 +134,11 @@
                                         I->getType()->isUnsignedIntegerType()));
   }
 
+  nonloc::ConcreteInt makeIntVal(const CXXBoolLiteralExpr *E) {
+    return E->getValue() ? nonloc::ConcreteInt(BasicVals.getValue(1, 1, true))
+                         : nonloc::ConcreteInt(BasicVals.getValue(0, 1, true));
+  }
+
   nonloc::ConcreteInt makeIntVal(const llvm::APSInt& V) {
     return nonloc::ConcreteInt(BasicVals.getValue(V));
   }

Modified: cfe/trunk/lib/Checker/Environment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/Environment.cpp?rev=101238&r1=101237&r2=101238&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/Environment.cpp (original)
+++ cfe/trunk/lib/Checker/Environment.cpp Wed Apr 14 01:29:29 2010
@@ -37,6 +37,13 @@
         return ValMgr.makeIntVal(C->getValue(), C->getType());
       }
 
+      case Stmt::CXXBoolLiteralExprClass: {
+        const SVal *X = ExprBindings.lookup(E);
+        if (X) 
+          return *X;
+        else 
+          return ValMgr.makeIntVal(cast<CXXBoolLiteralExpr>(E));
+      }
       case Stmt::IntegerLiteralClass: {
         // In C++, this expression may have been bound to a temporary object.
         SVal const *X = ExprBindings.lookup(E);

Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=101238&r1=101237&r2=101238&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Wed Apr 14 01:29:29 2010
@@ -587,7 +587,6 @@
       llvm_unreachable("Unhandled stmt class");
     // C++ stuff we don't support yet.
     case Stmt::CXXTypeidExprClass:
-    case Stmt::CXXBoolLiteralExprClass:
     case Stmt::CXXNullPtrLiteralExprClass:
     case Stmt::CXXThrowExprClass:
     case Stmt::CXXDefaultArgExprClass:
@@ -616,6 +615,7 @@
     case Stmt::AddrLabelExprClass:
     case Stmt::IntegerLiteralClass:
     case Stmt::CharacterLiteralClass:
+    case Stmt::CXXBoolLiteralExprClass:
     case Stmt::FloatingLiteralClass:
     case Stmt::ImplicitValueInitExprClass:
     case Stmt::ObjCSuperExprClass:
@@ -945,6 +945,7 @@
       return;
 
     // In C++, binding an rvalue to a reference requires to create an object.
+    case Stmt::CXXBoolLiteralExprClass:
     case Stmt::IntegerLiteralClass:
       CreateCXXTemporaryObject(Ex, Pred, Dst);
       return;





More information about the cfe-commits mailing list