[PATCH] D39122: [Sema] Fixes for enum handling for tautological comparison diagnostics

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 21 05:37:46 PDT 2017


aaron.ballman added inline comments.


================
Comment at: lib/Sema/SemaChecking.cpp:8185
+    if (!C.getLangOpts().CPlusPlus) {
+      // For enum types, for C code, use underlying data type.
+      if (const EnumType *ET = dyn_cast<EnumType>(T))
----------------
For enum types in C code, use the underlying datatype.


================
Comment at: lib/Sema/SemaChecking.cpp:8186
+      // For enum types, for C code, use underlying data type.
+      if (const EnumType *ET = dyn_cast<EnumType>(T))
+        T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
----------------
Can use `const auto *` here.


================
Comment at: lib/Sema/SemaChecking.cpp:8188
+        T = ET->getDecl()->getIntegerType().getDesugaredType(C).getTypePtr();
+    } else if (const EnumType *ET = dyn_cast<EnumType>(T)) {
+      // For enum types, in C++, use the known bit width of the enumerators.
----------------
Here as well.


================
Comment at: lib/Sema/SemaChecking.cpp:8189
+    } else if (const EnumType *ET = dyn_cast<EnumType>(T)) {
+      // For enum types, in C++, use the known bit width of the enumerators.
       EnumDecl *Enum = ET->getDecl();
----------------
For enum types in C++,


================
Comment at: lib/Sema/SemaChecking.cpp:8593
+  Min, // e.g. -32768 for short
+  Both // e.g. in C++, A::a in enum A { a = 0 };
 };
----------------
`Both` is not very descriptive -- I think `Zero` might be an improvement.


Repository:
  rL LLVM

https://reviews.llvm.org/D39122





More information about the cfe-commits mailing list