loplugin:intvsfloat get this working reliably
Change-Id: Ifdf1a152f6bc2e2f6edae97a5191120f630f7e49 Reviewed-on: https://gerrit.libreoffice.org/64374 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -16,9 +16,7 @@
|
|||||||
|
|
||||||
TODO multiplying/otherop on a combination of a float and int, and then truncating to int. like this:
|
TODO multiplying/otherop on a combination of a float and int, and then truncating to int. like this:
|
||||||
float getRotation() {}
|
float getRotation() {}
|
||||||
int moRotation;
|
int moRotation = -F_PI180 * 90 * getRotation();
|
||||||
moRotation = -F_PI180 * 90 * getRotation();
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -90,6 +88,8 @@ llvm::Optional<double> IntVsFloat::getExprValue(Expr const* expr)
|
|||||||
// Of the available clang Evaluate* APIs, this is the __only__ one that produces useful output
|
// Of the available clang Evaluate* APIs, this is the __only__ one that produces useful output
|
||||||
// (as of 17 Aug 2018 checkout of clang, ie. towards clang 7)
|
// (as of 17 Aug 2018 checkout of clang, ie. towards clang 7)
|
||||||
|
|
||||||
|
if (expr->isValueDependent())
|
||||||
|
return llvm::Optional<double>();
|
||||||
Expr::EvalResult evalResult;
|
Expr::EvalResult evalResult;
|
||||||
if (!expr->EvaluateAsRValue(evalResult, compiler.getASTContext()))
|
if (!expr->EvaluateAsRValue(evalResult, compiler.getASTContext()))
|
||||||
return llvm::Optional<double>();
|
return llvm::Optional<double>();
|
@@ -18,26 +18,22 @@ struct Class1
|
|||||||
|
|
||||||
void func1(Class1 const& class1)
|
void func1(Class1 const& class1)
|
||||||
{
|
{
|
||||||
if (1
|
// expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
||||||
== PI) // expected-error {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
if (1 == PI)
|
||||||
return;
|
return;
|
||||||
if (1
|
// expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
||||||
== class1
|
if (1 == class1.PI)
|
||||||
.PI) // expected-error {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
|
||||||
return;
|
return;
|
||||||
if (true
|
// expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
||||||
== class1
|
if (true == class1.PI)
|
||||||
.PI) // expected-error {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
|
||||||
return;
|
return;
|
||||||
if (1 == class1.getInt()) // no warning expected
|
if (1 == class1.getInt()) // no warning expected
|
||||||
return;
|
return;
|
||||||
if (1
|
// expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
||||||
== class1
|
if (1 == class1.E())
|
||||||
.E()) // expected-error {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
|
||||||
return;
|
return;
|
||||||
if (true
|
// expected-error@+1 {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
||||||
== class1
|
if (true == class1.E())
|
||||||
.E()) // expected-error {{comparing integer to float constant, can never be true [loplugin:intvsfloat]}}
|
|
||||||
return;
|
return;
|
||||||
if (1 == class1.getFloat()) // no warning expected
|
if (1 == class1.getFloat()) // no warning expected
|
||||||
return;
|
return;
|
||||||
@@ -45,24 +41,21 @@ void func1(Class1 const& class1)
|
|||||||
|
|
||||||
void func2(Class1 const& class1)
|
void func2(Class1 const& class1)
|
||||||
{
|
{
|
||||||
int i0
|
// expected-error@+1 {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
|
||||||
= PI; // expected-error {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
|
int i0 = PI;
|
||||||
(void)i0;
|
(void)i0;
|
||||||
int i1
|
// expected-error@+1 {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
|
||||||
= class1
|
int i1 = class1.PI;
|
||||||
.PI; // expected-error {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
|
|
||||||
(void)i1;
|
(void)i1;
|
||||||
int i2
|
// expected-error@+1 {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
|
||||||
= class1
|
int i2 = class1.E();
|
||||||
.E(); // expected-error {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
|
|
||||||
(void)i2;
|
(void)i2;
|
||||||
int i3 = class1.getFloat(); // no warning expected
|
int i3 = class1.getFloat(); // no warning expected
|
||||||
(void)i3;
|
(void)i3;
|
||||||
int i4 = class1.getInt(); // no warning expected
|
int i4 = class1.getInt(); // no warning expected
|
||||||
(void)i4;
|
(void)i4;
|
||||||
bool b1
|
// expected-error@+1 {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
|
||||||
= class1
|
bool b1 = class1.E();
|
||||||
.E(); // expected-error {{assigning constant float value to int truncates data [loplugin:intvsfloat]}}
|
|
||||||
(void)b1;
|
(void)b1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -677,7 +677,7 @@ void ScInputWindow::MouseMove( const MouseEvent& rMEvt )
|
|||||||
if (bInResize)
|
if (bInResize)
|
||||||
{
|
{
|
||||||
// detect direction
|
// detect direction
|
||||||
long nResizeThreshold = (long(TBX_WINDOW_HEIGHT) * 0.7);
|
long nResizeThreshold = long(TBX_WINDOW_HEIGHT * 0.7);
|
||||||
bool bResetPointerPos = false;
|
bool bResetPointerPos = false;
|
||||||
|
|
||||||
// Detect attempt to expand toolbar too much
|
// Detect attempt to expand toolbar too much
|
||||||
|
@@ -28,6 +28,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
|
|||||||
compilerplugins/clang/test/emptyif \
|
compilerplugins/clang/test/emptyif \
|
||||||
compilerplugins/clang/test/externvar \
|
compilerplugins/clang/test/externvar \
|
||||||
compilerplugins/clang/test/expressionalwayszero \
|
compilerplugins/clang/test/expressionalwayszero \
|
||||||
|
compilerplugins/clang/test/intvsfloat \
|
||||||
compilerplugins/clang/test/faileddyncast \
|
compilerplugins/clang/test/faileddyncast \
|
||||||
compilerplugins/clang/test/finalprotected \
|
compilerplugins/clang/test/finalprotected \
|
||||||
compilerplugins/clang/test/flatten \
|
compilerplugins/clang/test/flatten \
|
||||||
|
@@ -1148,7 +1148,7 @@ void GtkSalGraphics::PaintSpinButton(GtkStateFlags flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FALLBACK_ARROW_SIZE 11 * 0.85
|
#define FALLBACK_ARROW_SIZE gint(11 * 0.85)
|
||||||
|
|
||||||
tools::Rectangle GtkSalGraphics::NWGetComboBoxButtonRect(
|
tools::Rectangle GtkSalGraphics::NWGetComboBoxButtonRect(
|
||||||
ControlPart nPart,
|
ControlPart nPart,
|
||||||
|
Reference in New Issue
Block a user