Added braces to work around gcc warning in googletest: suggest explicit braces to avoid ambiguous 'else'. NFC.

llvm-svn: 305507
This commit is contained in:
Galina Kistanova 2017-06-15 21:01:24 +00:00
parent fcae62d6ee
commit 45fbb597ec
4 changed files with 16 additions and 8 deletions

View File

@ -320,11 +320,12 @@ TEST_F(CommentLexerTest, DoxygenCommand4) {
ASSERT_EQ(array_lengthof(Text), Toks.size()); ASSERT_EQ(array_lengthof(Text), Toks.size());
for (size_t j = 0, e = Toks.size(); j != e; j++) { for (size_t j = 0, e = Toks.size(); j != e; j++) {
if(Toks[j].is(tok::text)) if(Toks[j].is(tok::text)) {
ASSERT_EQ(StringRef(Text[j]), Toks[j].getText()) ASSERT_EQ(StringRef(Text[j]), Toks[j].getText())
<< "index " << i; << "index " << i;
} }
} }
}
} }
// A command marker followed by a non-letter that is not a part of an escape // A command marker followed by a non-letter that is not a part of an escape

View File

@ -320,10 +320,12 @@ public:
ExpectedName(ExpectedName) {} ExpectedName(ExpectedName) {}
void onEndOfTranslationUnit() override { void onEndOfTranslationUnit() override {
if (ExpectedCount != -1) if (ExpectedCount != -1) {
EXPECT_EQ(ExpectedCount, Count); EXPECT_EQ(ExpectedCount, Count);
if (!ExpectedName.empty()) }
if (!ExpectedName.empty()) {
EXPECT_EQ(ExpectedName, Name); EXPECT_EQ(ExpectedName, Name);
}
Count = 0; Count = 0;
Name.clear(); Name.clear();
} }
@ -346,8 +348,9 @@ public:
} }
BoundNodes::IDToNodeMap::const_iterator I = M.find(Id); BoundNodes::IDToNodeMap::const_iterator I = M.find(Id);
EXPECT_NE(M.end(), I); EXPECT_NE(M.end(), I);
if (I != M.end()) if (I != M.end()) {
EXPECT_EQ(Nodes->getNodeAs<T>(Id), I->second.get<T>()); EXPECT_EQ(Nodes->getNodeAs<T>(Id), I->second.get<T>());
}
return true; return true;
} }
EXPECT_TRUE(M.count(Id) == 0 || EXPECT_TRUE(M.count(Id) == 0 ||

View File

@ -300,9 +300,10 @@ struct ScopedDir {
EXPECT_FALSE(EC); EXPECT_FALSE(EC);
} }
~ScopedDir() { ~ScopedDir() {
if (Path != "") if (Path != "") {
EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); EXPECT_FALSE(llvm::sys::fs::remove(Path.str()));
} }
}
operator StringRef() { return Path.str(); } operator StringRef() { return Path.str(); }
}; };
@ -316,9 +317,10 @@ struct ScopedLink {
EXPECT_FALSE(EC); EXPECT_FALSE(EC);
} }
~ScopedLink() { ~ScopedLink() {
if (Path != "") if (Path != "") {
EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); EXPECT_FALSE(llvm::sys::fs::remove(Path.str()));
} }
}
operator StringRef() { return Path.str(); } operator StringRef() { return Path.str(); }
}; };
} // end anonymous namespace } // end anonymous namespace

View File

@ -143,8 +143,9 @@ TEST(LookupTest, replaceNestedClassName) {
Visitor.OnRecordTypeLoc = [&](RecordTypeLoc Type) { Visitor.OnRecordTypeLoc = [&](RecordTypeLoc Type) {
// Filter Types by name since there are other `RecordTypeLoc` in the test // Filter Types by name since there are other `RecordTypeLoc` in the test
// file. // file.
if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") {
EXPECT_EQ("x::Bar", replaceRecordTypeLoc(Type, "::a::x::Bar")); EXPECT_EQ("x::Bar", replaceRecordTypeLoc(Type, "::a::x::Bar"));
}
}; };
Visitor.runOver("namespace a { namespace b {\n" Visitor.runOver("namespace a { namespace b {\n"
"class Foo;\n" "class Foo;\n"
@ -155,8 +156,9 @@ TEST(LookupTest, replaceNestedClassName) {
// Filter Types by name since there are other `RecordTypeLoc` in the test // Filter Types by name since there are other `RecordTypeLoc` in the test
// file. // file.
// `a::b::Foo` in using shadow decl is not `TypeLoc`. // `a::b::Foo` in using shadow decl is not `TypeLoc`.
if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") {
EXPECT_EQ("Bar", replaceRecordTypeLoc(Type, "::a::x::Bar")); EXPECT_EQ("Bar", replaceRecordTypeLoc(Type, "::a::x::Bar"));
}
}; };
Visitor.runOver("namespace a { namespace b { class Foo {}; } }\n" Visitor.runOver("namespace a { namespace b { class Foo {}; } }\n"
"namespace c { using a::b::Foo; Foo f();; }\n"); "namespace c { using a::b::Foo; Foo f();; }\n");