summaryrefslogtreecommitdiffstats
path: root/clang/lib/Checker
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-12-04 03:47:34 +0000
committerJohn McCall <rjmccall@apple.com>2010-12-04 03:47:34 +0000
commit34376a68c414ccf372e9d83f3251ecb08eb055f2 (patch)
tree336b12526893f3694b8cb5654fef621818daca81 /clang/lib/Checker
parent1c8ac8f027d4a7af830e91513f37a2139c684f19 (diff)
downloadbcm5719-llvm-34376a68c414ccf372e9d83f3251ecb08eb055f2.tar.gz
bcm5719-llvm-34376a68c414ccf372e9d83f3251ecb08eb055f2.zip
Although we currently have explicit lvalue-to-rvalue conversions, they're
not actually frequently used, because ImpCastExprToType only creates a node if the types differ. So explicitly create an ICE in the lvalue-to-rvalue conversion code in DefaultFunctionArrayLvalueConversion() as well as several other new places, and consistently deal with the consequences throughout the compiler. In addition, introduce a new cast kind for loading an ObjCProperty l-value, and make sure we emit those nodes whenever an ObjCProperty l-value appears that's not on the LHS of an assignment operator. This breaks a couple of rewriter tests, which I've x-failed until future development occurs on the rewriter. Ted Kremenek kindly contributed the analyzer workarounds in this patch. llvm-svn: 120890
Diffstat (limited to 'clang/lib/Checker')
-rw-r--r--clang/lib/Checker/CheckSecuritySyntaxOnly.cpp6
-rw-r--r--clang/lib/Checker/DereferenceChecker.cpp1
-rw-r--r--clang/lib/Checker/Environment.cpp3
-rw-r--r--clang/lib/Checker/GRExprEngine.cpp17
-rw-r--r--clang/lib/Checker/IdempotentOperationChecker.cpp2
5 files changed, 18 insertions, 11 deletions
diff --git a/clang/lib/Checker/CheckSecuritySyntaxOnly.cpp b/clang/lib/Checker/CheckSecuritySyntaxOnly.cpp
index 9a2ac45fa2e..0223240ce6e 100644
--- a/clang/lib/Checker/CheckSecuritySyntaxOnly.cpp
+++ b/clang/lib/Checker/CheckSecuritySyntaxOnly.cpp
@@ -187,8 +187,10 @@ void WalkAST::CheckLoopConditionForFloat(const ForStmt *FS) {
return;
// Are we comparing variables?
- const DeclRefExpr *drLHS = dyn_cast<DeclRefExpr>(B->getLHS()->IgnoreParens());
- const DeclRefExpr *drRHS = dyn_cast<DeclRefExpr>(B->getRHS()->IgnoreParens());
+ const DeclRefExpr *drLHS =
+ dyn_cast<DeclRefExpr>(B->getLHS()->IgnoreParenLValueCasts());
+ const DeclRefExpr *drRHS =
+ dyn_cast<DeclRefExpr>(B->getRHS()->IgnoreParenLValueCasts());
// Does at least one of the variables have a floating point type?
drLHS = drLHS && drLHS->getType()->isRealFloatingType() ? drLHS : NULL;
diff --git a/clang/lib/Checker/DereferenceChecker.cpp b/clang/lib/Checker/DereferenceChecker.cpp
index 747fcbe311f..af929a7af72 100644
--- a/clang/lib/Checker/DereferenceChecker.cpp
+++ b/clang/lib/Checker/DereferenceChecker.cpp
@@ -59,6 +59,7 @@ void DereferenceChecker::AddDerefSource(llvm::raw_ostream &os,
llvm::SmallVectorImpl<SourceRange> &Ranges,
const Expr *Ex,
bool loadedFrom) {
+ Ex = Ex->IgnoreParenLValueCasts();
switch (Ex->getStmtClass()) {
default:
return;
diff --git a/clang/lib/Checker/Environment.cpp b/clang/lib/Checker/Environment.cpp
index aac4afaafba..4b67bda9132 100644
--- a/clang/lib/Checker/Environment.cpp
+++ b/clang/lib/Checker/Environment.cpp
@@ -53,7 +53,8 @@ SVal Environment::getSVal(const Stmt *E, SValBuilder& svalBuilder) const {
QualType CT = C->getType();
if (CT->isVoidType())
return UnknownVal();
- if (C->getCastKind() == CK_NoOp) {
+ if (C->getCastKind() == CK_NoOp ||
+ C->getCastKind() == CK_LValueToRValue) { // temporary workaround
E = C->getSubExpr();
continue;
}
diff --git a/clang/lib/Checker/GRExprEngine.cpp b/clang/lib/Checker/GRExprEngine.cpp
index a43d36aaeb4..e737eed8d15 100644
--- a/clang/lib/Checker/GRExprEngine.cpp
+++ b/clang/lib/Checker/GRExprEngine.cpp
@@ -778,6 +778,10 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred,
S->getLocStart(),
"Error evaluating statement");
+ // Expressions to ignore.
+ if (const Expr *Ex = dyn_cast<Expr>(S))
+ S = Ex->IgnoreParenLValueCasts();
+
// FIXME: add metadata to the CFG so that we can disable
// this check when we KNOW that there is no block-level subexpression.
// The motivation is that this check requires a hashtable lookup.
@@ -814,7 +818,9 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred,
MakeNode(Dst, S, Pred, GetState(Pred));
break;
}
-
+
+ case Stmt::ParenExprClass:
+ llvm_unreachable("ParenExprs already handled.");
// Cases that should never be evaluated simply because they shouldn't
// appear in the CFG.
case Stmt::BreakStmtClass:
@@ -1039,10 +1045,6 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred,
break;
}
- case Stmt::ParenExprClass:
- Visit(cast<ParenExpr>(S)->getSubExpr()->IgnoreParens(), Pred, Dst);
- break;
-
case Stmt::ReturnStmtClass:
VisitReturnStmt(cast<ReturnStmt>(S), Pred, Dst);
break;
@@ -1113,8 +1115,8 @@ void GRExprEngine::VisitLValue(const Expr* Ex, ExplodedNode* Pred,
Ex->getLocStart(),
"Error evaluating statement");
-
- Ex = Ex->IgnoreParens();
+ // Expressions to ignore.
+ Ex = Ex->IgnoreParenLValueCasts();
if (Ex != CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(Ex)){
Dst.Add(Pred);
@@ -2661,6 +2663,7 @@ void GRExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
}
return;
+ case CK_GetObjCProperty:
case CK_Dependent:
case CK_ArrayToPointerDecay:
case CK_BitCast:
diff --git a/clang/lib/Checker/IdempotentOperationChecker.cpp b/clang/lib/Checker/IdempotentOperationChecker.cpp
index 0e23c2a0313..245caef4853 100644
--- a/clang/lib/Checker/IdempotentOperationChecker.cpp
+++ b/clang/lib/Checker/IdempotentOperationChecker.cpp
@@ -543,7 +543,7 @@ bool IdempotentOperationChecker::isTruncationExtensionAssignment(
if (VD != RHS_DR->getDecl())
return false;
- return dyn_cast<DeclRefExpr>(RHS->IgnoreParens()) == NULL;
+ return dyn_cast<DeclRefExpr>(RHS->IgnoreParenLValueCasts()) == NULL;
}
// Returns false if a path to this block was not completely analyzed, or true
OpenPOWER on IntegriCloud