From 45fbb597ec728c083abb6bc2b8dace359d8299d2 Mon Sep 17 00:00:00 2001 From: Galina Kistanova Date: Thu, 15 Jun 2017 21:01:24 +0000 Subject: [PATCH] Added braces to work around gcc warning in googletest: suggest explicit braces to avoid ambiguous 'else'. NFC. llvm-svn: 305507 --- clang/unittests/AST/CommentLexer.cpp | 3 ++- clang/unittests/ASTMatchers/ASTMatchersTest.h | 9 ++++++--- clang/unittests/Basic/VirtualFileSystemTest.cpp | 6 ++++-- clang/unittests/Tooling/LookupTest.cpp | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/clang/unittests/AST/CommentLexer.cpp b/clang/unittests/AST/CommentLexer.cpp index 77ee22ffb43e..f96d6cd15f7a 100644 --- a/clang/unittests/AST/CommentLexer.cpp +++ b/clang/unittests/AST/CommentLexer.cpp @@ -320,9 +320,10 @@ TEST_F(CommentLexerTest, DoxygenCommand4) { ASSERT_EQ(array_lengthof(Text), Toks.size()); 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()) << "index " << i; + } } } } diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.h b/clang/unittests/ASTMatchers/ASTMatchersTest.h index 4f5579ce0def..7cfe5b9e3709 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.h +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.h @@ -320,10 +320,12 @@ public: ExpectedName(ExpectedName) {} void onEndOfTranslationUnit() override { - if (ExpectedCount != -1) + if (ExpectedCount != -1) { EXPECT_EQ(ExpectedCount, Count); - if (!ExpectedName.empty()) + } + if (!ExpectedName.empty()) { EXPECT_EQ(ExpectedName, Name); + } Count = 0; Name.clear(); } @@ -346,8 +348,9 @@ public: } BoundNodes::IDToNodeMap::const_iterator I = M.find(Id); EXPECT_NE(M.end(), I); - if (I != M.end()) + if (I != M.end()) { EXPECT_EQ(Nodes->getNodeAs(Id), I->second.get()); + } return true; } EXPECT_TRUE(M.count(Id) == 0 || diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/clang/unittests/Basic/VirtualFileSystemTest.cpp index 0856b17791fa..40add2195b58 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/clang/unittests/Basic/VirtualFileSystemTest.cpp @@ -300,8 +300,9 @@ struct ScopedDir { EXPECT_FALSE(EC); } ~ScopedDir() { - if (Path != "") + if (Path != "") { EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); + } } operator StringRef() { return Path.str(); } }; @@ -316,8 +317,9 @@ struct ScopedLink { EXPECT_FALSE(EC); } ~ScopedLink() { - if (Path != "") + if (Path != "") { EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); + } } operator StringRef() { return Path.str(); } }; diff --git a/clang/unittests/Tooling/LookupTest.cpp b/clang/unittests/Tooling/LookupTest.cpp index cc3922d01b51..f42f31e9dd99 100644 --- a/clang/unittests/Tooling/LookupTest.cpp +++ b/clang/unittests/Tooling/LookupTest.cpp @@ -143,8 +143,9 @@ TEST(LookupTest, replaceNestedClassName) { Visitor.OnRecordTypeLoc = [&](RecordTypeLoc Type) { // Filter Types by name since there are other `RecordTypeLoc` in the test // file. - if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") + if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") { EXPECT_EQ("x::Bar", replaceRecordTypeLoc(Type, "::a::x::Bar")); + } }; Visitor.runOver("namespace a { namespace b {\n" "class Foo;\n" @@ -155,8 +156,9 @@ TEST(LookupTest, replaceNestedClassName) { // Filter Types by name since there are other `RecordTypeLoc` in the test // file. // `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")); + } }; Visitor.runOver("namespace a { namespace b { class Foo {}; } }\n" "namespace c { using a::b::Foo; Foo f();; }\n");