Skip to content

Commit

Permalink
Fixed #606: Correct handling of parentheses in a variable declaration.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasfertig committed Feb 13, 2024
1 parent fa206b9 commit 7716e5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions InsightsHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,19 @@ static bool HasTypeWithSubType(const QualType& t)
}
//-----------------------------------------------------------------------------

template<typename QT, typename SUB_T>
static bool HasTypePath(const QualType& t)
{
if(const auto* lref = dyn_cast_or_null<QT>(t.getTypePtrOrNull())) {
const auto subType = GetDesugarType(lref->getPointeeType());

return isa<SUB_T>(subType);
}

return false;
}
//-----------------------------------------------------------------------------

std::string GetTypeNameAsParameter(const QualType& t, std::string_view varName, const Unqualified unqualified)
{
const bool isFunctionPointer =
Expand Down Expand Up @@ -1225,6 +1238,8 @@ std::string GetTypeNameAsParameter(const QualType& t, std::string_view varName,
} else {
typeName += StrCat(" "sv, varName);
}
} else if(HasTypePath<PointerType, ParenType>(t)) {
InsertAfter(typeName, "(*"sv, varName);

} else if(not isRawArrayType and not varName.empty()) {
typeName += StrCat(" "sv, varName);
Expand Down
1 change: 1 addition & 0 deletions tests/Issue606.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void (*p);
2 changes: 2 additions & 0 deletions tests/Issue606.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
void (*p);

0 comments on commit 7716e5e

Please sign in to comment.