[PATCH] D135557: Add needsImplicitDefaultConstructor and friends

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 24 07:26:48 PDT 2022


aaron.ballman added a comment.

In D135557#3872324 <https://reviews.llvm.org/D135557#3872324>, @dblaikie wrote:

> In D135557#3871803 <https://reviews.llvm.org/D135557#3871803>, @aaron.ballman wrote:
>
>> In D135557#3871716 <https://reviews.llvm.org/D135557#3871716>, @dblaikie wrote:
>>
>>> (I'm still sort of curious how the AST matchers deal with all this - I guess they must have Sema available, because I'd assume they make all sorts of queries like "is this constructible from that" - since they're often trying to generate new code and want to know what constructs will be valid, which is different from the indexing use case, admittedly)
>>
>> Nope, AST matchers don't have Sema available, so they don't have a way to query "is this constructible from that". You've got the AST itself (and the `ASTContext`) and not a whole lot else beyond that.
>
> Huh, that quite surprises me as to how some transformations are implemented in that situation. I guess maybe the more syntactically interesting ones are actual clang warnings with fixits, exposed via clang-tidy, so they have sema and all.

Yup! That's how clang-tidy can appear to have sema-related diagnostics.

In D135557#3872411 <https://reviews.llvm.org/D135557#3872411>, @royjacobson wrote:

> I would be more comfortable with exposing something like `clang_CXXRecord_hasAnyNonDeletedDefaultConstructor`. It's better than the confusing `clang_CXXRecord_needsImplicitDefaultConstructor` but it would still be different from the usual type traits in a subtle way. For the other special member functions that would be enough, we can use `!CXXMethod::isIneligibleOrNotSelected()` to know if their constraints are satisfied and there's no SFINAE problems because except for default constructors they're not allowed to be templates.

I would be comfortable with such an API as that's no longer an implementation detail of our AST.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135557/new/

https://reviews.llvm.org/D135557



More information about the cfe-commits mailing list