Skip to content

Commit c3cb0d6

Browse files
committed
Swift: fix name extraction in VarDecl
1 parent 86b4f16 commit c3cb0d6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

swift/extractor/visitors/DeclVisitor.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DeclVisitor : public AstVisitorBase<DeclVisitor> {
5252

5353
void translateParamDecl(swift::ParamDecl* decl, codeql::ParamDecl* entry) {
5454
entry->id = dispatcher_.assignNewLabel(decl);
55-
fillAbstractVarDecl(decl, entry);
55+
fillVarDecl(decl, entry);
5656
}
5757

5858
void translateTopLevelCodeDecl(swift::TopLevelCodeDecl* decl, codeql::TopLevelCodeDecl* entry) {
@@ -75,7 +75,7 @@ class DeclVisitor : public AstVisitorBase<DeclVisitor> {
7575
void translateVarDecl(swift::VarDecl* decl, codeql::ConcreteVarDecl* entry) {
7676
entry->id = dispatcher_.assignNewLabel(decl);
7777
entry->introducer_int = static_cast<uint8_t>(decl->getIntroducer());
78-
fillAbstractVarDecl(decl, entry);
78+
fillVarDecl(decl, entry);
7979
}
8080

8181
void translateStructDecl(swift::StructDecl* decl, codeql::StructDecl* entry) {
@@ -161,8 +161,8 @@ class DeclVisitor : public AstVisitorBase<DeclVisitor> {
161161
void fillAbstractFunctionDecl(swift::AbstractFunctionDecl* decl,
162162
codeql::AbstractFunctionDecl* entry) {
163163
assert(decl->hasParameterList() && "Expect functions to have a parameter list");
164-
entry->name = !decl->hasName() || decl->getName().isSpecial() ? "(unnamed function decl)"
165-
: decl->getNameStr().str();
164+
entry->name = !decl->hasName() || decl->getName().isSpecial() ? "(unnamed function decl)"
165+
: decl->getNameStr().str();
166166
entry->body = dispatcher_.fetchOptionalLabel(decl->getBody());
167167
entry->params = dispatcher_.fetchRepeatedLabels(*decl->getParameters());
168168
fillValueDecl(decl, entry);
@@ -188,7 +188,8 @@ class DeclVisitor : public AstVisitorBase<DeclVisitor> {
188188
entry->members = dispatcher_.fetchRepeatedLabels(decl->getAllMembers());
189189
}
190190

191-
void fillAbstractVarDecl(swift::VarDecl* decl, codeql::VarDecl* entry) {
191+
void fillVarDecl(swift::VarDecl* decl, codeql::VarDecl* entry) {
192+
entry->name = decl->getNameStr().str();
192193
entry->type = dispatcher_.fetchLabel(decl->getType());
193194
entry->parent_pattern = dispatcher_.fetchOptionalLabel(decl->getParentPattern());
194195
entry->parent_initializer = dispatcher_.fetchOptionalLabel(decl->getParentInitializer());

0 commit comments

Comments
 (0)