Skip to content

Commit 691482c

Browse files
committed
[clang][ssaf] Apply clang-format
1 parent db34258 commit 691482c

File tree

7 files changed

+58
-51
lines changed

7 files changed

+58
-51
lines changed

clang/include/clang/Analysis/Scalable/ASTEntityMapping.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef LLVM_CLANG_ANALYSIS_SCALABLE_ASTENTITYMAPPING_H
1010
#define LLVM_CLANG_ANALYSIS_SCALABLE_ASTENTITYMAPPING_H
1111

12-
#include "clang/Analysis/Scalable/Model/EntityName.h"
1312
#include "clang/AST/Decl.h"
13+
#include "clang/Analysis/Scalable/Model/EntityName.h"
1414
#include "llvm/ADT/StringRef.h"
1515
#include <optional>
1616

@@ -29,16 +29,18 @@ namespace clang::ssaf {
2929
///
3030
/// \param D The declaration to map. Must not be null.
3131
///
32-
/// \return An EntityName if the declaration can be mapped, std::nullopt otherwise.
33-
std::optional<EntityName> getEntityName(const Decl* D);
32+
/// \return An EntityName if the declaration can be mapped, std::nullopt
33+
/// otherwise.
34+
std::optional<EntityName> getEntityName(const Decl *D);
3435

3536
/// Maps return entity of a function to an EntityName.
36-
/// The returned name uniquely identifies the return value of function \param FD.
37+
/// The returned name uniquely identifies the return value of function \param
38+
/// FD.
3739
///
3840
/// \param FD The function declaration. Must not be null.
3941
///
4042
/// \return An EntityName for the function's return entity.
41-
std::optional<EntityName> getEntityNameForReturn(const FunctionDecl* FD);
43+
std::optional<EntityName> getEntityNameForReturn(const FunctionDecl *FD);
4244

4345
} // namespace clang::ssaf
4446

clang/include/clang/Analysis/Scalable/Model/BuildNamespace.h

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626

2727
namespace clang::ssaf {
2828

29-
enum class BuildNamespaceKind : unsigned short {
30-
CompilationUnit,
31-
LinkUnit
32-
};
29+
enum class BuildNamespaceKind : unsigned short { CompilationUnit, LinkUnit };
3330

3431
llvm::StringRef toString(BuildNamespaceKind BNK);
3532

@@ -43,8 +40,8 @@ std::optional<BuildNamespaceKind> parseBuildNamespaceKind(llvm::StringRef Str);
4340
/// kind.
4441
///
4542
/// BuildNamespaces can be composed into NestedBuildNamespace to represent
46-
/// hierarchical namespace structures that model how software is constructed from
47-
/// its components.
43+
/// hierarchical namespace structures that model how software is constructed
44+
/// from its components.
4845
class BuildNamespace {
4946
BuildNamespaceKind Kind;
5047
std::string Name;
@@ -53,17 +50,17 @@ class BuildNamespace {
5350

5451
public:
5552
BuildNamespace(BuildNamespaceKind Kind, llvm::StringRef Name)
56-
: Kind(Kind), Name(Name.str()) {}
53+
: Kind(Kind), Name(Name.str()) {}
5754

5855
/// Creates a BuildNamespace representing a compilation unit.
5956
///
6057
/// \param CompilationId The unique identifier for the compilation unit.
6158
/// \returns A BuildNamespace with CompilationUnit kind.
6259
static BuildNamespace makeCompilationUnit(llvm::StringRef CompilationId);
6360

64-
bool operator==(const BuildNamespace& Other) const;
65-
bool operator!=(const BuildNamespace& Other) const;
66-
bool operator<(const BuildNamespace& Other) const;
61+
bool operator==(const BuildNamespace &Other) const;
62+
bool operator!=(const BuildNamespace &Other) const;
63+
bool operator<(const BuildNamespace &Other) const;
6764

6865
friend class SerializationFormat;
6966
};
@@ -85,10 +82,10 @@ class NestedBuildNamespace {
8582
public:
8683
NestedBuildNamespace() = default;
8784

88-
explicit NestedBuildNamespace(const std::vector<BuildNamespace>& Namespaces)
89-
: Namespaces(Namespaces) {}
85+
explicit NestedBuildNamespace(const std::vector<BuildNamespace> &Namespaces)
86+
: Namespaces(Namespaces) {}
9087

91-
explicit NestedBuildNamespace(const BuildNamespace& N) {
88+
explicit NestedBuildNamespace(const BuildNamespace &N) {
9289
Namespaces.push_back(N);
9390
}
9491

@@ -97,23 +94,25 @@ class NestedBuildNamespace {
9794
/// \param CompilationId The unique identifier for the compilation unit.
9895
/// \returns A NestedBuildNamespace containing a single CompilationUnit
9996
/// BuildNamespace.
100-
static NestedBuildNamespace makeCompilationUnit(llvm::StringRef CompilationId);
97+
static NestedBuildNamespace
98+
makeCompilationUnit(llvm::StringRef CompilationId);
10199

102100
/// Creates a new NestedBuildNamespace by appending additional namespace.
103101
///
104102
/// \param Namespace The namespace to append.
105103
NestedBuildNamespace makeQualified(NestedBuildNamespace Namespace) const {
106104
auto Copy = *this;
107-
Copy.Namespaces.reserve(Copy.Namespaces.size() + Namespace.Namespaces.size());
105+
Copy.Namespaces.reserve(Copy.Namespaces.size() +
106+
Namespace.Namespaces.size());
108107
llvm::append_range(Copy.Namespaces, Namespace.Namespaces);
109108
return Copy;
110109
}
111110

112111
bool empty() const;
113112

114-
bool operator==(const NestedBuildNamespace& Other) const;
115-
bool operator!=(const NestedBuildNamespace& Other) const;
116-
bool operator<(const NestedBuildNamespace& Other) const;
113+
bool operator==(const NestedBuildNamespace &Other) const;
114+
bool operator!=(const NestedBuildNamespace &Other) const;
115+
bool operator<(const NestedBuildNamespace &Other) const;
117116

118117
friend class JSONWriter;
119118
friend class LinkUnitResolution;

clang/include/clang/Analysis/Scalable/Model/EntityName.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class EntityName {
3838
EntityName(llvm::StringRef USR, llvm::StringRef Suffix,
3939
NestedBuildNamespace Namespace);
4040

41-
bool operator==(const EntityName& Other) const;
42-
bool operator!=(const EntityName& Other) const;
43-
bool operator<(const EntityName& Other) const;
41+
bool operator==(const EntityName &Other) const;
42+
bool operator!=(const EntityName &Other) const;
43+
bool operator<(const EntityName &Other) const;
4444

4545
/// Creates a new EntityName with additional build namespace qualification.
4646
///

clang/lib/Analysis/Scalable/ASTEntityMapping.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace clang::ssaf {
2020

21-
std::optional<EntityName> getEntityName(const Decl* D) {
21+
std::optional<EntityName> getEntityName(const Decl *D) {
2222
if (!D)
2323
return std::nullopt;
2424

@@ -34,9 +34,11 @@ std::optional<EntityName> getEntityName(const Decl* D) {
3434
llvm::SmallString<16> Suffix;
3535
const Decl *USRDecl = D;
3636

37-
// For parameters, use the parent function's USR with parameter index as suffix
38-
if (const auto * PVD = dyn_cast<ParmVarDecl>(D)) {
39-
const auto *FD = dyn_cast_or_null<FunctionDecl>(PVD->getParentFunctionOrMethod());
37+
// For parameters, use the parent function's USR with parameter index as
38+
// suffix
39+
if (const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
40+
const auto *FD =
41+
dyn_cast_or_null<FunctionDecl>(PVD->getParentFunctionOrMethod());
4042
if (!FD)
4143
return std::nullopt;
4244
USRDecl = FD;
@@ -57,7 +59,7 @@ std::optional<EntityName> getEntityName(const Decl* D) {
5759
return EntityName(USRBuf.str(), Suffix, {});
5860
}
5961

60-
std::optional<EntityName> getEntityNameForReturn(const FunctionDecl* FD) {
62+
std::optional<EntityName> getEntityNameForReturn(const FunctionDecl *FD) {
6163
if (!FD)
6264
return std::nullopt;
6365

clang/lib/Analysis/Scalable/Model/BuildNamespace.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
namespace clang::ssaf {
1414

1515
llvm::StringRef toString(BuildNamespaceKind BNK) {
16-
switch(BNK) {
17-
case BuildNamespaceKind::CompilationUnit: return "compilation_unit";
18-
case BuildNamespaceKind::LinkUnit: return "link_unit";
16+
switch (BNK) {
17+
case BuildNamespaceKind::CompilationUnit:
18+
return "compilation_unit";
19+
case BuildNamespaceKind::LinkUnit:
20+
return "link_unit";
1921
}
2022
llvm_unreachable("Unknown BuildNamespaceKind");
2123
}
@@ -28,41 +30,43 @@ std::optional<BuildNamespaceKind> parseBuildNamespaceKind(llvm::StringRef Str) {
2830
return std::nullopt;
2931
}
3032

31-
BuildNamespace BuildNamespace::makeCompilationUnit(llvm::StringRef CompilationId) {
32-
return BuildNamespace{BuildNamespaceKind::CompilationUnit, CompilationId.str()};
33+
BuildNamespace
34+
BuildNamespace::makeCompilationUnit(llvm::StringRef CompilationId) {
35+
return BuildNamespace{BuildNamespaceKind::CompilationUnit,
36+
CompilationId.str()};
3337
}
3438

35-
bool BuildNamespace::operator==(const BuildNamespace& Other) const {
39+
bool BuildNamespace::operator==(const BuildNamespace &Other) const {
3640
return asTuple() == Other.asTuple();
3741
}
3842

39-
bool BuildNamespace::operator!=(const BuildNamespace& Other) const {
43+
bool BuildNamespace::operator!=(const BuildNamespace &Other) const {
4044
return !(*this == Other);
4145
}
4246

43-
bool BuildNamespace::operator<(const BuildNamespace& Other) const {
47+
bool BuildNamespace::operator<(const BuildNamespace &Other) const {
4448
return asTuple() < Other.asTuple();
4549
}
4650

47-
NestedBuildNamespace NestedBuildNamespace::makeCompilationUnit(llvm::StringRef CompilationId) {
51+
NestedBuildNamespace
52+
NestedBuildNamespace::makeCompilationUnit(llvm::StringRef CompilationId) {
4853
NestedBuildNamespace Result;
49-
Result.Namespaces.push_back(BuildNamespace::makeCompilationUnit(CompilationId));
54+
Result.Namespaces.push_back(
55+
BuildNamespace::makeCompilationUnit(CompilationId));
5056
return Result;
5157
}
5258

53-
bool NestedBuildNamespace::empty() const {
54-
return Namespaces.empty();
55-
}
59+
bool NestedBuildNamespace::empty() const { return Namespaces.empty(); }
5660

57-
bool NestedBuildNamespace::operator==(const NestedBuildNamespace& Other) const {
61+
bool NestedBuildNamespace::operator==(const NestedBuildNamespace &Other) const {
5862
return Namespaces == Other.Namespaces;
5963
}
6064

61-
bool NestedBuildNamespace::operator!=(const NestedBuildNamespace& Other) const {
65+
bool NestedBuildNamespace::operator!=(const NestedBuildNamespace &Other) const {
6266
return !(*this == Other);
6367
}
6468

65-
bool NestedBuildNamespace::operator<(const NestedBuildNamespace& Other) const {
69+
bool NestedBuildNamespace::operator<(const NestedBuildNamespace &Other) const {
6670
return Namespaces < Other.Namespaces;
6771
}
6872

clang/lib/Analysis/Scalable/Model/EntityName.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ namespace clang::ssaf {
1212

1313
EntityName::EntityName(llvm::StringRef USR, llvm::StringRef Suffix,
1414
NestedBuildNamespace Namespace)
15-
: USR(USR.str()), Suffix(Suffix), Namespace(std::move(Namespace)) {}
15+
: USR(USR.str()), Suffix(Suffix), Namespace(std::move(Namespace)) {}
1616

17-
bool EntityName::operator==(const EntityName& Other) const {
17+
bool EntityName::operator==(const EntityName &Other) const {
1818
return asTuple() == Other.asTuple();
1919
}
2020

21-
bool EntityName::operator!=(const EntityName& Other) const {
21+
bool EntityName::operator!=(const EntityName &Other) const {
2222
return !(*this == Other);
2323
}
2424

clang/unittests/Analysis/Scalable/ASTEntityMappingTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ TEST(ASTEntityMappingTest, ImplicitDeclLambda) {
106106
auto Matches = match(Matcher, Ctx);
107107
ASSERT_GT(Matches.size(), 0u);
108108

109-
const auto * ImplCXXRD = Matches[0].getNodeAs<CXXRecordDecl>("decl");
109+
const auto *ImplCXXRD = Matches[0].getNodeAs<CXXRecordDecl>("decl");
110110
ASSERT_NE(ImplCXXRD, nullptr);
111111

112112
auto EntityName = getEntityName(ImplCXXRD);

0 commit comments

Comments
 (0)