From 477323d58a0de352c6a61e08b5a83127c4adc904 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Wed, 14 Apr 2010 06:29:29 +0000 Subject: [PATCH] Add support for CXXBoolLiteralExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101238 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Checker/PathSensitive/ValueManager.h | 6 ++++++ lib/Checker/Environment.cpp | 7 +++++++ lib/Checker/GRExprEngine.cpp | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/clang/Checker/PathSensitive/ValueManager.h b/include/clang/Checker/PathSensitive/ValueManager.h index f80ad42174..5a9d54d337 100644 --- a/include/clang/Checker/PathSensitive/ValueManager.h +++ b/include/clang/Checker/PathSensitive/ValueManager.h @@ -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)); } diff --git a/lib/Checker/Environment.cpp b/lib/Checker/Environment.cpp index be1a677d91..addfc21c18 100644 --- a/lib/Checker/Environment.cpp +++ b/lib/Checker/Environment.cpp @@ -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(E)); + } case Stmt::IntegerLiteralClass: { // In C++, this expression may have been bound to a temporary object. SVal const *X = ExprBindings.lookup(E); diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index 88c4210856..8f74a5b1e8 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -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; -- 2.40.0