To avoid situations where clang adds a new type and we don't notice that, this commit turns
-Wswitch into a fatal compile error when compiling ClangASTType.cpp. This enables us to remove an
assertion, which was guarding this condition at runtime (and producing annoying warnings).
Details
- Reviewers
emaste
Diff Detail
Event Timeline
Is it only this one switch statement that needs this assertion? Maybe the pragma should be localized to this part (with push/pop)? Also, I'm not sure if any other compilers are supported but this wouldn't work with MSVC.
I am no expert in this area, but it seems to me that basically the whole file is made of switch statements on clang enums and that they all could use some protection.
It is true that we won't get this protection on MSVC, but I don't think that's a big problem. Since this is not OS-dependent, it should be enough that at least some compilers are verifying this. However, if you know the right incantations to produce an error on MSVC, we can definitely add them.
For clang and gcc we pass -Wno-unknown-pragma, but I don't know if we have a MSVC equivalent. If we don't and this produces a warning there, we can make this pragma #ifndef MSVC.
AFAIK, there's no equivalent for this with MSVC. I think it would be a good
idea to wrap the pragma around an ifdef.
This seems fine to me - I agree that as long as we'll catch this e.g. through one compiler on the build bots it should be sufficient.