summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-05-29 02:58:15 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-05-29 02:58:15 +0000
commit74e032a4d4673f53388571ab9ecd783584e3fccf (patch)
treee6441b9d0f9f2a9512c210caf90de20b55485b9f /tools
parentd9169d3cbe3716ad1ae20947222fa2bf3b3fae6b (diff)
downloadllvm-74e032a4d4673f53388571ab9ecd783584e3fccf.tar.gz
llvm-74e032a4d4673f53388571ab9ecd783584e3fccf.tar.bz2
llvm-74e032a4d4673f53388571ab9ecd783584e3fccf.tar.xz
Fix two bugs in the CppWriter.cpp:
1. Return the module from the MakeModule function so it can be verified. 2. Make sure types get generated with their names git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm2cpp/CppWriter.cpp8
-rw-r--r--tools/llvm2cpp/Makefile13
2 files changed, 17 insertions, 4 deletions
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp
index 54a28e9f83..0f28e30e16 100644
--- a/tools/llvm2cpp/CppWriter.cpp
+++ b/tools/llvm2cpp/CppWriter.cpp
@@ -1120,6 +1120,13 @@ CppWriter::printTypeDefInternal(const Type* Ty) {
assert(!"Invalid TypeID");
}
+ // If the type had a name, make sure we recreate it.
+ const std::string* progTypeName =
+ findTypeName(TheModule->getSymbolTable(),Ty);
+ if (progTypeName)
+ Out << "mod->addTypeName(\"" << *progTypeName << "\", "
+ << typeName << ");\n";
+
// Pop us off the type stack
TypeStack.pop_back();
@@ -1989,6 +1996,7 @@ void WriteModuleToCppFile(Module* mod, std::ostream& o) {
SlotMachine SlotTable(mod);
CppWriter W(o, SlotTable, mod);
W.write(mod);
+ o << "return mod;\n";
o << "}\n";
}
diff --git a/tools/llvm2cpp/Makefile b/tools/llvm2cpp/Makefile
index 44a5b6fc41..e1511db8bd 100644
--- a/tools/llvm2cpp/Makefile
+++ b/tools/llvm2cpp/Makefile
@@ -13,11 +13,16 @@ USEDLIBS = LLVMAsmParser LLVMBCWriter LLVMCore \
include $(LEVEL)/Makefile.common
-tryit: all-local recurty.cpp globalvars.cpp
+CPPFILESTOTRY = recurty.cpp globalvars.cpp
+tryit: all-local $(CPPFILESTOTRY)
-%.cpp : %.ll
+%.cpp : %.ll $(ToolDir)/llvm2cpp
llvm2cpp $*.ll -f -o $*.cpp
- gcc -I$(LLVM_SRC_ROOT)/include -I$(LLVM_OBJ_ROOT)/include -g \
+
+% : %.cpp Makefile
+ gcc -Wall -I$(LLVM_SRC_ROOT)/include -I$(LLVM_OBJ_ROOT)/include -g \
-D__STDC_LIMIT_MACROS -L$(LibDir) $(LibDir)/LLVMCore.o -lLLVMSupport \
- $(LibDir)/LLVMbzip2.o -lLLVMSystem -lstdc++ \
+ $(LibDir)/LLVMbzip2.o -lLLVMSystem -lstdc++ -Wno-unused \
$*.cpp -o $*
+
+#$(CPPFILESTOTRY): $(ToolDir)/llvm2cpp