diff options
author | Noel Grandin <noel@peralex.com> | 2015-05-28 16:18:34 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-05-29 08:48:41 +0200 |
commit | e0b2e6e3f767240016133dd2d55e0bfb9192ca39 (patch) | |
tree | 16373b19bd514dfad5fa4f3eea128ed801e5b726 /compilerplugins | |
parent | 6140ca9f1d728475e332f9fa96ee62dda58687ea (diff) |
loplugin:loopvartoosmall
Change-Id: Icbe68b31d4ab04ca3cd9f572e3598413946a75c7
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/loopvartoosmall.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compilerplugins/clang/loopvartoosmall.cxx b/compilerplugins/clang/loopvartoosmall.cxx index cee6f0247e54..a742af61fb12 100644 --- a/compilerplugins/clang/loopvartoosmall.cxx +++ b/compilerplugins/clang/loopvartoosmall.cxx @@ -49,7 +49,7 @@ bool LoopVarTooSmall::VisitForStmt( const ForStmt* stmt ) { if (ignoreLocation( stmt )) return true; - // ignore SAL for now + // ignore sal/ module for now StringRef aFileName = getFilename(stmt->getLocStart()); if (aFileName.startswith(SRCDIR "/sal/")) { return true; @@ -76,8 +76,9 @@ bool LoopVarTooSmall::VisitForStmt( const ForStmt* stmt ) if (binOp->getOpcode() != BO_LT && binOp->getOpcode() != BO_LE) return true; const Expr* binOpRHS = binOp->getRHS(); - // ignore complex expressions for now - if (isa<BinaryOperator>(binOpRHS)) + // ignore complex expressions for now, promotion rules on conditions like "i < (size()+1)" + // make it hard to guess at a correct type. + if (isa<BinaryOperator>(binOpRHS) || isa<ParenExpr>(binOpRHS)) return true; if (isa<ImplicitCastExpr>(binOpRHS)) { const ImplicitCastExpr* castExpr = dyn_cast<ImplicitCastExpr>(binOpRHS); @@ -105,13 +106,13 @@ bool LoopVarTooSmall::VisitForStmt( const ForStmt* stmt ) "loop index type is smaller than length type. " + qt.getAsString() + " < " + qt2.getAsString(), stmt->getInit()->getLocStart()) << stmt->getInit()->getSourceRange(); -// stmt->getCond()->dump(); + //stmt->getCond()->dump(); } return true; } -loplugin::Plugin::Registration< LoopVarTooSmall > X("loopvartoosmall", false); +loplugin::Plugin::Registration< LoopVarTooSmall > X("loopvartoosmall", true); } |