Skip to content

Helper for FunctionTemplateDecl -> FunctionDecl - #1104

Open
keremsahn wants to merge 1 commit into
compiler-research:mainfrom
keremsahn:ftd-helper
Open

Helper for FunctionTemplateDecl -> FunctionDecl#1104
keremsahn wants to merge 1 commit into
compiler-research:mainfrom
keremsahn:ftd-helper

Conversation

@keremsahn

Copy link
Copy Markdown
Contributor
D = UnwrapUsingShadowToFunction(D);
if (const auto* FTD = dyn_cast_or_null<FunctionTemplateDecl>(D))
    D = FTD->getTemplatedDecl();
return dyn_cast_or_null<FunctionDecl>(D);

I used this pattern at least four times and going to use again, so a helper removes repeating code

@Vipul-Cariappa

…nce this pattern written at least four times by me, to not repeat code I wrote this helper

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clang-tidy made some suggestions


// Resolves the FunctionDecl a decl names, looking through a using-shadow and
// a template pattern. Null when the decl does not name a function.
static const clang::FunctionDecl* UnwrapToFunctionDecl(const clang::Decl* D) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

warning: unused function 'UnwrapToFunctionDecl' [clang-diagnostic-unused-function]

function.
                                            ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant