[clang] [clang] Increase VecLib bitfield size to 4 bits in CodeGenOptions.def (PR #108804)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 17 20:37:46 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 2ae968a0d9fb61606b020e898d884c82dd0ed8b5 2e6275d645485c5ae32754a753ed99bcfc507dba --extensions cpp -- clang/unittests/CodeGen/AllLibrariesFit.cpp clang/unittests/CodeGen/EncodingDecodingTest.cpp clang/unittests/CodeGen/SimulatedOverflowTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/unittests/CodeGen/AllLibrariesFit.cpp b/clang/unittests/CodeGen/AllLibrariesFit.cpp
index 9c2c34ceee..7bb2891289 100644
--- a/clang/unittests/CodeGen/AllLibrariesFit.cpp
+++ b/clang/unittests/CodeGen/AllLibrariesFit.cpp
@@ -3,7 +3,8 @@
#include "gtest/gtest.h"
TEST(VecLibBitfieldTest, AllLibrariesFit) {
- // We expect that all vector libraries fit in the bitfield size
- EXPECT_LE(static_cast<size_t>(llvm::driver::VectorLibrary::MaxLibrary),
- (1 << VECLIB_BIT_COUNT)) << "VecLib bitfield size is too small!";
+ // We expect that all vector libraries fit in the bitfield size
+ EXPECT_LE(static_cast<size_t>(llvm::driver::VectorLibrary::MaxLibrary),
+ (1 << VECLIB_BIT_COUNT))
+ << "VecLib bitfield size is too small!";
}
diff --git a/clang/unittests/CodeGen/EncodingDecodingTest.cpp b/clang/unittests/CodeGen/EncodingDecodingTest.cpp
index c819c02a44..67c89ef07c 100644
--- a/clang/unittests/CodeGen/EncodingDecodingTest.cpp
+++ b/clang/unittests/CodeGen/EncodingDecodingTest.cpp
@@ -1,15 +1,17 @@
TEST(VecLibBitfieldTest, EncodingDecodingTest) {
- clang::CodeGenOptions Opts;
-
- // Test encoding and decoding for each vector library
- for (int i = static_cast<int>(llvm::driver::VectorLibrary::Accelerate);
- i <= static_cast<int>(llvm::driver::VectorLibrary::MaxLibrary); ++i) {
-
- Opts.VecLib = static_cast<llvm::driver::VectorLibrary>(i);
-
- // Encode and then decode
- llvm::driver::VectorLibrary decodedValue = static_cast<llvm::driver::VectorLibrary>(Opts.VecLib);
-
- EXPECT_EQ(decodedValue, Opts.VecLib) << "Encoding/Decoding failed for vector library " << i;
- }
+ clang::CodeGenOptions Opts;
+
+ // Test encoding and decoding for each vector library
+ for (int i = static_cast<int>(llvm::driver::VectorLibrary::Accelerate);
+ i <= static_cast<int>(llvm::driver::VectorLibrary::MaxLibrary); ++i) {
+
+ Opts.VecLib = static_cast<llvm::driver::VectorLibrary>(i);
+
+ // Encode and then decode
+ llvm::driver::VectorLibrary decodedValue =
+ static_cast<llvm::driver::VectorLibrary>(Opts.VecLib);
+
+ EXPECT_EQ(decodedValue, Opts.VecLib)
+ << "Encoding/Decoding failed for vector library " << i;
+ }
}
diff --git a/clang/unittests/CodeGen/SimulatedOverflowTest.cpp b/clang/unittests/CodeGen/SimulatedOverflowTest.cpp
index 4c716d3480..acfeaf7498 100644
--- a/clang/unittests/CodeGen/SimulatedOverflowTest.cpp
+++ b/clang/unittests/CodeGen/SimulatedOverflowTest.cpp
@@ -1,23 +1,26 @@
// Simulate the addition of a new library without increasing the bitfield size
enum class SimulatedVectorLibrary {
- Accelerate = 0,
- LIBMVEC,
- MASSV,
- SVML,
- SLEEF,
- Darwin_libsystem_m,
- ArmPL,
- AMDLIBM,
- NoLibrary,
- // Simulate new addition
- NewLibrary,
- MaxLibrary
+ Accelerate = 0,
+ LIBMVEC,
+ MASSV,
+ SVML,
+ SLEEF,
+ Darwin_libsystem_m,
+ ArmPL,
+ AMDLIBM,
+ NoLibrary,
+ // Simulate new addition
+ NewLibrary,
+ MaxLibrary
};
-#define SIMULATED_VECLIB_BIT_COUNT 4 // The current bitfield size (should be 4 for 9 options)
+#define SIMULATED_VECLIB_BIT_COUNT \
+ 4 // The current bitfield size (should be 4 for 9 options)
TEST(VecLibBitfieldTest, SimulatedOverflowTest) {
- // Simulate the addition of a new library and check if the bitfield size is sufficient
- EXPECT_LE(static_cast<size_t>(SimulatedVectorLibrary::MaxLibrary),
- (1 << SIMULATED_VECLIB_BIT_COUNT)) << "Simulated VecLib bitfield size overflow!";
+ // Simulate the addition of a new library and check if the bitfield size is
+ // sufficient
+ EXPECT_LE(static_cast<size_t>(SimulatedVectorLibrary::MaxLibrary),
+ (1 << SIMULATED_VECLIB_BIT_COUNT))
+ << "Simulated VecLib bitfield size overflow!";
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/108804
More information about the cfe-commits
mailing list