[llvm] [JITLink][AArch32] Unittest for error paths of readAddend functionality (PR #69636)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 19 13:19:42 PDT 2023
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 616c86accbf4c9ada37da6fb6b04554dec0fffee 6bad67fd44160421c6874f6a1fd1554c0d7d1e5a -- llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
index 66fb3cde4352..1df59edcd769 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
@@ -68,7 +68,6 @@ TEST(AArch32_ELF, EdgeKinds) {
}
}
-
struct ThumbRelocation {
/// Create a read-only reference to a Thumb32 fixup.
ThumbRelocation(const char *FixupPtr)
@@ -87,17 +86,18 @@ struct ArmRelocation {
const support::ulittle32_t &Wd;
};
-std::string makeUnexpectedOpcodeError(const LinkGraph &G, const ThumbRelocation &R,
- Edge::Kind Kind) {
+std::string makeUnexpectedOpcodeError(const LinkGraph &G,
+ const ThumbRelocation &R,
+ Edge::Kind Kind) {
return formatv("Invalid opcode [ {0:x4}, {1:x4} ] for relocation: {2}",
- static_cast<uint16_t>(R.Hi), static_cast<uint16_t>(R.Lo),
- G.getEdgeKindName(Kind));
+ static_cast<uint16_t>(R.Hi), static_cast<uint16_t>(R.Lo),
+ G.getEdgeKindName(Kind));
}
-std::string makeUnexpectedOpcodeError(const LinkGraph &G, const ArmRelocation &R,
- Edge::Kind Kind) {
+std::string makeUnexpectedOpcodeError(const LinkGraph &G,
+ const ArmRelocation &R, Edge::Kind Kind) {
return formatv("Invalid opcode {0:x8} for relocation: {1}",
- static_cast<uint32_t>(R.Wd), G.getEdgeKindName(Kind));
+ static_cast<uint32_t>(R.Wd), G.getEdgeKindName(Kind));
}
TEST(AArch32_ELF, readAddends) {
@@ -116,14 +116,17 @@ TEST(AArch32_ELF, readAddends) {
auto ArmCfg = getArmConfigForCPUArch(ARMBuildAttrs::v7);
- auto makeReadAddendError = [](LinkGraph &G, Block &B, Edge &E){
- return ("In graph " + G.getName() + ", section " + B.getSection().getName() +
- " can not read implicit addend for aarch32 edge kind " +
- G.getEdgeKindName(E.getKind())).str();
+ auto makeReadAddendError = [](LinkGraph &G, Block &B, Edge &E) {
+ return ("In graph " + G.getName() + ", section " +
+ B.getSection().getName() +
+ " can not read implicit addend for aarch32 edge kind " +
+ G.getEdgeKindName(E.getKind()))
+ .str();
};
- EXPECT_THAT_EXPECTED(readAddend(*G, B, InvalidEdge, ArmCfg), FailedWithMessage(makeReadAddendError(*G, B, InvalidEdge)));
-
+ EXPECT_THAT_EXPECTED(
+ readAddend(*G, B, InvalidEdge, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, InvalidEdge)));
ArmRelocation R_Arm(B.getContent().data());
ThumbRelocation R_Thumb(B.getContent().data());
@@ -131,22 +134,31 @@ TEST(AArch32_ELF, readAddends) {
for (Edge::Kind K = FirstDataRelocation; K < LastDataRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), Succeeded());
- EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E), FailedWithMessage(makeReadAddendError(*G, B, E)));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg), FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
}
for (Edge::Kind K = FirstArmRelocation; K < LastArmRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), FailedWithMessage(makeReadAddendError(*G, B, E)));
- EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E), FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Arm, K)));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg), FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(
+ readAddendArm(*G, B, E),
+ FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Arm, K)));
+ EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
}
for (Edge::Kind K = FirstThumbRelocation; K < LastThumbRelocation; K += 1) {
Edge E(K, 0, TargetSymbol, 0);
- EXPECT_THAT_EXPECTED(readAddendData(*G, B, E), FailedWithMessage(makeReadAddendError(*G, B, E)));
- EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E), FailedWithMessage(makeReadAddendError(*G, B, E)));
- EXPECT_THAT_EXPECTED(readAddendThumb(*G, B, E, ArmCfg), FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Thumb, K)));
+ EXPECT_THAT_EXPECTED(readAddendData(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(readAddendArm(*G, B, E),
+ FailedWithMessage(makeReadAddendError(*G, B, E)));
+ EXPECT_THAT_EXPECTED(
+ readAddendThumb(*G, B, E, ArmCfg),
+ FailedWithMessage(makeUnexpectedOpcodeError(*G, R_Thumb, K)));
}
-
}
namespace llvm {
``````````
</details>
https://github.com/llvm/llvm-project/pull/69636
More information about the llvm-commits
mailing list