Skip to content

Commit ea33083

Browse files
committed
[NFC] Fix dangling-else warning
This is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on. Built by GCC 11. Fix warnings: llvm/unittests/ProfileData/CoverageMappingTest.cpp: In member function ‘virtual void {anonymous}::CoverageMappingTest_TVIdxBuilder_Test::TestBody()’: llvm/unittests/ProfileData/CoverageMappingTest.cpp:1116:10: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=dangling-else] 1116 | if (Node.NextIDs[C] < 0)
1 parent c3bbc3a commit ea33083

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2936,8 +2936,9 @@ TEST_F(OpenMPIRBuilderTest, CriticalDirective) {
29362936
const DataLayout &DL = M->getDataLayout();
29372937
const llvm::Align TypeAlign = DL.getABITypeAlign(CriticalNamePtrTy);
29382938
const llvm::Align PtrAlign = DL.getPointerABIAlignment(GV->getAddressSpace());
2939-
if (const llvm::MaybeAlign Alignment = GV->getAlign())
2939+
if (const llvm::MaybeAlign Alignment = GV->getAlign()) {
29402940
EXPECT_EQ(*Alignment, std::max(TypeAlign, PtrAlign));
2941+
}
29412942
}
29422943

29432944
TEST_F(OpenMPIRBuilderTest, OrderedDirectiveDependSource) {

llvm/unittests/IR/AttributesTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ TEST(Attributes, SetIntersect) {
468468
AS0 = AttributeSet::get(C0, AB0);
469469
Res = AS0.intersectWith(C0, AS1);
470470
ASSERT_EQ(Res.has_value(), CanDrop);
471-
if (CanDrop)
471+
if (CanDrop) {
472472
ASSERT_FALSE(Res->hasAttributes());
473-
473+
}
474474
AS1 = AttributeSet::get(C1, AB0);
475475
Res = AS0.intersectWith(C0, AS1);
476476
ASSERT_TRUE(Res.has_value());

llvm/unittests/IR/PatternMatch.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,20 +637,23 @@ TEST_F(PatternMatchTest, CheckedInt) {
637637
CRes = nullptr;
638638
EXPECT_EQ(CheckUgt1(APVal), m_CheckedInt(CheckUgt1).match(C));
639639
EXPECT_EQ(CheckUgt1(APVal), m_CheckedInt(CRes, CheckUgt1).match(C));
640-
if (CheckUgt1(APVal))
640+
if (CheckUgt1(APVal)) {
641641
EXPECT_EQ(CRes, C);
642+
}
642643

643644
CRes = nullptr;
644645
EXPECT_EQ(CheckNonZero(APVal), m_CheckedInt(CheckNonZero).match(C));
645646
EXPECT_EQ(CheckNonZero(APVal), m_CheckedInt(CRes, CheckNonZero).match(C));
646-
if (CheckNonZero(APVal))
647+
if (CheckNonZero(APVal)) {
647648
EXPECT_EQ(CRes, C);
649+
}
648650

649651
CRes = nullptr;
650652
EXPECT_EQ(CheckPow2(APVal), m_CheckedInt(CheckPow2).match(C));
651653
EXPECT_EQ(CheckPow2(APVal), m_CheckedInt(CRes, CheckPow2).match(C));
652-
if (CheckPow2(APVal))
654+
if (CheckPow2(APVal)) {
653655
EXPECT_EQ(CRes, C);
656+
}
654657

655658
};
656659

@@ -710,8 +713,9 @@ TEST_F(PatternMatchTest, CheckedInt) {
710713
EXPECT_EQ(Expec, m_CheckedInt(CRes, CheckFn).match(C));
711714
if (Expec) {
712715
EXPECT_NE(CRes, nullptr);
713-
if (AllSame)
716+
if (AllSame) {
714717
EXPECT_EQ(CRes, C);
718+
}
715719
}
716720
};
717721
auto DoVecCheck = [&](ArrayRef<std::optional<int8_t>> Vals) {

llvm/unittests/Object/ELFObjectFileTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,9 @@ TEST(ELFObjectFileTest, ReadPGOAnalysisMap) {
12441244
}
12451245
EXPECT_EQ(PGOAnalyses, *ExpectedPGO);
12461246
for (auto &&[BB, PGO] : llvm::zip(*BBAddrMaps, PGOAnalyses)) {
1247-
if (PGO.FeatEnable.BBFreq || PGO.FeatEnable.BrProb)
1247+
if (PGO.FeatEnable.BBFreq || PGO.FeatEnable.BrProb) {
12481248
EXPECT_EQ(BB.getNumBBEntries(), PGO.BBEntries.size());
1249+
}
12491250
}
12501251
}
12511252
};

llvm/unittests/ProfileData/CoverageMappingTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,8 +1113,9 @@ TEST(CoverageMappingTest, TVIdxBuilder) {
11131113
EXPECT_EQ(Node.Width, IndicesRefs[I].Width);
11141114
for (int C = 0; C < 2; ++C) {
11151115
auto Index = TheBuilder.Indices[I][C];
1116-
if (Node.NextIDs[C] < 0)
1116+
if (Node.NextIDs[C] < 0) {
11171117
EXPECT_TRUE(Decisions.insert({Index, Node.Width}).second);
1118+
}
11181119
}
11191120
#endif
11201121
}

0 commit comments

Comments
 (0)