[Lldb-commits] [PATCH] D11099: [ClangASTType] Catch unhandled clang types at compile time

Pavel Labath labath at google.com
Fri Jul 10 05:44:44 PDT 2015


labath created this revision.
labath added reviewers: granata.enrico, emaste.
labath added a subscriber: lldb-commits.

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

http://reviews.llvm.org/D11099

Files:
  source/Symbol/ClangASTType.cpp

Index: source/Symbol/ClangASTType.cpp
===================================================================
--- source/Symbol/ClangASTType.cpp
+++ source/Symbol/ClangASTType.cpp
@@ -52,6 +52,11 @@
 #include <iterator>
 #include <mutex>
 
+// We make this a hard error to detect cases when clang introduces new types, but we do not
+// handle them yet. If you get a compiler error about an enumeration value missing from a switch in
+// this file, then you need to add code to handle the new type.
+#pragma GCC diagnostic error "-Wswitch"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -2212,7 +2217,6 @@
         case clang::Type::Builtin:
             switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind())
         {
-            default: assert(0 && "Unknown builtin type!");
             case clang::BuiltinType::Void:
                 break;
                 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11099.29441.patch
Type: text/x-patch
Size: 884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150710/75b12ee3/attachment.bin>


More information about the lldb-commits mailing list