[clang] d76b56f - [NFC] Eliminate warnings in SourceLocationEncodingTest.cpp
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 1 23:02:56 PDT 2023
Author: Chuanqi Xu
Date: 2023-11-02T14:01:17+08:00
New Revision: d76b56fd28582c1cc6663cefa5ae2f8a23492d0a
URL: https://github.com/llvm/llvm-project/commit/d76b56fd28582c1cc6663cefa5ae2f8a23492d0a
DIFF: https://github.com/llvm/llvm-project/commit/d76b56fd28582c1cc6663cefa5ae2f8a23492d0a.diff
LOG: [NFC] Eliminate warnings in SourceLocationEncodingTest.cpp
There are 2 dangling else warnings and a warning pararences around bit operations.
This patch tries to eliminate that.
Added:
Modified:
clang/unittests/Serialization/SourceLocationEncodingTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Serialization/SourceLocationEncodingTest.cpp b/clang/unittests/Serialization/SourceLocationEncodingTest.cpp
index 2640ea4a599893a..141da4c27f8d0b5 100644
--- a/clang/unittests/Serialization/SourceLocationEncodingTest.cpp
+++ b/clang/unittests/Serialization/SourceLocationEncodingTest.cpp
@@ -25,8 +25,9 @@ void roundTrip(SourceLocation::UIntTy Loc,
std::optional<uint64_t> ExpectedEncoded = std::nullopt) {
uint64_t ActualEncoded =
SourceLocationEncoding::encode(SourceLocation::getFromRawEncoding(Loc));
- if (ExpectedEncoded)
+ if (ExpectedEncoded) {
ASSERT_EQ(ActualEncoded, *ExpectedEncoded) << "Encoding " << Loc;
+ }
SourceLocation::UIntTy DecodedEncoded =
SourceLocationEncoding::decode(ActualEncoded).getRawEncoding();
ASSERT_EQ(DecodedEncoded, Loc) << "Decoding " << ActualEncoded;
@@ -41,9 +42,10 @@ void roundTrip(std::vector<SourceLocation::UIntTy> Locs,
for (auto L : Locs)
ActualEncoded.push_back(SourceLocationEncoding::encode(
SourceLocation::getFromRawEncoding(L), Seq));
- if (!ExpectedEncoded.empty())
+ if (!ExpectedEncoded.empty()) {
ASSERT_EQ(ActualEncoded, ExpectedEncoded)
<< "Encoding " << testing::PrintToString(Locs);
+ }
}
std::vector<SourceLocation::UIntTy> DecodedEncoded;
{
@@ -70,7 +72,7 @@ TEST(SourceLocationEncoding, Individual) {
roundTrip(Big);
roundTrip(Big + 1);
roundTrip(MacroBit | Big);
- roundTrip(MacroBit | Big + 1);
+ roundTrip(MacroBit | (Big + 1));
}
TEST(SourceLocationEncoding, Sequence) {
More information about the cfe-commits
mailing list