]> granicus.if.org Git - clang/commitdiff
Add support for CXXBoolLiteralExpr.
authorZhongxing Xu <xuzhongxing@gmail.com>
Wed, 14 Apr 2010 06:29:29 +0000 (06:29 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Wed, 14 Apr 2010 06:29:29 +0000 (06:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101238 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Checker/PathSensitive/ValueManager.h
lib/Checker/Environment.cpp
lib/Checker/GRExprEngine.cpp

index f80ad421742fa49492dfd7d0067e8ab3c766b04e..5a9d54d337b0e15ffb5006a8e592dd591e67475b 100644 (file)
@@ -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 @@ public:
                                         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));
   }
index be1a677d9118fb20561f3683676b82a38a2ee7e7..addfc21c1805e77cb160f6cd651655e06540709d 100644 (file)
@@ -37,6 +37,13 @@ SVal Environment::GetSVal(const Stmt *E, ValueManager& ValMgr) const {
         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);
index 88c421085611223a4e32de6a4eb1f598ac14ff2e..8f74a5b1e80370a8ee80c17dea8b0ad3a488adb0 100644 (file)
@@ -587,7 +587,6 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
       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 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
     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 @@ void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
       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;