[clang-tools-extra] 03dff0d - [clang-tidy] Disambiguate calls to log
Rainer Orth via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 27 12:16:14 PDT 2023
Author: Rainer Orth
Date: 2023-08-27T21:15:43+02:00
New Revision: 03dff0d4acafb61bbb3b765507de79c5e5b6681a
URL: https://github.com/llvm/llvm-project/commit/03dff0d4acafb61bbb3b765507de79c5e5b6681a
DIFF: https://github.com/llvm/llvm-project/commit/03dff0d4acafb61bbb3b765507de79c5e5b6681a.diff
LOG: [clang-tidy] Disambiguate calls to log
c8644b18f570be9d26d83cdeeb2369cd3cbddaf1 <https://reviews.llvm.org/rGc8644b18f570be9d26d83cdeeb2369cd3cbddaf1>
broke the Solaris/amd64 <https://lab.llvm.org/staging/#/builders/101/builds/15078>
and Solaris/sparcv9 <https://lab.llvm.org/staging/#/builders/50/builds/15116> buildbots:
FAILED: tools/clang/tools/extra/clang-tidy/altera/CMakeFiles/obj.clangTidyAlteraModule.dir/UnrollLoopsCheck.cpp.o
[...]
/vol/llvm/src/llvm-project/dist/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:217:25: error: call to 'log' is ambiguous
217 | Iterations = 1 + (log(EndValue) - log(InitValue)) / log(ConstantValue);
| ^~~
/usr/include/iso/math_iso.h:60:15: note: candidate function
60 | extern double log __P((double));
| ^
/usr/include/iso/math_iso.h:158:15: note: candidate function
158 | inline float log(float __X) { return __logf(__X); }
| ^
/usr/include/iso/math_iso.h:193:21: note: candidate function
193 | inline long double log(long double __X) { return __logl(__X); }
| ^
Fixed by disambituating the calls with `double` casts.
Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
Differential Revision: https://reviews.llvm.org/D158959
Added:
Modified:
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index 37eacf565f199d..532a43bad74127 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt *Statement,
Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
break;
case (BO_MulAssign):
- Iterations = 1 + (log(EndValue) - log(InitValue)) / log(ConstantValue);
+ Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
+ log((double)ConstantValue);
break;
case (BO_DivAssign):
- Iterations = 1 + (log(InitValue) - log(EndValue)) / log(ConstantValue);
+ Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
+ log((double)ConstantValue);
break;
default:
// All other operators are not handled; assume large bounds.
More information about the cfe-commits
mailing list