Skip to content

Commit 30ac699

Browse files
committed
[clang][ssaf] Shorten names of EntityName factory functions
1 parent 4cab5a1 commit 30ac699

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ namespace clang::ssaf {
3030
/// \param D The declaration to map. Must not be null.
3131
///
3232
/// \return An EntityName if the declaration can be mapped, std::nullopt otherwise.
33-
std::optional<EntityName> getLocalEntityNameForDecl(const Decl* D);
33+
std::optional<EntityName> getEntityName(const Decl* D);
3434

3535
/// Maps return entity of a function to an EntityName.
3636
/// The returned name uniquely identifies the return value of function \param FD.
3737
///
3838
/// \param FD The function declaration. Must not be null.
3939
///
4040
/// \return An EntityName for the function's return entity.
41-
std::optional<EntityName> getLocalEntityNameForFunctionReturn(const FunctionDecl* FD);
41+
std::optional<EntityName> getEntityNameForReturn(const FunctionDecl* FD);
4242

4343
} // namespace clang::ssaf
4444

clang/lib/Analysis/Scalable/ASTEntityMapping.cpp

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

1919
namespace clang::ssaf {
2020

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

@@ -58,7 +58,7 @@ std::optional<EntityName> getLocalEntityNameForDecl(const Decl* D) {
5858
return EntityName(USRBuf.str(), Suffix, {});
5959
}
6060

61-
std::optional<EntityName> getLocalEntityNameForFunctionReturn(const FunctionDecl* FD) {
61+
std::optional<EntityName> getEntityNameForReturn(const FunctionDecl* FD) {
6262
if (!FD)
6363
return std::nullopt;
6464

clang/unittests/Analysis/Scalable/ASTEntityMappingTest.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ TEST(ASTEntityMappingTest, FunctionDecl) {
3939
const auto *FD = findDecl<FunctionDecl>(Ctx, "foo");
4040
ASSERT_NE(FD, nullptr);
4141

42-
auto EntityName = getLocalEntityNameForDecl(FD);
42+
auto EntityName = getEntityName(FD);
4343
EXPECT_TRUE(EntityName.has_value());
4444
}
4545

@@ -50,7 +50,7 @@ TEST(ASTEntityMappingTest, VarDecl) {
5050
const auto *VD = findDecl<VarDecl>(Ctx, "x");
5151
ASSERT_NE(VD, nullptr);
5252

53-
auto EntityName = getLocalEntityNameForDecl(VD);
53+
auto EntityName = getEntityName(VD);
5454
EXPECT_TRUE(EntityName.has_value());
5555
}
5656

@@ -65,7 +65,7 @@ TEST(ASTEntityMappingTest, ParmVarDecl) {
6565
const auto *PVD = FD->getParamDecl(0);
6666
ASSERT_NE(PVD, nullptr);
6767

68-
auto EntityName = getLocalEntityNameForDecl(PVD);
68+
auto EntityName = getEntityName(PVD);
6969
EXPECT_TRUE(EntityName.has_value());
7070
}
7171

@@ -76,7 +76,7 @@ TEST(ASTEntityMappingTest, RecordDecl) {
7676
const auto *RD = findDecl<RecordDecl>(Ctx, "S");
7777
ASSERT_NE(RD, nullptr);
7878

79-
auto EntityName = getLocalEntityNameForDecl(RD);
79+
auto EntityName = getEntityName(RD);
8080
EXPECT_TRUE(EntityName.has_value());
8181
}
8282

@@ -87,12 +87,12 @@ TEST(ASTEntityMappingTest, FieldDecl) {
8787
const auto *FD = findDecl<FieldDecl>(Ctx, "field");
8888
ASSERT_NE(FD, nullptr);
8989

90-
auto EntityName = getLocalEntityNameForDecl(FD);
90+
auto EntityName = getEntityName(FD);
9191
EXPECT_TRUE(EntityName.has_value());
9292
}
9393

9494
TEST(ASTEntityMappingTest, NullDecl) {
95-
auto EntityName = getLocalEntityNameForDecl(nullptr);
95+
auto EntityName = getEntityName(nullptr);
9696
EXPECT_FALSE(EntityName.has_value());
9797
}
9898

@@ -116,7 +116,7 @@ TEST(ASTEntityMappingTest, ImplicitDecl) {
116116
}
117117
}
118118

119-
auto EntityName = getLocalEntityNameForDecl(ImplCtor);
119+
auto EntityName = getEntityName(ImplCtor);
120120
EXPECT_FALSE(EntityName.has_value());
121121
}
122122

@@ -140,7 +140,7 @@ TEST(ASTEntityMappingTest, BuiltinFunction) {
140140
ASSERT_NE(Callee, nullptr);
141141
ASSERT_NE(Callee->getBuiltinID(), 0u /* not a built-in */);
142142

143-
auto EntityName = getLocalEntityNameForDecl(Callee);
143+
auto EntityName = getEntityName(Callee);
144144
EXPECT_FALSE(EntityName.has_value());
145145
}
146146

@@ -151,7 +151,7 @@ TEST(ASTEntityMappingTest, UnsupportedDecl) {
151151
const auto *ND = findDecl<NamespaceDecl>(Ctx, "N");
152152
ASSERT_NE(ND, nullptr);
153153

154-
auto EntityName = getLocalEntityNameForDecl(ND);
154+
auto EntityName = getEntityName(ND);
155155
EXPECT_FALSE(EntityName.has_value());
156156
}
157157

@@ -162,12 +162,12 @@ TEST(ASTEntityMappingTest, FunctionReturn) {
162162
const auto *FD = findDecl<FunctionDecl>(Ctx, "foo");
163163
ASSERT_NE(FD, nullptr);
164164

165-
auto EntityName = getLocalEntityNameForFunctionReturn(FD);
165+
auto EntityName = getEntityNameForReturn(FD);
166166
EXPECT_TRUE(EntityName.has_value());
167167
}
168168

169169
TEST(ASTEntityMappingTest, FunctionReturnNull) {
170-
auto EntityName = getLocalEntityNameForFunctionReturn(nullptr);
170+
auto EntityName = getEntityNameForReturn(nullptr);
171171
EXPECT_FALSE(EntityName.has_value());
172172
}
173173

@@ -189,7 +189,7 @@ TEST(ASTEntityMappingTest, FunctionReturnBuiltin) {
189189

190190
const auto *Callee = CE->getDirectCallee();
191191
if (Callee && Callee->getBuiltinID()) {
192-
auto EntityName = getLocalEntityNameForFunctionReturn(Callee);
192+
auto EntityName = getEntityNameForReturn(Callee);
193193
EXPECT_FALSE(EntityName.has_value());
194194
}
195195
}
@@ -206,8 +206,8 @@ TEST(ASTEntityMappingTest, DifferentFunctionsDifferentNames) {
206206
ASSERT_NE(Foo, nullptr);
207207
ASSERT_NE(Bar, nullptr);
208208

209-
auto FooName = getLocalEntityNameForDecl(Foo);
210-
auto BarName = getLocalEntityNameForDecl(Bar);
209+
auto FooName = getEntityName(Foo);
210+
auto BarName = getEntityName(Bar);
211211
ASSERT_TRUE(FooName.has_value());
212212
ASSERT_TRUE(BarName.has_value());
213213

@@ -230,14 +230,14 @@ TEST(ASTEntityMappingTest, FunctionRedeclaration) {
230230
const auto *FirstDecl = Matches[0].getNodeAs<FunctionDecl>("decl");
231231
ASSERT_NE(FirstDecl, nullptr);
232232

233-
auto FirstName = getLocalEntityNameForDecl(FirstDecl);
233+
auto FirstName = getEntityName(FirstDecl);
234234
ASSERT_TRUE(FirstName.has_value());
235235

236236
for (size_t I = 1; I < Matches.size(); ++I) {
237237
const auto *Decl = Matches[I].getNodeAs<FunctionDecl>("decl");
238238
ASSERT_NE(Decl, nullptr);
239239

240-
auto Name = getLocalEntityNameForDecl(Decl);
240+
auto Name = getEntityName(Decl);
241241
ASSERT_TRUE(Name.has_value());
242242
EXPECT_EQ(*FirstName, *Name);
243243
}
@@ -257,14 +257,14 @@ TEST(ASTEntityMappingTest, VarRedeclaration) {
257257
const auto *FirstDecl = Matches[0].getNodeAs<VarDecl>("decl");
258258
ASSERT_NE(FirstDecl, nullptr);
259259

260-
auto FirstName = getLocalEntityNameForDecl(FirstDecl);
260+
auto FirstName = getEntityName(FirstDecl);
261261
ASSERT_TRUE(FirstName.has_value());
262262

263263
for (size_t I = 1; I < Matches.size(); ++I) {
264264
const auto *Decl = Matches[I].getNodeAs<VarDecl>("decl");
265265
ASSERT_NE(Decl, nullptr);
266266

267-
auto Name = getLocalEntityNameForDecl(Decl);
267+
auto Name = getEntityName(Decl);
268268
ASSERT_TRUE(Name.has_value());
269269
EXPECT_EQ(*FirstName, *Name);
270270
}
@@ -284,14 +284,14 @@ TEST(ASTEntityMappingTest, RecordRedeclaration) {
284284
const auto *FirstDecl = Matches[0].getNodeAs<RecordDecl>("decl");
285285
ASSERT_NE(FirstDecl, nullptr);
286286

287-
auto FirstName = getLocalEntityNameForDecl(FirstDecl);
287+
auto FirstName = getEntityName(FirstDecl);
288288
ASSERT_TRUE(FirstName.has_value());
289289

290290
for (size_t I = 1; I < Matches.size(); ++I) {
291291
const auto *Decl = Matches[I].getNodeAs<RecordDecl>("decl");
292292
ASSERT_NE(Decl, nullptr);
293293

294-
auto Name = getLocalEntityNameForDecl(Decl);
294+
auto Name = getEntityName(Decl);
295295
ASSERT_TRUE(Name.has_value());
296296
EXPECT_EQ(*FirstName, *Name);
297297
}
@@ -314,15 +314,15 @@ TEST(ASTEntityMappingTest, ParmVarDeclRedeclaration) {
314314
ASSERT_NE(FirstFuncDecl, nullptr);
315315
ASSERT_GT(FirstFuncDecl->param_size(), 0u);
316316

317-
auto ParamEName = getLocalEntityNameForDecl(FirstFuncDecl->getParamDecl(0));
317+
auto ParamEName = getEntityName(FirstFuncDecl->getParamDecl(0));
318318
ASSERT_TRUE(ParamEName.has_value());
319319

320320
for (size_t I = 1; I < Matches.size(); ++I) {
321321
const auto *FDecl = Matches[I].getNodeAs<FunctionDecl>("decl");
322322
ASSERT_NE(FDecl, nullptr);
323323
ASSERT_GT(FDecl->param_size(), 0u);
324324

325-
auto ParamRedeclEName = getLocalEntityNameForDecl(FDecl->getParamDecl(0));
325+
auto ParamRedeclEName = getEntityName(FDecl->getParamDecl(0));
326326
EXPECT_EQ(*ParamEName, *ParamRedeclEName);
327327
}
328328
}
@@ -340,14 +340,14 @@ TEST(ASTEntityMappingTest, FunctionReturnRedeclaration) {
340340

341341
const auto *Decl1 = Matches[0].getNodeAs<FunctionDecl>("decl");
342342
ASSERT_NE(Decl1, nullptr);
343-
auto Name1 = getLocalEntityNameForFunctionReturn(Decl1);
343+
auto Name1 = getEntityNameForReturn(Decl1);
344344
ASSERT_TRUE(Name1.has_value());
345345

346346
for (size_t I = 1; I < Matches.size(); ++I) {
347347
const auto *FDecl = Matches[I].getNodeAs<FunctionDecl>("decl");
348348
ASSERT_NE(FDecl, nullptr);
349349

350-
auto Name = getLocalEntityNameForFunctionReturn(Decl1);
350+
auto Name = getEntityNameForReturn(Decl1);
351351
ASSERT_TRUE(Name.has_value());
352352
EXPECT_EQ(*Name1, *Name);
353353
}

0 commit comments

Comments
 (0)