github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp --
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
--diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang-tools-extra/clangd/XRefs.cpp
b/clang-tools-extra/clangd/XRefs.cpp
index e49d28323..9b0c39b9f 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -65,7 +65,6 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-#include "support/Logger.h"
#include <algorithm>
#include <optional>
#include <string>
@@ -1787,9 +1786,9 @@ public:
bool HasWrite = false;
bool HasRead = false;
const ValueDecl *TargetParam;
-
+
ParamUsageVisitor(const ValueDecl *P) : TargetParam(P) {}
-
+
// Any reference to the target is at least a read, unless we later
// identify it specifically as a write (e.g. assignment/inc/dec on LHS).
bool VisitDeclRefExpr(DeclRefExpr *DRE) {
@@ -1809,7 +1808,7 @@ public:
}
return true;
}
-
+
bool VisitBinaryOperator(BinaryOperator *BO) {
// Check for assignment to parameter
if (BO->isAssignmentOp()) {
@@ -1892,7 +1891,7 @@ declToHierarchyItem(const NamedDecl &ND, llvm::StringRef
TUPath) {
HI.range = HI.selectionRange;
}
- //determineParameterUsage(ND, HI);
+ // determineParameterUsage(ND, HI);
HI.uri = URIForFile::canonicalize(*FilePath, TUPath);
@@ -2472,7 +2471,8 @@ const NamedDecl *getNamedDeclFromSymbol(const Symbol &Sym,
}
std::vector<CallHierarchyIncomingCall>
-incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index,
ParsedAST &AST) {
+incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index,
+ ParsedAST &AST) {
std::vector<CallHierarchyIncomingCall> Results;
if (!Index || Item.data.empty())
return Results;
@@ -2482,11 +2482,10 @@ incomingCalls(const CallHierarchyItem &Item, const
SymbolIndex *Index, ParsedAST
return Results;
}
-
LookupRequest LR;
LR.IDs.insert(*ID);
- std::optional<const NamedDecl*> PVD;
+ std::optional<const NamedDecl *> PVD;
Index->lookup(LR, [&ID, &AST, &PVD](const Symbol &Sym) {
// This callback is called once per found symbol; here we expect exactly
one
if (Sym.ID == *ID) {
@@ -2542,7 +2541,8 @@ incomingCalls(const CallHierarchyItem &Item, const
SymbolIndex *Index, ParsedAST
if (const auto *FD = llvm::dyn_cast<clang::FunctionDecl>(ND)) {
if (isa<ValueDecl>(PVD.value())) {
const auto *VD = llvm::dyn_cast<clang::ValueDecl>(PVD.value());
- CHI->referenceTags = analyseParameterUsage(FD, VD); // FD is the
caller of var
+ CHI->referenceTags =
+ analyseParameterUsage(FD, VD); // FD is the caller of var
}
}
} else {
diff --git a/clang-tools-extra/clangd/XRefs.h b/clang-tools-extra/clangd/XRefs.h
index 911cf72d7..31e7b0b14 100644
--- a/clang-tools-extra/clangd/XRefs.h
+++ b/clang-tools-extra/clangd/XRefs.h
@@ -148,7 +148,8 @@ std::vector<CallHierarchyItem>
prepareCallHierarchy(ParsedAST &AST, Position Pos, PathRef TUPath);
std::vector<CallHierarchyIncomingCall>
-incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index,
ParsedAST &AST);
+incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index,
+ ParsedAST &AST);
std::vector<CallHierarchyOutgoingCall>
outgoingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index);
diff --git a/clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
b/clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
index ad5c7d06a..c7d0c297f 100644
--- a/clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -402,7 +402,8 @@ TEST(CallHierarchy, MultiFileCpp) {
withDetail("nsa::caller1"))),
iFromRanges(Caller1C.range()))));
- auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get(),
AST);
+ auto IncomingLevel2 =
+ incomingCalls(IncomingLevel1[0].from, Index.get(), AST);
ASSERT_THAT(
IncomingLevel2,
ElementsAre(
@@ -411,13 +412,15 @@ TEST(CallHierarchy, MultiFileCpp) {
AllOf(from(AllOf(withName("caller3"), withDetail("nsa::caller3"))),
iFromRanges(Caller3C.range("Caller1")))));
- auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get(),
AST);
+ auto IncomingLevel3 =
+ incomingCalls(IncomingLevel2[0].from, Index.get(), AST);
ASSERT_THAT(IncomingLevel3,
ElementsAre(AllOf(from(AllOf(withName("caller3"),
withDetail("nsa::caller3"))),
iFromRanges(Caller3C.range("Caller2")))));
- auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get(),
AST);
+ auto IncomingLevel4 =
+ incomingCalls(IncomingLevel3[0].from, Index.get(), AST);
EXPECT_THAT(IncomingLevel4, IsEmpty());
};
@@ -558,7 +561,8 @@ TEST(CallHierarchy, IncomingMultiFileObjC) {
ElementsAre(AllOf(from(withName("caller1")),
iFromRanges(Caller1C.range()))));
- auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get(),
AST);
+ auto IncomingLevel2 =
+ incomingCalls(IncomingLevel1[0].from, Index.get(), AST);
ASSERT_THAT(IncomingLevel2,
ElementsAre(AllOf(from(withName("caller2")),
iFromRanges(Caller2C.range("A"),
@@ -566,12 +570,14 @@ TEST(CallHierarchy, IncomingMultiFileObjC) {
AllOf(from(withName("caller3")),
iFromRanges(Caller3C.range("Caller1")))));
- auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get(),
AST);
+ auto IncomingLevel3 =
+ incomingCalls(IncomingLevel2[0].from, Index.get(), AST);
ASSERT_THAT(IncomingLevel3,
ElementsAre(AllOf(from(withName("caller3")),
iFromRanges(Caller3C.range("Caller2")))));
- auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get(),
AST);
+ auto IncomingLevel4 =
+ incomingCalls(IncomingLevel3[0].from, Index.get(), AST);
EXPECT_THAT(IncomingLevel4, IsEmpty());
};
@@ -671,7 +677,8 @@ TEST(CallHierarchy, HierarchyOnVar) {
}
TEST(CallHierarchy, HierarchyOnVarWithReadReference) {
- // Tests that the call hierarchy works on non-local variables and read/write
tags are set.
+ // Tests that the call hierarchy works on non-local variables and read/write
+ // tags are set.
Annotations Source(R"cpp(
int v^ar = 1;
void caller() {
@@ -687,11 +694,13 @@ TEST(CallHierarchy, HierarchyOnVarWithReadReference) {
prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
ASSERT_THAT(Items, ElementsAre(withName("var")));
auto IncomingLevel1 = incomingCalls(Items[0], Index.get(), AST);
- EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(0) ==
ReferenceTag::Read);
+ EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(0) ==
+ ReferenceTag::Read);
}
TEST(CallHierarchy, HierarchyOnVarWithWriteReference) {
- // Tests that the call hierarchy works on non-local variables and read/write
tags are set.
+ // Tests that the call hierarchy works on non-local variables and read/write
+ // tags are set.
Annotations Source(R"cpp(
int v^ar = 1;
void caller() {
@@ -706,11 +715,13 @@ TEST(CallHierarchy, HierarchyOnVarWithWriteReference) {
prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
ASSERT_THAT(Items, ElementsAre(withName("var")));
auto IncomingLevel1 = incomingCalls(Items[0], Index.get(), AST);
- EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(0) ==
ReferenceTag::Write);
+ EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(0) ==
+ ReferenceTag::Write);
}
TEST(CallHierarchy, HierarchyOnVarWithUnaryWriteReference) {
- // Tests that the call hierarchy works on non-local variables and read/write
tags are set.
+ // Tests that the call hierarchy works on non-local variables and read/write
+ // tags are set.
Annotations Source(R"cpp(
int v^ar = 1;
void caller() {
@@ -725,12 +736,13 @@ TEST(CallHierarchy,
HierarchyOnVarWithUnaryWriteReference) {
prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
ASSERT_THAT(Items, ElementsAre(withName("var")));
auto IncomingLevel1 = incomingCalls(Items[0], Index.get(), AST);
- EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(0) ==
ReferenceTag::Write);
+ EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(0) ==
+ ReferenceTag::Write);
}
// TEST(CallHierarchy, HierarchyOnFieldWithReadWriteReference) {
-// // Tests that the call hierarchy works on non-local variables and
read/write tags are set.
-// Annotations Source(R"cpp(
+// // Tests that the call hierarchy works on non-local variables and
+// read/write tags are set. Annotations Source(R"cpp(
// struct Vars {
// int v^ar1 = 1;
// };
@@ -747,8 +759,10 @@ TEST(CallHierarchy, HierarchyOnVarWithUnaryWriteReference)
{
// prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
// ASSERT_THAT(Items, ElementsAre(withName("var1")));
// auto IncomingLevel1 = incomingCalls(Items[0], Index.get(), AST);
-// EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(0) ==
ReferenceTag::Read);
-// //EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(1) ==
ReferenceTag::Read);
+// EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(0) ==
+// ReferenceTag::Read);
+// //EXPECT_TRUE(IncomingLevel1.front().from.referenceTags.at(1) ==
+// ReferenceTag::Read);
// }
TEST(CallHierarchy, HierarchyOnEnumConstant) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/172462
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits