Getting corresponding c-instruction line number along with ir-instruction in a function's CFG


I am not a good programmer but for my project i have to use llvm to generate CFG for c programs where i have a mapping from IR instruction in CFG to their respective c instruction. After surfing a in source of llvm i did the following change in printInstruction() function in llvm/lib/VMCore/AsmWriter.cpp file.

void AssemblyWriter::printInstruction(const Instruction &I) {
if (AnnotationWriter) AnnotationWriter->emitInstructionAnnot(&I, Out);

// Print out indentation for an instruction.
Out << " ";
if (MDNode *N = I.getMetadata(“dbg”)) { // Code
DILocation Loc(N); // inserted
unsigned Line = Loc.getLineNumber(); // by
Out<<“LN@”<<Line; // me
StringRef File = Loc.getFilename(); // to
Out<<“FN@”<<File; // get
StringRef Dir = Loc.getDirectory(); // the
Out<<“DN@”<<Dir; // mapping
} //

// Print out name if it exists…

Code compiles well but i get following linking problem :frowning:
llvm[2]: Linking Debug+Asserts executable llvm-as
/home/rangi/llvm/build/Debug+Asserts/lib/libLLVMCore.a(AsmWriter.o): In function llvm::DIDescriptor::getUnsignedField(unsigned int) const': /home/rangi/llvm/include/llvm/Analysis/DebugInfo.h:70: undefined reference to llvm::DIDescriptor::getUInt64Field(unsigned int) const’
/home/rangi/llvm/build/Debug+Asserts/lib/libLLVMCore.a(AsmWriter.o): In function DIScope': /home/rangi/llvm/include/llvm/Analysis/DebugInfo.h:160: undefined reference to vtable for llvm::DIScope’
/home/rangi/llvm/build/Debug+Asserts/lib/libLLVMCore.a(AsmWriter.o): In function ~DIScope': /home/rangi/llvm/include/llvm/Analysis/DebugInfo.h:161: undefined reference to vtable for llvm::DIScope’
/home/rangi/llvm/build/Debug+Asserts/lib/libLLVMCore.a(AsmWriter.o): In function llvm::DILocation::getFilename() const': /home/rangi/llvm/include/llvm/Analysis/DebugInfo.h:785: undefined reference to llvm::DIScope::getFilename() const’
/home/rangi/llvm/build/Debug+Asserts/lib/libLLVMCore.a(AsmWriter.o): In function llvm::DILocation::getDirectory() const': /home/rangi/llvm/include/llvm/Analysis/DebugInfo.h:786: undefined reference to llvm::DIScope::getDirectory() const’
/home/rangi/llvm/build/Debug+Asserts/lib/libLLVMCore.a(AsmWriter.o): In function llvm::DIScope llvm::DIDescriptor::getFieldAs<llvm::DIScope>(unsigned int) const': /home/rangi/llvm/include/llvm/Analysis/DebugInfo.h:77: undefined reference to llvm::DIDescriptor::getDescriptorField(unsigned int) const’

Plese tell me if what is missing and if this the right way to achive mapping.
Thanks in advance