Make command line arguments setup be endian correct!!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4605 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index b8d1c34..d11ed6e 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -980,6 +980,28 @@
}
+GenericValue Interpreter::CreateArgv(const std::vector<std::string> &InputArgv){
+ // Pointers are 64 bits...
+ PointerTy *Result = new PointerTy[InputArgv.size()+1]; // 64 bit assumption
+
+ for (unsigned i = 0; i < InputArgv.size(); ++i) {
+ unsigned Size = InputArgv[i].size()+1;
+ char *Dest = new char[Size];
+ copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
+ Dest[Size-1] = 0;
+
+ GenericValue GV; GV.PointerVal = (PointerTy)Dest;
+ // Endian safe: Result[i] = (PointerTy)Dest;
+ StoreValueToMemory(GV, (GenericValue*)(Result+i),
+ Type::LongTy); // 64 bit assumption
+ }
+
+ Result[InputArgv.size()] = 0;
+ GenericValue GV; GV.PointerVal = (PointerTy)Result;
+ return GV;
+}
+
+
//===----------------------------------------------------------------------===//
// Miscellaneous Instruction Implementations
//===----------------------------------------------------------------------===//