summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/cppunitassertequals.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/cppunitassertequals.cxx')
-rw-r--r--compilerplugins/clang/cppunitassertequals.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/compilerplugins/clang/cppunitassertequals.cxx b/compilerplugins/clang/cppunitassertequals.cxx
index 56f13b822163..26879fae9f95 100644
--- a/compilerplugins/clang/cppunitassertequals.cxx
+++ b/compilerplugins/clang/cppunitassertequals.cxx
@@ -132,6 +132,19 @@ bool CppunitAssertEquals::VisitCallExpr(const CallExpr* callExpr)
callExpr->getExprLoc())
<< callExpr->getSourceRange();
}
+ if (loplugin::DeclCheck(decl).Function("assertDoubleEquals").
+ Namespace("CppUnit").GlobalNamespace())
+ {
+ // can happen in template test code that both params are compile time constants
+ if (isCompileTimeConstant(callExpr->getArg(0)))
+ return true;
+ if (isCompileTimeConstant(callExpr->getArg(1)))
+ report(
+ DiagnosticsEngine::Warning,
+ "CPPUNIT_ASSERT_DOUBLES_EQUALS parameters look switched, expected value should be first param",
+ callExpr->getExprLoc())
+ << callExpr->getSourceRange();
+ }
return true;
}
@@ -167,7 +180,7 @@ Expr const * stripConstructor(Expr const * expr) {
bool CppunitAssertEquals::isCompileTimeConstant(Expr const * expr)
{
- if (expr->isIntegerConstantExpr(compiler.getASTContext()))
+ if (expr->isCXX11ConstantExpr(compiler.getASTContext()))
return true;
// is string literal ?
expr = expr->IgnoreParenImpCasts();