[llvm-commits] CVS: llvm/lib/VMCore/Module.cpp

Owen Anderson resistor at mac.com
Wed May 17 22:46:20 PDT 2006



Changes in directory llvm/lib/VMCore:

Module.cpp updated: 1.66 -> 1.67
---
Log message:

Fix some think-o's in my last commit. Thanks to Chris for pointing them out.


---
Diffs of the changes:  (+18 -16)

 Module.cpp |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)


Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.66 llvm/lib/VMCore/Module.cpp:1.67
--- llvm/lib/VMCore/Module.cpp:1.66	Wed May 17 21:10:31 2006
+++ llvm/lib/VMCore/Module.cpp	Thu May 18 00:46:08 2006
@@ -89,58 +89,60 @@
 /// Target endian information...
 Module::Endianness Module::getEndianness() const {
   std::string temp = DataLayout;
+  Module::Endianness ret = AnyEndianness;
   
-  while (temp.length() > 0) {
+  while (!temp.empty()) {
     std::string token = getToken(temp, "-");
     
     if (token[0] == 'e') {
-      return LittleEndian;
+      ret = LittleEndian;
     } else if (token[0] == 'E') {
-      return BigEndian;
+      ret = BigEndian;
     }
   }
   
-  return AnyEndianness;
+  return ret;
 }
 
 void Module::setEndianness(Endianness E) {
-  if (DataLayout.compare("") != 0 && E != AnyEndianness)
-    DataLayout.insert(0, "-");
+  if (!DataLayout.empty() && E != AnyEndianness)
+    DataLayout += "-";
   
   if (E == LittleEndian)
-    DataLayout.insert(0, "e");
+    DataLayout += "e";
   else if (E == BigEndian)
-    DataLayout.insert(0, "E");
+    DataLayout += "E";
 }
 
 /// Target Pointer Size information...
 Module::PointerSize Module::getPointerSize() const {
   std::string temp = DataLayout;
+  Module::PointerSize ret = AnyPointerSize;
   
-  while (temp.length() > 0) {
+  while (!temp.empty()) {
     std::string token = getToken(temp, "-");
     char signal = getToken(token, ":")[0];
     
     if (signal == 'p') {
       int size = atoi(getToken(token, ":").c_str());
       if (size == 32)
-        return Pointer32;
+        ret = Pointer32;
       else if (size == 64)
-        return Pointer64;
+        ret = Pointer64;
     }
   }
   
-  return AnyPointerSize;
+  return ret;
 }
 
 void Module::setPointerSize(PointerSize PS) {
-  if (DataLayout.compare("") != 0 && PS != AnyPointerSize)
-    DataLayout.insert(0, "-");
+  if (!DataLayout.empty() && PS != AnyPointerSize)
+    DataLayout += "-";
   
   if (PS == Pointer32)
-    DataLayout.insert(0, "p:32:32");
+    DataLayout += "p:32:32";
   else if (PS == Pointer64)
-    DataLayout.insert(0, "p:64:64");
+    DataLayout += "p:64:64";
 }
 
 //===----------------------------------------------------------------------===//






More information about the llvm-commits mailing list