From a51f0f8367acb79177abfb93e5b3533b490448cf Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 28 Feb 2014 02:17:23 +0000 Subject: Now that it is possible, use the mangler in IRObjectFile. A really simple patch marks the end of a lot of yak shaving :-) llvm-svn: 202463 --- llvm/lib/Object/IRObjectFile.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Object/IRObjectFile.cpp') diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp index 37e7eb8..b3a5668fc 100644 --- a/llvm/lib/Object/IRObjectFile.cpp +++ b/llvm/lib/Object/IRObjectFile.cpp @@ -13,6 +13,7 @@ #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Mangler.h" #include "llvm/IR/Module.h" #include "llvm/Object/IRObjectFile.h" #include "llvm/Support/raw_ostream.h" @@ -27,6 +28,13 @@ IRObjectFile::IRObjectFile(MemoryBuffer *Object, error_code &EC, return; M.reset(MOrErr.get()); + + // If we have a DataLayout, setup a mangler. + const DataLayout *DL = M->getDataLayout(); + if (!DL) + return; + + Mang.reset(new Mangler(DL)); } static const GlobalValue &getGV(DataRefImpl &Symb) { @@ -86,9 +94,13 @@ void IRObjectFile::moveSymbolNext(DataRefImpl &Symb) const { error_code IRObjectFile::printSymbolName(raw_ostream &OS, DataRefImpl Symb) const { - // FIXME: This should use the Mangler. const GlobalValue &GV = getGV(Symb); - OS << GV.getName(); + + if (Mang) + Mang->getNameWithPrefix(OS, &GV, false); + else + OS << GV.getName(); + return object_error::success; } -- cgit v1.1