Opened 11 months ago

Last modified 11 months ago

#32580 new enhancement

Use clang's enum_extensibility attribute to check enum values

Reported by: teor Owned by:
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: code-correctness
Cc: Actual Points:
Parent ID: Points: 1
Reviewer: Sponsor:

Description

We could avoid constructing bad enum values using enum_extensibility:
https://clang.llvm.org/docs/AttributeReference.html#enum-extensibility

Child Tickets

Change History (3)

comment:1 Changed 11 months ago by teor

Here's how we can check for that feature in clang:
https://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros

I think the same syntax works on gcc, but we should check.

Last edited 11 months ago by teor (previous) (diff)

comment:2 Changed 11 months ago by nickm

That first link (https://clang.llvm.org/docs/AttributeReference.html#enum-extensibility) gives me an empty page. Is there a better place to find out what this is?

comment:3 in reply to:  2 Changed 11 months ago by teor

Replying to nickm:

That first link (https://clang.llvm.org/docs/AttributeReference.html#enum-extensibility) gives me an empty page. Is there a better place to find out what this is?

That's really weird, I see that too. But it worked a few days ago. And some search engines still have it indexed :-)

Here's the version from clang 9.0.0, the latest release:
https://releases.llvm.org/9.0.0/tools/clang/docs/AttributeReference.html#enum-extensibility

Note: See TracTickets for help on using tickets.