On linux. Most users haven't installed libc++-dev, but ANTLR is passing
the "--stdlib=libc++" argument. As a result, this won't compile. Users
will see:
```
/tmp/antlr4/runtime/Cpp/runtime/src/antlr4-common.h:8:10: fatal error:
'algorithm' file not found
```
This is caused by the "WITH_LIBCXX" option.
It was introduced by:
d46ef90aa0
It causes the option "--stdlib=libc++" to be appended by default.
I believe its default value should have been left as "Off".
With "off" by default, clang will use its default C++ library, which is
always available.
The WITH_LIBCXX option is kept, being able to change the C++ library
might be useful?
BUG=https://github.com/antlr/antlr4/issues/2898
All other switch statements have a default case (either "break" or
"<error>"), but these are missing.
Does not change functionality, simply fixes a warning - and allows a
project to build with -Werror.
Prior to C++20, the type of a "UTF-8 encoded string literal" is char
const * - i.e. it is exactly the same as a non-prefixed string literal
(they are semantically different, but technically the same).
Since C++20, the type of a UTF-8 encoded string literal is changed to
char8_t const * - which is not convertable to char const *. Even in
C++20, there is no actual change to how characters are stored, only the
type is changed (they are now semantically different, and supposed to be
technically different - but nothing in the language actually uses the
semantics).
In short, removing the u8"" prefix has no effect prior to C++20, and
simply allows compilation to succeed since c++20.
Defining a static const member in a header breaks ODR, as the object will be
defined in every translation unit that includes the header.
Instead, the members should either be declared `inline` (which is
implicitly the case for `constexpr` members) or initialized in a cpp.
Alternatively, using an anonymous enum allows the definition to remain
inside the header meaning that the compiler can still choose to inline
values.
This commit doesn't change the behavior, it contains few small improvements:
- prevent useless copy when creating the variable tokenName
- avoid to check if tokenName is empty twice
- use std::string::empty() instead of creating an empty string to compare with
- use std::string::clear() instead of assigning an empty C string to clear a string