[PATCH] D30170: Function definition may have uninstantiated body

Kim Gräsman via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 13 13:34:09 PDT 2018


On Wed, Feb 28, 2018 at 8:21 PM, Richard Smith - zygoloid via
Phabricator via cfe-commits <cfe-commits at lists.llvm.org> wrote:
> ================
> Comment at: lib/Sema/SemaDecl.cpp:11986
> +      !FD->isDefined(Definition)
> +      && FD->getDeclContext()->isFileContext()) {
> +    // If this is a friend function defined in a class template, it does not
> ----------------
> `&&` on the end of the previous line, please.
>
> If the intent here is to detect non-member functions, using `!FD->isCXXClassMember()` or `!isa<CXXMethodDecl>(FD)` would be clearer.

I just recently did something like this and finally settled on
`FD->getKind() == Decl::Function`. `FunctionDecl` now has two derived
types, `CXXMethodDecl` and `CXXDeductionGuideDecl`, so the negation on
`CXXMethodDecl` is no longer strictly enough.

I think it would be nice if `FunctionDecl` had an
`isNonMemberFunction()` (or whatever the formal term is) that did the
above-mentioned check for kind equality.

For what it's worth,
- Kim


More information about the cfe-commits mailing list