[cfe-dev] [libc++]bitmask element ECMAScript is 0
Jason Liu via cfe-dev
cfe-dev at lists.llvm.org
Thu Oct 13 08:12:17 PDT 2016
When I was browsing regex header from libcxx, I found the following code:
enum syntax_option_type
{
icase = 1 << 0,
nosubs = 1 << 1,
optimize = 1 << 2,
collate = 1 << 3,
ECMAScript = 0,
basic = 1 << 4,
extended = 1 << 5,
awk = 1 << 6,
grep = 1 << 7,
egrep = 1 << 8
};
syntax_option_type is an implementation-defined bitmask type. According to
standard, bitmask elements have distinct, nonzero values. And the value 0
is used to represent an empty bitmask, in which no bitmask elements are
set.
Standard does mention that if no grammar element is set, the default
grammar is ECMAScript. But ECMAScript still looks like a bitmask element
inside of bitmask type syntax_option_type to me, which means it should be
non-zero.
Interestingly, when I look at the history of regex header, ECMAScript was a
non-zero value at some point, but got changed to 0 in a later commit.
So my questions are... Any reasons why we changed it to 0? (Maybe for
cleaner implementation?) Is this still standard compliant? If not, should
we modify it to be more standard compliant?
Thanks in advance!
Regards,
Jason Liu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161013/f8bd5af3/attachment.html>
More information about the cfe-dev
mailing list