diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-24 20:26:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-24 20:26:31 +0000 |
commit | b9cb11391dc7096a2174fefd45b81057859183ec (patch) | |
tree | 83ef437befa312e35e1ea0ca588e6e360441ca6b /clang/lib/Analysis/CheckSecuritySyntaxOnly.cpp | |
parent | a39aaa5fd54191697f79fb011a9d12ad6da1c773 (diff) | |
download | bcm5719-llvm-b9cb11391dc7096a2174fefd45b81057859183ec.tar.gz bcm5719-llvm-b9cb11391dc7096a2174fefd45b81057859183ec.zip |
In the "use of floating point variable as loop counter" check, check
if the DeclRefExpr is a float, not just either argument.
llvm-svn: 76998
Diffstat (limited to 'clang/lib/Analysis/CheckSecuritySyntaxOnly.cpp')
-rw-r--r-- | clang/lib/Analysis/CheckSecuritySyntaxOnly.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Analysis/CheckSecuritySyntaxOnly.cpp b/clang/lib/Analysis/CheckSecuritySyntaxOnly.cpp index 5c98a526b7f..17fc6d7c32e 100644 --- a/clang/lib/Analysis/CheckSecuritySyntaxOnly.cpp +++ b/clang/lib/Analysis/CheckSecuritySyntaxOnly.cpp @@ -143,16 +143,18 @@ void WalkAST::CheckLoopConditionForFloat(const ForStmt *FS) { if (!B) return; - // The actual error condition. - if (!((B->isRelationalOp() || B->isEqualityOp()) && - ((B->getLHS()->getType()->isFloatingType() || - B->getRHS()->getType()->isFloatingType())))) + // Is this a comparison? + if (!(B->isRelationalOp() || B->isEqualityOp())) return; - + // Are we comparing variables? const DeclRefExpr *drLHS = dyn_cast<DeclRefExpr>(B->getLHS()->IgnoreParens()); const DeclRefExpr *drRHS = dyn_cast<DeclRefExpr>(B->getRHS()->IgnoreParens()); + // Does at least one of the variables have a floating point type? + drLHS = drLHS && drLHS->getType()->isFloatingType() ? drLHS : NULL; + drRHS = drRHS && drRHS->getType()->isFloatingType() ? drRHS : NULL; + if (!drLHS && !drRHS) return; |