This is an archive of the discontinued LLVM Phabricator instance.

[NFC, Refactor] Convert ConstexprKind from Specifiers.h to a scoped enum
ClosedPublic

Authored by tschuett on Nov 14 2020, 2:13 PM.

Details

Summary

ninja clang clangd

Diff Detail

Event Timeline

tschuett created this revision.Nov 14 2020, 2:13 PM
tschuett requested review of this revision.Nov 14 2020, 2:13 PM
tschuett updated this revision to Diff 305333.Nov 14 2020, 3:33 PM

int -> underlying_type_t

There are some uses of static_cast<std::underlying_type_t<ConstexprSpecKind>>() that I'm not certain really need that much complexity given that I doubt we'd ever change the underlying type of the enumeration away from being an int (or something which promotes to int). Do you think using underlying_type_t adds some extra value I'm not seeing? We seem to go both ways in this patch and should be consistent -- my weak preference is to cast to int for brevity and to reduce the template instantiation work when compiling Clang, but I don't insist.

clang/include/clang/Basic/Specifiers.h
32

I think the names should probably have consistent internal casing -- the keywords are constexpr, consteval, and constinit, so it's a bit weird to have Constexpr and ConstInit. How about changing ConstEval and ConstInit to Consteval and Constinit?

clang/lib/Sema/SemaDecl.cpp
7133

This one uses int but others use underlying_type_t

9119–9122

This one uses int but others use underlying_type_t.

tschuett updated this revision to Diff 305537.Nov 16 2020, 9:10 AM
  • rebased
  • underlying_type_t -> int
  • renamed enum values
This revision is now accepted and ready to land.Nov 16 2020, 11:08 AM

Thank you for the patch, I've commit on your behalf in 41b65f166b51760f77d0f9e465b3858f46e101f0