[Libreoffice-commits] core.git: compilerplugins/clang filter/source sal/rtl svl/source tools/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Nov 23 13:11:49 UTC 2017
compilerplugins/clang/simplifybool.cxx | 4 ++++
compilerplugins/clang/test/simplifybool.cxx | 11 ++++++++++-
filter/source/graphicfilter/icgm/class4.cxx | 4 ++--
sal/rtl/math.cxx | 2 +-
svl/source/numbers/zformat.cxx | 2 +-
tools/source/generic/b3dtrans.cxx | 4 ++--
6 files changed, 20 insertions(+), 7 deletions(-)
New commits:
commit e0846b7abe78e55bc1e959143d980208077b13ca
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Nov 23 10:39:41 2017 +0200
loplugin:simplifybool can't invert conditions involving float types
so revert some of the changes from
commit 7a1c21e53fc4733a4bb52282ce0098fcc085ab0e
loplugin:simplifybool for negation of comparison operator
Change-Id: I937d575b86c1e418805d399b0dc16ae91876b4fe
Reviewed-on: https://gerrit.libreoffice.org/45130
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/compilerplugins/clang/simplifybool.cxx b/compilerplugins/clang/simplifybool.cxx
index 260946a5fd98..9167014f8c84 100644
--- a/compilerplugins/clang/simplifybool.cxx
+++ b/compilerplugins/clang/simplifybool.cxx
@@ -142,6 +142,10 @@ bool SimplifyBool::VisitUnaryLNot(UnaryOperator const * expr) {
// RecordType would require more smarts - we'd need to verify that an inverted operator actually existed
if (t->isTemplateTypeParmType() || t->isRecordType() || t->isDependentType())
return true;
+ // for floating point (with NaN) !(x<y) need not be equivalent to x>=y
+ if (t->isFloatingType() ||
+ binaryOp->getRHS()->IgnoreImpCasts()->getType()->getUnqualifiedDesugaredType()->isFloatingType())
+ return true;
if (!binaryOp->isComparisonOp())
return true;
report(
diff --git a/compilerplugins/clang/test/simplifybool.cxx b/compilerplugins/clang/test/simplifybool.cxx
index e6b52c33f3b6..2cb2e810c110 100644
--- a/compilerplugins/clang/test/simplifybool.cxx
+++ b/compilerplugins/clang/test/simplifybool.cxx
@@ -15,7 +15,16 @@ void f1(int a, int b)
}
};
-// Consitently either warn about all or none of the below occurrences of "!!":
+void f2(float a, float b)
+{
+ // no warning expected
+ if (!(a < b))
+ {
+ a = b;
+ }
+};
+
+// Consistently either warn about all or none of the below occurrences of "!!":
enum E1
{
diff --git a/filter/source/graphicfilter/icgm/class4.cxx b/filter/source/graphicfilter/icgm/class4.cxx
index 46f15e650c01..0185f699014c 100644
--- a/filter/source/graphicfilter/icgm/class4.cxx
+++ b/filter/source/graphicfilter/icgm/class4.cxx
@@ -395,7 +395,7 @@ void CGM::ImplDoClass4()
fStartAngle = fEndAngle;
fEndAngle = fG;
}
- if ( ( fInterAngle <= fStartAngle ) && ( fInterAngle < fEndAngle ) )
+ if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
{
nSwitch ^=1;
aIntermediatePoint = aEndingPoint;
@@ -465,7 +465,7 @@ void CGM::ImplDoClass4()
fStartAngle = fEndAngle;
fEndAngle = fG;
}
- if ( ( fInterAngle <= fStartAngle ) && ( fInterAngle < fEndAngle ) )
+ if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
{
aIntermediatePoint = aEndingPoint;
aEndingPoint = aStartingPoint;
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index a9b30a4dc498..96c5843dcfea 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -170,7 +170,7 @@ bool isRepresentableInteger(double fAbsValue)
// this here.
double fInt;
return (nInt <= kMaxInt &&
- (((fInt = static_cast< double >(nInt)) >= fAbsValue) && (fInt <= fAbsValue)));
+ (!((fInt = static_cast< double >(nInt)) < fAbsValue) && !(fInt > fAbsValue)));
}
return false;
}
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 9a314d40b6aa..d3e48317f4d0 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -2368,7 +2368,7 @@ bool SvNumberformat::GetOutputString(double fNumber,
{
if (::rtl::math::isSignBitSet(fNumber))
{
- if (fNumber >= 0.0)
+ if (!(fNumber < 0.0))
fNumber = -fNumber; // do not display -0.0
}
if (fNumber == 0.0)
diff --git a/tools/source/generic/b3dtrans.cxx b/tools/source/generic/b3dtrans.cxx
index c65074482529..1162f24993f6 100644
--- a/tools/source/generic/b3dtrans.cxx
+++ b/tools/source/generic/b3dtrans.cxx
@@ -59,11 +59,11 @@ void B3dTransformationSet::Orientation(basegfx::B3DHomMatrix& rTarget, const bas
void B3dTransformationSet::Frustum(basegfx::B3DHomMatrix& rTarget, double fLeft, double fRight, double fBottom, double fTop, double fNear, double fFar)
{
- if(fNear <= 0.0)
+ if(!(fNear > 0.0))
{
fNear = 0.001;
}
- if(fFar <= 0.0)
+ if(!(fFar > 0.0))
{
fFar = 1.0;
}
More information about the Libreoffice-commits
mailing list