Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3876,8 +3876,17 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {

FunctionTypeLoc FunctionDecl::getFunctionTypeLoc() const {
const TypeSourceInfo *TSI = getTypeSourceInfo();
return TSI ? TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>()
: FunctionTypeLoc();

if (!TSI)
return FunctionTypeLoc();

TypeLoc TL = TSI->getTypeLoc().IgnoreParens();

// ignore function type attributes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other sugars we need to ignore? e.g., a ParenType via:

void (foo)(int f) {}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. But to implement it in its updated form, I mimicked getAsAdjusted. So currently, it supports ParenType and AttributedType. I think I should add MacroQualifiedType for example.

while (auto ATL = TL.getAs<AttributedTypeLoc>())
TL = ATL.getModifiedLoc();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't THINK we want this? We want to keep around the 'type' as modified by the attributed type (so if it is no_return, we want to make sure we have a noreturn function type for example). So I would think we would want the Equivalent type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad I've made this error. I'll start by adding your example as a test.


return TL.getAs<FunctionTypeLoc>();
}

SourceRange FunctionDecl::getReturnTypeSourceRange() const {
Expand Down
Loading