[Libreoffice-commits] core.git: compilerplugins/clang
Noel Grandin
noel at peralex.com
Mon Jul 25 06:14:53 UTC 2016
compilerplugins/clang/overrideparam.cxx | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
New commits:
commit 594dd232c8ff4808d4ad43cc41a9934a9c6d131d
Author: Noel Grandin <noel at peralex.com>
Date: Mon Jul 25 08:14:06 2016 +0200
loplugin:overrideparam enable checking that default values match
Change-Id: I4ca21d12d6f5dd4bb0b2705f7e36249082b0838c
diff --git a/compilerplugins/clang/overrideparam.cxx b/compilerplugins/clang/overrideparam.cxx
index c04165b..c6490d8 100644
--- a/compilerplugins/clang/overrideparam.cxx
+++ b/compilerplugins/clang/overrideparam.cxx
@@ -104,7 +104,6 @@ bool OverrideParam::VisitCXXMethodDecl(const CXXMethodDecl * methodDecl) {
}
else if (parmVarDecl->hasDefaultArg() && superParmVarDecl->hasDefaultArg()
&& !hasSameDefaultParams(parmVarDecl, superParmVarDecl)) {
- /* do nothing for now, will enable this in a later commit
report(
DiagnosticsEngine::Warning,
"overridden method declaration has different default param to super-method",
@@ -115,7 +114,6 @@ bool OverrideParam::VisitCXXMethodDecl(const CXXMethodDecl * methodDecl) {
"original param here",
superParmVarDecl->getSourceRange().getBegin())
<< superParmVarDecl->getSourceRange();
- */
}
/* do nothing for now, will enable this in a later commit
if (methodDecl->isThisDeclarationADefinition() && parmVarDecl->getName().empty()) {
@@ -162,12 +160,23 @@ bool OverrideParam::hasSameDefaultParams(const ParmVarDecl * parmVarDecl, const
{
return x1 == x2;
}
+ APFloat f1(0.0f), f2(0.0f);
+ if (defaultArgExpr->EvaluateAsFloat(f1, compiler.getASTContext())
+ && superDefaultArgExpr->EvaluateAsFloat(f2, compiler.getASTContext()))
+ {
+ return f1.bitwiseIsEqual(f2);
+ }
// catch params with defaults like "= OUString()"
if (isa<MaterializeTemporaryExpr>(defaultArgExpr)
&& isa<MaterializeTemporaryExpr>(superDefaultArgExpr))
{
return true;
}
+ if (isa<CXXBindTemporaryExpr>(defaultArgExpr)
+ && isa<CXXBindTemporaryExpr>(superDefaultArgExpr))
+ {
+ return true;
+ }
return false;
}
More information about the Libreoffice-commits
mailing list