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 cpp,h --
clang/include/clang/Analysis/Scalable/Model/EntityId.h
clang/include/clang/Analysis/Scalable/Model/EntityIdTable.h
clang/lib/Analysis/Scalable/Model/EntityIdTable.cpp
clang/unittests/Analysis/Scalable/EntityIdTableTest.cpp
clang/unittests/Analysis/Scalable/EntityIdTest.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/include/clang/Analysis/Scalable/Model/EntityId.h
b/clang/include/clang/Analysis/Scalable/Model/EntityId.h
index 764005169..62160c0b5 100644
--- a/clang/include/clang/Analysis/Scalable/Model/EntityId.h
+++ b/clang/include/clang/Analysis/Scalable/Model/EntityId.h
@@ -38,9 +38,9 @@ class EntityId {
EntityId() = delete;
public:
- bool operator==(const EntityId& Other) const { return Index == Other.Index; }
- bool operator<(const EntityId& Other) const { return Index < Other.Index; }
- bool operator!=(const EntityId& Other) const { return !(*this == Other); }
+ bool operator==(const EntityId &Other) const { return Index == Other.Index; }
+ bool operator<(const EntityId &Other) const { return Index < Other.Index; }
+ bool operator!=(const EntityId &Other) const { return !(*this == Other); }
};
} // namespace ssaf
diff --git a/clang/include/clang/Analysis/Scalable/Model/EntityIdTable.h
b/clang/include/clang/Analysis/Scalable/Model/EntityIdTable.h
index 9df19b36c..572c7d3ef 100644
--- a/clang/include/clang/Analysis/Scalable/Model/EntityIdTable.h
+++ b/clang/include/clang/Analysis/Scalable/Model/EntityIdTable.h
@@ -25,7 +25,7 @@ namespace ssaf {
class EntityIdTable {
std::set<EntityName> Entities;
- std::vector<const EntityName*> IdToEntity;
+ std::vector<const EntityName *> IdToEntity;
public:
EntityIdTable() = default;
@@ -34,15 +34,16 @@ public:
///
/// If the entity already exists in the table, returns its existing Id.
/// Otherwise, creates and returns a new Id. This operation is idempotent.
- EntityId createEntityId(const EntityName& Name);
+ EntityId createEntityId(const EntityName &Name);
/// Returns true if an entity with the given name exists in the table.
- bool exists(const EntityName& Name) const;
+ bool exists(const EntityName &Name) const;
/// Invokes the callback for each entity in the table.
///
/// Iteration order is unspecified.
- void forEach(std::function<void(const EntityName&, EntityId)> Callback)
const;
+ void
+ forEach(std::function<void(const EntityName &, EntityId)> Callback) const;
/// Returns the number of unique entities in the table.
size_t count() const;
diff --git a/clang/lib/Analysis/Scalable/Model/EntityIdTable.cpp
b/clang/lib/Analysis/Scalable/Model/EntityIdTable.cpp
index b47d8d512..7322ff604 100644
--- a/clang/lib/Analysis/Scalable/Model/EntityIdTable.cpp
+++ b/clang/lib/Analysis/Scalable/Model/EntityIdTable.cpp
@@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//
#include "clang/Analysis/Scalable/Model/EntityIdTable.h"
-#include <cassert>
#include <algorithm>
+#include <cassert>
namespace clang {
namespace ssaf {
-EntityId EntityIdTable::createEntityId(const EntityName& Name) {
+EntityId EntityIdTable::createEntityId(const EntityName &Name) {
auto [It, Inserted] = Entities.insert(Name);
if (Inserted) {
@@ -21,7 +21,7 @@ EntityId EntityIdTable::createEntityId(const EntityName&
Name) {
return EntityId(IdToEntity.size() - 1);
}
- const EntityName* EntityPtr = &(*It);
+ const EntityName *EntityPtr = &(*It);
auto IdIt = std::find(IdToEntity.begin(), IdToEntity.end(), EntityPtr);
assert(IdIt != IdToEntity.end() && "Entity exists but has no ID");
@@ -29,21 +29,20 @@ EntityId EntityIdTable::createEntityId(const EntityName&
Name) {
return EntityId(Index);
}
-bool EntityIdTable::exists(const EntityName& Name) const {
+bool EntityIdTable::exists(const EntityName &Name) const {
return Entities.find(Name) != Entities.end();
}
-void EntityIdTable::forEach(std::function<void(const EntityName&, EntityId)>
Callback) const {
+void EntityIdTable::forEach(
+ std::function<void(const EntityName &, EntityId)> Callback) const {
for (size_t Index = 0; Index < IdToEntity.size(); ++Index) {
EntityId EId(Index);
- const EntityName& Name = *IdToEntity[Index];
+ const EntityName &Name = *IdToEntity[Index];
Callback(Name, EId);
}
}
-size_t EntityIdTable::count() const {
- return IdToEntity.size();
-}
+size_t EntityIdTable::count() const { return IdToEntity.size(); }
} // namespace ssaf
} // namespace clang
diff --git a/clang/unittests/Analysis/Scalable/EntityIdTableTest.cpp
b/clang/unittests/Analysis/Scalable/EntityIdTableTest.cpp
index 4f8a164db..b13760927 100644
--- a/clang/unittests/Analysis/Scalable/EntityIdTableTest.cpp
+++ b/clang/unittests/Analysis/Scalable/EntityIdTableTest.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
#include "clang/Analysis/Scalable/Model/EntityIdTable.h"
+#include "clang/Analysis/Scalable/Model/BuildNamespace.h"
#include "clang/Analysis/Scalable/Model/EntityId.h"
#include "clang/Analysis/Scalable/Model/EntityName.h"
-#include "clang/Analysis/Scalable/Model/BuildNamespace.h"
#include "gtest/gtest.h"
namespace clang {
@@ -86,7 +86,8 @@ TEST(EntityIdTableTest, WithBuildNamespace) {
NestedBuildNamespace NS =
NestedBuildNamespace::makeCompilationUnit("test.o");
EntityName Entity1("c:@F@foo", "", NS);
- EntityName Entity2("c:@F@foo", "",
NestedBuildNamespace::makeCompilationUnit("other.o"));
+ EntityName Entity2("c:@F@foo", "",
+ NestedBuildNamespace::makeCompilationUnit("other.o"));
EntityId Id1 = Table.createEntityId(Entity1);
EntityId Id2 = Table.createEntityId(Entity2);
@@ -98,9 +99,8 @@ TEST(EntityIdTableTest, ForEachEmptyTable) {
EntityIdTable Table;
int CallbackCount = 0;
- Table.forEach([&CallbackCount](const EntityName&, EntityId) {
- CallbackCount++;
- });
+ Table.forEach(
+ [&CallbackCount](const EntityName &, EntityId) { CallbackCount++; });
EXPECT_EQ(CallbackCount, 0);
}
@@ -119,7 +119,7 @@ TEST(EntityIdTableTest, ForEachMultipleEntities) {
std::set<EntityId> VisitedIds;
std::set<EntityName> VisitedNames;
- Table.forEach([&](const EntityName& Name, EntityId Id) {
+ Table.forEach([&](const EntityName &Name, EntityId Id) {
VisitedIds.insert(Id);
VisitedNames.insert(Name);
});
diff --git a/clang/unittests/Analysis/Scalable/EntityIdTest.cpp
b/clang/unittests/Analysis/Scalable/EntityIdTest.cpp
index bf6c9be13..669c12a37 100644
--- a/clang/unittests/Analysis/Scalable/EntityIdTest.cpp
+++ b/clang/unittests/Analysis/Scalable/EntityIdTest.cpp
@@ -51,11 +51,9 @@ TEST(EntityIdTest, Transitivity) {
EntityName Entity2("c:@F@yyy", "", {});
EntityName Entity3("c:@F@zzz", "", {});
- EntityId Ids[3] = {
- Table.createEntityId(Entity1),
- Table.createEntityId(Entity2),
- Table.createEntityId(Entity3)
- };
+ EntityId Ids[3] = {Table.createEntityId(Entity1),
+ Table.createEntityId(Entity2),
+ Table.createEntityId(Entity3)};
std::sort(Ids, Ids + 3);
``````````
</details>
https://github.com/llvm/llvm-project/pull/171660
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits