-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang-tidy][NFC] Enable performance-type-promotion-in-math-fn
check in the codebase
#158186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-tools-extra Author: Victor Chernyakin (localspook) ChangesCloses #156155. Full diff: https://github.com/llvm/llvm-project/pull/158186.diff 3 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/.clang-tidy b/clang-tools-extra/clang-tidy/.clang-tidy
index ae554c6668a84..d290901730405 100644
--- a/clang-tools-extra/clang-tidy/.clang-tidy
+++ b/clang-tools-extra/clang-tidy/.clang-tidy
@@ -16,7 +16,6 @@ Checks: >
performance-*,
-performance-enum-size,
-performance-no-int-to-ptr,
- -performance-type-promotion-in-math-fn,
-performance-unnecessary-value-param,
readability-*,
-readability-avoid-nested-conditional-operator,
diff --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index 789327b196ab6..d7b8f7bc62409 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -76,9 +76,9 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
CharUnits CurrSize = Result.Context->getASTRecordLayout(Struct).getSize();
CharUnits MinByteSize =
CharUnits::fromQuantity(std::max<clang::CharUnits::QuantityType>(
- ceil(static_cast<float>(TotalBitSize) / CharSize), 1));
+ std::ceil(static_cast<float>(TotalBitSize) / CharSize), 1));
CharUnits MaxAlign = CharUnits::fromQuantity(
- ceil((float)Struct->getMaxAlignment() / CharSize));
+ std::ceil((float)Struct->getMaxAlignment() / CharSize));
CharUnits CurrAlign =
Result.Context->getASTRecordLayout(Struct).getAlignment();
CharUnits NewAlign = computeRecommendedAlignment(MinByteSize);
diff --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index 0bb9d6e4a7cee..9846a573a8c29 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -208,18 +208,20 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt *Statement,
return true;
switch (Op->getOpcode()) {
case (BO_AddAssign):
- Iterations = ceil(float(EndValue - InitValue) / ConstantValue);
+ Iterations = std::ceil(float(EndValue - InitValue) / ConstantValue);
break;
case (BO_SubAssign):
- Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
+ Iterations = std::ceil(float(InitValue - EndValue) / ConstantValue);
break;
case (BO_MulAssign):
- Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
- log((double)ConstantValue);
+ Iterations =
+ 1 + (std::log((double)EndValue) - std::log((double)InitValue)) /
+ std::log((double)ConstantValue);
break;
case (BO_DivAssign):
- Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
- log((double)ConstantValue);
+ Iterations =
+ 1 + (std::log((double)InitValue) - std::log((double)EndValue)) /
+ std::log((double)ConstantValue);
break;
default:
// All other operators are not handled; assume large bounds.
|
@llvm/pr-subscribers-clang-tidy Author: Victor Chernyakin (localspook) ChangesCloses #156155. Full diff: https://github.com/llvm/llvm-project/pull/158186.diff 3 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/.clang-tidy b/clang-tools-extra/clang-tidy/.clang-tidy
index ae554c6668a84..d290901730405 100644
--- a/clang-tools-extra/clang-tidy/.clang-tidy
+++ b/clang-tools-extra/clang-tidy/.clang-tidy
@@ -16,7 +16,6 @@ Checks: >
performance-*,
-performance-enum-size,
-performance-no-int-to-ptr,
- -performance-type-promotion-in-math-fn,
-performance-unnecessary-value-param,
readability-*,
-readability-avoid-nested-conditional-operator,
diff --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index 789327b196ab6..d7b8f7bc62409 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -76,9 +76,9 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
CharUnits CurrSize = Result.Context->getASTRecordLayout(Struct).getSize();
CharUnits MinByteSize =
CharUnits::fromQuantity(std::max<clang::CharUnits::QuantityType>(
- ceil(static_cast<float>(TotalBitSize) / CharSize), 1));
+ std::ceil(static_cast<float>(TotalBitSize) / CharSize), 1));
CharUnits MaxAlign = CharUnits::fromQuantity(
- ceil((float)Struct->getMaxAlignment() / CharSize));
+ std::ceil((float)Struct->getMaxAlignment() / CharSize));
CharUnits CurrAlign =
Result.Context->getASTRecordLayout(Struct).getAlignment();
CharUnits NewAlign = computeRecommendedAlignment(MinByteSize);
diff --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index 0bb9d6e4a7cee..9846a573a8c29 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -208,18 +208,20 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt *Statement,
return true;
switch (Op->getOpcode()) {
case (BO_AddAssign):
- Iterations = ceil(float(EndValue - InitValue) / ConstantValue);
+ Iterations = std::ceil(float(EndValue - InitValue) / ConstantValue);
break;
case (BO_SubAssign):
- Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
+ Iterations = std::ceil(float(InitValue - EndValue) / ConstantValue);
break;
case (BO_MulAssign):
- Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
- log((double)ConstantValue);
+ Iterations =
+ 1 + (std::log((double)EndValue) - std::log((double)InitValue)) /
+ std::log((double)ConstantValue);
break;
case (BO_DivAssign):
- Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
- log((double)ConstantValue);
+ Iterations =
+ 1 + (std::log((double)InitValue) - std::log((double)EndValue)) /
+ std::log((double)ConstantValue);
break;
default:
// All other operators are not handled; assume large bounds.
|
Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) / | ||
log((double)ConstantValue); | ||
Iterations = | ||
1 + (std::log((double)EndValue) - std::log((double)InitValue)) / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no type promotion with these log
s, but I figured it's still better to std::
-qualify them for consistency
Closes #156155.