[PATCH] D158959: [clang-tidy] Disambiguate calls to log

2023-08-27 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Thank you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158959/new/

https://reviews.llvm.org/D158959

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158959: [clang-tidy] Disambiguate calls to log

2023-08-27 Thread Rainer Orth via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03dff0d4acaf: [clang-tidy] Disambiguate calls to log 
(authored by ro).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158959/new/

https://reviews.llvm.org/D158959

Files:
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp


Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@
   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.


Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@
   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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158959: [clang-tidy] Disambiguate calls to log

2023-08-27 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added a reviewer: PiotrZSL.
Herald added subscribers: carlosgalvezp, pengfei, zzheng, fedor.sergeev, 
xazax.hun, jyknight.
Herald added a reviewer: njames93.
Herald added a project: All.
ro requested review of this revision.
Herald added a project: clang-tools-extra.

c8644b18f570be9d26d83cdeeb2369cd3cbddaf1 
 broke the 
Solaris/amd64  and 
Solaris/sparcv9  
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`.

Will commit shortly to unbreak the bots.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158959

Files:
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp


Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@
   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.


Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@
   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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits