summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/Analysis/GRExprEngine.cpp5
-rw-r--r--clang/Analysis/ValueState.cpp7
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/Analysis/GRExprEngine.cpp b/clang/Analysis/GRExprEngine.cpp
index 8df9e5f305a..6d45beab327 100644
--- a/clang/Analysis/GRExprEngine.cpp
+++ b/clang/Analysis/GRExprEngine.cpp
@@ -449,8 +449,9 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* E, NodeTy* Pred, NodeSet& Dst) {
QualType T = CastE->getType();
- // Check for redundant casts.
- if (E->getType() == T ||
+ // Check for redundant casts or casting to "void"
+ if (T->isVoidType() ||
+ E->getType() == T ||
(T->isPointerType() && E->getType()->isFunctionType())) {
Dst.Add(Pred);
return;
diff --git a/clang/Analysis/ValueState.cpp b/clang/Analysis/ValueState.cpp
index 963864662a9..5796238d48d 100644
--- a/clang/Analysis/ValueState.cpp
+++ b/clang/Analysis/ValueState.cpp
@@ -252,6 +252,10 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
case Stmt::ImplicitCastExprClass: {
ImplicitCastExpr* C = cast<ImplicitCastExpr>(E);
QualType CT = C->getType();
+
+ if (CT->isVoidType())
+ return UnknownVal();
+
QualType ST = C->getSubExpr()->getType();
if (CT == ST || (CT->isPointerType() && ST->isFunctionType())) {
@@ -266,6 +270,9 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
QualType CT = C->getType();
QualType ST = C->getSubExpr()->getType();
+ if (CT->isVoidType())
+ return UnknownVal();
+
if (CT == ST || (CT->isPointerType() && ST->isFunctionType())) {
E = C->getSubExpr();
continue;
OpenPOWER on IntegriCloud