Fix some clang-tidy findings
* modernize-use-std-numbers
* modernize-use-starts-ends-with
diff --git a/verible/verilog/analysis/checkers/truncated-numeric-literal-rule.cc b/verible/verilog/analysis/checkers/truncated-numeric-literal-rule.cc
index 298bc6c..c6a17c2 100644
--- a/verible/verilog/analysis/checkers/truncated-numeric-literal-rule.cc
+++ b/verible/verilog/analysis/checkers/truncated-numeric-literal-rule.cc
@@ -18,6 +18,7 @@
#include <cctype>
#include <cmath>
#include <cstddef>
+#include <numbers>
#include <set>
#include <string>
#include <string_view>
@@ -136,11 +137,13 @@
// without fully parsing the decimal number ?
double v;
if (absl::SimpleAtod(literal, &v) && !std::isinf(v)) {
- return std::max(129, static_cast<int>(ceil(log(v) / log(2))));
+ return std::max(129,
+ static_cast<int>(ceil(log(v) / std::numbers::ln2)));
}
// Uh, more than 300-ish decimal digits ? ... rough estimation it is.
- return ceil((literal.length() - 1) * log(10) / log(2));
+ return ceil((literal.length() - 1) * std::numbers::ln10 /
+ std::numbers::ln2);
} break;
default:
break; // unexpected base
diff --git a/verible/verilog/formatting/token-annotator.cc b/verible/verilog/formatting/token-annotator.cc
index fc6d2f0..6b42b60 100644
--- a/verible/verilog/formatting/token-annotator.cc
+++ b/verible/verilog/formatting/token-annotator.cc
@@ -263,8 +263,7 @@
// If a closing ')', that ends the definition name.
if (left.TokenEnum() == verilog_tokentype::PP_Identifier &&
right.TokenEnum() == verilog_tokentype::PP_define_body &&
- right.Text().substr(0, 2) == "``" &&
- right.OriginalLeadingSpaces().empty()) {
+ right.Text().starts_with("``") && right.OriginalLeadingSpaces().empty()) {
return {0, "Preserve spacing in concatenated name"};
}