Page MenuHomePhabricator

[ClangASTType] Catch unhandled clang types at compile time
AbandonedPublic

Authored by labath on Jul 10 2015, 5:44 AM.

Details

Reviewers
emaste
Summary

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).

Diff Detail

Event Timeline

labath updated this revision to Diff 29441.Jul 10 2015, 5:44 AM
labath retitled this revision from to [ClangASTType] Catch unhandled clang types at compile time.
labath updated this object.
labath added reviewers: granata.enrico, emaste.
labath added a subscriber: lldb-commits.

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.

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.

emaste edited edge metadata.Aug 30 2015, 5:58 PM

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.

granata.enrico resigned from this revision.Oct 15 2015, 1:34 PM
granata.enrico removed a reviewer: granata.enrico.
labath abandoned this revision.Nov 30 2015, 2:45 AM