This is an archive of the discontinued LLVM Phabricator instance.

[clang] Support `constexpr` for some `ASTNodeKind` member functions
ClosedPublic

Authored by li.zhe.hua on Oct 12 2022, 2:34 PM.

Details

Summary

Add constexpr support for:

  • The getFromNodeKind factory function
  • isSame
  • isNone
  • hasPointerIdentity

This enables these functions to be used in SFINAE context for AST node
types.

Diff Detail

Event Timeline

li.zhe.hua created this revision.Oct 12 2022, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2022, 2:34 PM
li.zhe.hua requested review of this revision.Oct 12 2022, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2022, 2:34 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added a subscriber: shafik.Oct 12 2022, 3:30 PM

LGTM, looks mostly straight forward but I am not super familiar with this code so I will let Aaron also review it too.

aaron.ballman accepted this revision.Oct 13 2022, 9:02 AM

LGTM aside from a minor question.

clang/include/clang/AST/ASTTypeTraits.h
89–91

Any reason for this to not be constexpr as well?

This revision is now accepted and ready to land.Oct 13 2022, 9:02 AM

Appease clang-format, add constexpr to operator<.

li.zhe.hua marked an inline comment as done.Oct 13 2022, 9:42 AM
li.zhe.hua added inline comments.
clang/include/clang/AST/ASTTypeTraits.h
89–91

Not in particular. I really only needed hasPointerIdentity, but figured it'd be odd not to support isSame or isNone, so the same probably goes for operator<.

This revision was landed with ongoing or failed builds.Oct 13 2022, 10:01 AM
This revision was automatically updated to reflect the committed changes.
li.zhe.hua marked an inline comment as done.