Skip to content

Commit 3ca3356

Browse files
committed
chore: merge function parameters
1 parent 7086f2c commit 3ca3356

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/lib/AST/ASTVisitor.cpp

+22-8
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,28 @@ class ASTVisitor
21982198
D->getExplicitSpecifier());
21992199
}
22002200

2201+
for(const ParmVarDecl* P : D->parameters())
2202+
{
2203+
auto index = P->getFunctionScopeIndex();
2204+
Param& param = index < I.Params.size() ?
2205+
I.Params[index] : I.Params.emplace_back();
2206+
// KRYSTIAN NOTE: it's not clear what the correct thing
2207+
// to do here is. this will use the longest name seen
2208+
// in any redeclaration
2209+
if(std::string_view name = P->getName();
2210+
name.size() > param.Name.size())
2211+
param.Name = name;
2212+
2213+
if(! param.Type)
2214+
param.Type = buildTypeInfo(P->getOriginalType());
2215+
2216+
const Expr* default_arg = P->hasUninstantiatedDefaultArg() ?
2217+
P->getUninstantiatedDefaultArg() : P->getInit();
2218+
if(param.Default.empty() && default_arg)
2219+
param.Default = getSourceCode(
2220+
default_arg->getSourceRange());
2221+
}
2222+
22012223
if(! created)
22022224
return;
22032225

@@ -2206,14 +2228,6 @@ class ASTVisitor
22062228
I.Class = convertToFunctionClass(
22072229
D->getDeclKind());
22082230

2209-
for(const ParmVarDecl* P : D->parameters())
2210-
{
2211-
I.Params.emplace_back(
2212-
buildTypeInfo(P->getOriginalType()),
2213-
P->getNameAsString(),
2214-
getSourceCode(P->getDefaultArgRange()));
2215-
}
2216-
22172231
QualType RT = D->getReturnType();
22182232
ExtractMode next_mode = ExtractMode::IndirectDependency;
22192233
if(auto* AT = RT->getContainedAutoType();

0 commit comments

Comments
 (0)