loplugin:overrideparam enable checking that default values match
Change-Id: I4ca21d12d6f5dd4bb0b2705f7e36249082b0838c
This commit is contained in:
@@ -104,7 +104,6 @@ bool OverrideParam::VisitCXXMethodDecl(const CXXMethodDecl * methodDecl) {
|
|||||||
}
|
}
|
||||||
else if (parmVarDecl->hasDefaultArg() && superParmVarDecl->hasDefaultArg()
|
else if (parmVarDecl->hasDefaultArg() && superParmVarDecl->hasDefaultArg()
|
||||||
&& !hasSameDefaultParams(parmVarDecl, superParmVarDecl)) {
|
&& !hasSameDefaultParams(parmVarDecl, superParmVarDecl)) {
|
||||||
/* do nothing for now, will enable this in a later commit
|
|
||||||
report(
|
report(
|
||||||
DiagnosticsEngine::Warning,
|
DiagnosticsEngine::Warning,
|
||||||
"overridden method declaration has different default param to super-method",
|
"overridden method declaration has different default param to super-method",
|
||||||
@@ -115,7 +114,6 @@ bool OverrideParam::VisitCXXMethodDecl(const CXXMethodDecl * methodDecl) {
|
|||||||
"original param here",
|
"original param here",
|
||||||
superParmVarDecl->getSourceRange().getBegin())
|
superParmVarDecl->getSourceRange().getBegin())
|
||||||
<< superParmVarDecl->getSourceRange();
|
<< superParmVarDecl->getSourceRange();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
/* do nothing for now, will enable this in a later commit
|
/* do nothing for now, will enable this in a later commit
|
||||||
if (methodDecl->isThisDeclarationADefinition() && parmVarDecl->getName().empty()) {
|
if (methodDecl->isThisDeclarationADefinition() && parmVarDecl->getName().empty()) {
|
||||||
@@ -162,12 +160,23 @@ bool OverrideParam::hasSameDefaultParams(const ParmVarDecl * parmVarDecl, const
|
|||||||
{
|
{
|
||||||
return x1 == x2;
|
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()"
|
// catch params with defaults like "= OUString()"
|
||||||
if (isa<MaterializeTemporaryExpr>(defaultArgExpr)
|
if (isa<MaterializeTemporaryExpr>(defaultArgExpr)
|
||||||
&& isa<MaterializeTemporaryExpr>(superDefaultArgExpr))
|
&& isa<MaterializeTemporaryExpr>(superDefaultArgExpr))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (isa<CXXBindTemporaryExpr>(defaultArgExpr)
|
||||||
|
&& isa<CXXBindTemporaryExpr>(superDefaultArgExpr))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user