[llvm-commits] CVS: llvm/include/llvm/CodeGen/MachOWriter.h

Nate Begeman natebegeman at mac.com
Mon Jan 29 13:21:03 PST 2007



Changes in directory llvm/include/llvm/CodeGen:

MachOWriter.h updated: 1.17 -> 1.18
---
Log message:

Properly support cstrings


---
Diffs of the changes:  (+8 -2)

 MachOWriter.h |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)


Index: llvm/include/llvm/CodeGen/MachOWriter.h
diff -u llvm/include/llvm/CodeGen/MachOWriter.h:1.17 llvm/include/llvm/CodeGen/MachOWriter.h:1.18
--- llvm/include/llvm/CodeGen/MachOWriter.h:1.17	Fri Jan 26 16:39:48 2007
+++ llvm/include/llvm/CodeGen/MachOWriter.h	Mon Jan 29 15:20:42 2007
@@ -14,6 +14,7 @@
 #ifndef LLVM_CODEGEN_MACHOWRITER_H
 #define LLVM_CODEGEN_MACHOWRITER_H
 
+#include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineRelocation.h"
@@ -486,8 +487,13 @@
     MachOSection *getDataSection() {
       return getSection("__DATA", "__data");
     }
-    MachOSection *getConstSection(const Type *Ty) {
-      // FIXME: support cstring literals and pointer literal
+    MachOSection *getConstSection(Constant *C) {
+      const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
+      if (CVA && CVA->isCString())
+        return getSection("__TEXT", "__cstring", 
+                          MachOSection::S_CSTRING_LITERALS);
+      
+      const Type *Ty = C->getType();
       if (Ty->isPrimitiveType() || Ty->isInteger()) {
         unsigned Size = TM.getTargetData()->getTypeSize(Ty);
         switch(Size) {






More information about the llvm-commits mailing list