[llvm] r183749 - Fix variable name style. Don't cast to and from int.

Rafael Espindola rafael.espindola at gmail.com
Tue Jun 11 08:29:11 PDT 2013


Author: rafael
Date: Tue Jun 11 10:29:10 2013
New Revision: 183749

URL: http://llvm.org/viewvc/llvm-project?rev=183749&view=rev
Log:
Fix variable name style. Don't cast to and from int.

This enables the compiler to see the enum and produce warnings about a switch
not being fully covered. Fix one of these warnings.

Modified:
    llvm/trunk/include/llvm/Support/FileSystem.h
    llvm/trunk/lib/Object/ObjectFile.cpp

Modified: llvm/trunk/include/llvm/Support/FileSystem.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=183749&r1=183748&r2=183749&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileSystem.h (original)
+++ llvm/trunk/include/llvm/Support/FileSystem.h Tue Jun 11 10:29:10 2013
@@ -181,7 +181,7 @@ public:
 /// file_magic - An "enum class" enumeration of file types based on magic (the first
 ///         N bytes of the file).
 struct file_magic {
-  enum _ {
+  enum Impl {
     unknown = 0,              ///< Unrecognized file
     bitcode,                  ///< Bitcode file
     archive,                  ///< ar style archive file
@@ -204,16 +204,15 @@ struct file_magic {
   };
 
   bool is_object() const {
-    return v_ == unknown ? false : true;
+    return V == unknown ? false : true;
   }
 
-  file_magic() : v_(unknown) {}
-  file_magic(_ v) : v_(v) {}
-  explicit file_magic(int v) : v_(_(v)) {}
-  operator int() const {return v_;}
+  file_magic() : V(unknown) {}
+  file_magic(Impl V) : V(V) {}
+  operator Impl() const { return V; }
 
 private:
-  int v_;
+  Impl V;
 };
 
 /// @}

Modified: llvm/trunk/lib/Object/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ObjectFile.cpp?rev=183749&r1=183748&r2=183749&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ObjectFile.cpp Tue Jun 11 10:29:10 2013
@@ -44,6 +44,8 @@ ObjectFile *ObjectFile::createObjectFile
   sys::fs::file_magic Type = sys::fs::identify_magic(Object->getBuffer());
   switch (Type) {
   case sys::fs::file_magic::unknown:
+  case sys::fs::file_magic::bitcode:
+  case sys::fs::file_magic::archive:
     return 0;
   case sys::fs::file_magic::elf_relocatable:
   case sys::fs::file_magic::elf_executable:





More information about the llvm-commits mailing list