diff options
Diffstat (limited to 'lib/IR/DebugInfo.cpp')
-rw-r--r-- | lib/IR/DebugInfo.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 749e0b5057..f5884a4a90 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Intrinsics.h" +#include "LLVMContextImpl.h" #include "llvm/IR/Module.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" @@ -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<Value *, 10> 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<const char *, unsigned> 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<char> &Out) { |