X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FDebugInfo.cpp;h=add4b87a8b12b3eb2bcf6dd326147e17d9233949;hb=eb3d76da81e2148ed7c577594c873ba147f4f435;hp=749e0b5057a76e05414bdfe28d9ad31108813719;hpb=6f8c0c061331324faef1fdb6e39724045fc7a140;p=oota-llvm.git diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 749e0b5057a..add4b87a8b1 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo.h" +#include "LLVMContextImpl.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" @@ -23,9 +24,9 @@ #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/Module.h" +#include "llvm/IR/ValueHandle.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" -#include "llvm/Support/ValueHandle.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; using namespace llvm::dwarf; @@ -818,6 +819,29 @@ DIArray DICompileUnit::getImportedEntities() const { return DIArray(getNodeField(DbgNode, 11)); } +/// copyWithNewScope - Return a copy of this location, replacing the +/// current scope with the given one. +DILocation DILocation::copyWithNewScope(LLVMContext &Ctx, + DILexicalBlock NewScope) { + SmallVector Elts; + assert(Verify()); + for (unsigned I = 0; I < DbgNode->getNumOperands(); ++I) { + if (I != 2) + Elts.push_back(DbgNode->getOperand(I)); + else + Elts.push_back(NewScope); + } + MDNode *NewDIL = MDNode::get(Ctx, Elts); + return DILocation(NewDIL); +} + +/// computeNewDiscriminator - Generate a new discriminator value for this +/// file and line location. +unsigned DILocation::computeNewDiscriminator(LLVMContext &Ctx) { + std::pair Key(getFilename().data(), getLineNumber()); + return ++Ctx.pImpl->DiscriminatorTable[Key]; +} + /// fixupSubprogramName - Replace contains special characters used /// in a typical Objective-C names with '.' in a given string. static void fixupSubprogramName(DISubprogram Fn, SmallVectorImpl &Out) {