-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use if with braces to silence Wdanlging-else warning #129480
base: main
Are you sure you want to change the base?
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clangd Author: Sondre Lindkjølen (sondredl) ChangesFull diff: https://github.com/llvm/llvm-project/pull/129480.diff 2 Files Affected:
diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index 1ce28c91a420c..1e006c00dd15d 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1079,12 +1079,12 @@ TEST_F(SymbolCollectorTest, SpelledReferences) {
llvm::StringRef Main;
llvm::StringRef TargetSymbolName;
} TestCases[] = {
- {
- R"cpp(
+ {
+ R"cpp(
struct Foo;
#define MACRO Foo
)cpp",
- R"cpp(
+ R"cpp(
struct $spelled[[Foo]] {
$spelled[[Foo]]();
~$spelled[[Foo]]();
@@ -1092,34 +1092,35 @@ TEST_F(SymbolCollectorTest, SpelledReferences) {
$spelled[[Foo]] Variable1;
$implicit[[MACRO]] Variable2;
)cpp",
- "Foo",
- },
- {
- R"cpp(
+ "Foo",
+ },
+ {
+ R"cpp(
class Foo {
public:
Foo() = default;
};
)cpp",
- R"cpp(
+ R"cpp(
void f() { Foo $implicit[[f]]; f = $spelled[[Foo]]();}
)cpp",
- "Foo::Foo" /// constructor.
- },
- { // Unclean identifiers
- R"cpp(
+ "Foo::Foo" /// constructor.
+ },
+ {
+ // Unclean identifiers
+ R"cpp(
struct Foo {};
)cpp",
- R"cpp(
+ R"cpp(
$spelled[[Fo\
o]] f{};
)cpp",
- "Foo",
- },
+ "Foo",
+ },
};
CollectorOpts.RefFilter = RefKind::All;
CollectorOpts.RefsInHeaders = false;
- for (const auto& T : TestCases) {
+ for (const auto &T : TestCases) {
SCOPED_TRACE(T.Header + "\n---\n" + T.Main);
Annotations Header(T.Header);
Annotations Main(T.Main);
@@ -1145,12 +1146,14 @@ o]] f{};
ImplicitRefs = std::move(ImplicitSlabBuilder).build();
EXPECT_EQ(SpelledRanges.empty(), SpelledRefs.empty());
EXPECT_EQ(ImplicitRanges.empty(), ImplicitRefs.empty());
- if (!SpelledRanges.empty())
+ if (!SpelledRanges.empty()) {
EXPECT_THAT(SpelledRefs,
Contains(Pair(TargetID, haveRanges(SpelledRanges))));
- if (!ImplicitRanges.empty())
+ }
+ if (!ImplicitRanges.empty()) {
EXPECT_THAT(ImplicitRefs,
Contains(Pair(TargetID, haveRanges(ImplicitRanges))));
+ }
}
}
@@ -2174,14 +2177,14 @@ TEST_F(SymbolCollectorTest, Concepts) {
TEST_F(SymbolCollectorTest, IncludeHeaderForwardDecls) {
CollectorOpts.CollectIncludePath = true;
- const std::string Header = R"cpp(#pragma once
+ const std::string Header = R"cpp(#pragma once
struct Foo;
#include "full.h"
)cpp";
auto FullFile = testPath("full.h");
InMemoryFileSystem->addFile(FullFile, 0,
llvm::MemoryBuffer::getMemBuffer(R"cpp(
-#pragma once
+#pragma once
struct Foo {};)cpp"));
runSymbolCollector(Header, /*Main=*/"",
/*ExtraArgs=*/{"-I", testRoot()});
diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
index 43f38e39c8952..cec0d60b286e2 100644
--- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -141,8 +141,9 @@ class TUSchedulerTests : public ::testing::Test {
if (!D)
return;
Publish([&]() {
- const_cast<llvm::unique_function<void(PathRef, std::vector<Diag>)> &>(
- *D)(File, Diags);
+ const_cast<
+ llvm::unique_function<void(PathRef, std::vector<Diag>)> &> (*D)(
+ File, Diags);
});
}
};
@@ -445,9 +446,8 @@ TEST_F(TUSchedulerTests, InvalidationUnchanged) {
std::atomic<int> Actions(0);
Notification Start;
- updateWithDiags(S, Path, "a", WantDiagnostics::Yes, [&](std::vector<Diag>) {
- Start.wait();
- });
+ updateWithDiags(S, Path, "a", WantDiagnostics::Yes,
+ [&](std::vector<Diag>) { Start.wait(); });
S.runWithAST(
"invalidatable", Path,
[&](llvm::Expected<InputsAndAST> AST) {
@@ -1216,9 +1216,10 @@ TEST_F(TUSchedulerTests, PublishWithStalePreamble) {
void onPreambleAST(
PathRef Path, llvm::StringRef Version, CapturedASTCtx,
std::shared_ptr<const include_cleaner::PragmaIncludes>) override {
- if (BuildBefore)
+ if (BuildBefore) {
ASSERT_TRUE(UnblockPreamble.wait(timeoutSeconds(60)))
<< "Expected notification";
+ }
BuildBefore = true;
}
@@ -1593,8 +1594,7 @@ TEST_F(TUSchedulerTests, PreambleThrottle) {
// The throttler saw all files, and we built them.
EXPECT_THAT(Throttler.Acquires,
testing::UnorderedElementsAreArray(Filenames));
- EXPECT_THAT(BuiltFilenames,
- testing::UnorderedElementsAreArray(Filenames));
+ EXPECT_THAT(BuiltFilenames, testing::UnorderedElementsAreArray(Filenames));
// We built the files in reverse order that the throttler saw them.
EXPECT_THAT(BuiltFilenames,
testing::ElementsAreArray(Throttler.Acquires.rbegin(),
|
@llvm/pr-subscribers-clang-tools-extra Author: Sondre Lindkjølen (sondredl) ChangesFull diff: https://github.com/llvm/llvm-project/pull/129480.diff 2 Files Affected:
diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index 1ce28c91a420c..1e006c00dd15d 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1079,12 +1079,12 @@ TEST_F(SymbolCollectorTest, SpelledReferences) {
llvm::StringRef Main;
llvm::StringRef TargetSymbolName;
} TestCases[] = {
- {
- R"cpp(
+ {
+ R"cpp(
struct Foo;
#define MACRO Foo
)cpp",
- R"cpp(
+ R"cpp(
struct $spelled[[Foo]] {
$spelled[[Foo]]();
~$spelled[[Foo]]();
@@ -1092,34 +1092,35 @@ TEST_F(SymbolCollectorTest, SpelledReferences) {
$spelled[[Foo]] Variable1;
$implicit[[MACRO]] Variable2;
)cpp",
- "Foo",
- },
- {
- R"cpp(
+ "Foo",
+ },
+ {
+ R"cpp(
class Foo {
public:
Foo() = default;
};
)cpp",
- R"cpp(
+ R"cpp(
void f() { Foo $implicit[[f]]; f = $spelled[[Foo]]();}
)cpp",
- "Foo::Foo" /// constructor.
- },
- { // Unclean identifiers
- R"cpp(
+ "Foo::Foo" /// constructor.
+ },
+ {
+ // Unclean identifiers
+ R"cpp(
struct Foo {};
)cpp",
- R"cpp(
+ R"cpp(
$spelled[[Fo\
o]] f{};
)cpp",
- "Foo",
- },
+ "Foo",
+ },
};
CollectorOpts.RefFilter = RefKind::All;
CollectorOpts.RefsInHeaders = false;
- for (const auto& T : TestCases) {
+ for (const auto &T : TestCases) {
SCOPED_TRACE(T.Header + "\n---\n" + T.Main);
Annotations Header(T.Header);
Annotations Main(T.Main);
@@ -1145,12 +1146,14 @@ o]] f{};
ImplicitRefs = std::move(ImplicitSlabBuilder).build();
EXPECT_EQ(SpelledRanges.empty(), SpelledRefs.empty());
EXPECT_EQ(ImplicitRanges.empty(), ImplicitRefs.empty());
- if (!SpelledRanges.empty())
+ if (!SpelledRanges.empty()) {
EXPECT_THAT(SpelledRefs,
Contains(Pair(TargetID, haveRanges(SpelledRanges))));
- if (!ImplicitRanges.empty())
+ }
+ if (!ImplicitRanges.empty()) {
EXPECT_THAT(ImplicitRefs,
Contains(Pair(TargetID, haveRanges(ImplicitRanges))));
+ }
}
}
@@ -2174,14 +2177,14 @@ TEST_F(SymbolCollectorTest, Concepts) {
TEST_F(SymbolCollectorTest, IncludeHeaderForwardDecls) {
CollectorOpts.CollectIncludePath = true;
- const std::string Header = R"cpp(#pragma once
+ const std::string Header = R"cpp(#pragma once
struct Foo;
#include "full.h"
)cpp";
auto FullFile = testPath("full.h");
InMemoryFileSystem->addFile(FullFile, 0,
llvm::MemoryBuffer::getMemBuffer(R"cpp(
-#pragma once
+#pragma once
struct Foo {};)cpp"));
runSymbolCollector(Header, /*Main=*/"",
/*ExtraArgs=*/{"-I", testRoot()});
diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
index 43f38e39c8952..cec0d60b286e2 100644
--- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -141,8 +141,9 @@ class TUSchedulerTests : public ::testing::Test {
if (!D)
return;
Publish([&]() {
- const_cast<llvm::unique_function<void(PathRef, std::vector<Diag>)> &>(
- *D)(File, Diags);
+ const_cast<
+ llvm::unique_function<void(PathRef, std::vector<Diag>)> &> (*D)(
+ File, Diags);
});
}
};
@@ -445,9 +446,8 @@ TEST_F(TUSchedulerTests, InvalidationUnchanged) {
std::atomic<int> Actions(0);
Notification Start;
- updateWithDiags(S, Path, "a", WantDiagnostics::Yes, [&](std::vector<Diag>) {
- Start.wait();
- });
+ updateWithDiags(S, Path, "a", WantDiagnostics::Yes,
+ [&](std::vector<Diag>) { Start.wait(); });
S.runWithAST(
"invalidatable", Path,
[&](llvm::Expected<InputsAndAST> AST) {
@@ -1216,9 +1216,10 @@ TEST_F(TUSchedulerTests, PublishWithStalePreamble) {
void onPreambleAST(
PathRef Path, llvm::StringRef Version, CapturedASTCtx,
std::shared_ptr<const include_cleaner::PragmaIncludes>) override {
- if (BuildBefore)
+ if (BuildBefore) {
ASSERT_TRUE(UnblockPreamble.wait(timeoutSeconds(60)))
<< "Expected notification";
+ }
BuildBefore = true;
}
@@ -1593,8 +1594,7 @@ TEST_F(TUSchedulerTests, PreambleThrottle) {
// The throttler saw all files, and we built them.
EXPECT_THAT(Throttler.Acquires,
testing::UnorderedElementsAreArray(Filenames));
- EXPECT_THAT(BuiltFilenames,
- testing::UnorderedElementsAreArray(Filenames));
+ EXPECT_THAT(BuiltFilenames, testing::UnorderedElementsAreArray(Filenames));
// We built the files in reverse order that the throttler saw them.
EXPECT_THAT(BuiltFilenames,
testing::ElementsAreArray(Throttler.Acquires.rbegin(),
|
b3d537c
to
0fa9813
Compare
0fa9813
to
80741b0
Compare
the pull request aims to silence the dangling else warning when compiling the unit tests