#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"
using namespace llvm;
using namespace object;
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) {
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;
}
ErrorOr<SymbolicFile *> llvm::object::SymbolicFile::createIRObjectFile(
MemoryBuffer *Object, LLVMContext &Context, bool BufferOwned) {
error_code EC;
- OwningPtr<IRObjectFile> Ret(
+ std::unique_ptr<IRObjectFile> Ret(
new IRObjectFile(Object, EC, Context, BufferOwned));
if (EC)
return EC;
- return Ret.take();
+ return Ret.release();
}