当前位置: 首页>>代码示例>>C++>>正文


C++ DIScope类代码示例

本文整理汇总了C++中DIScope的典型用法代码示例。如果您正苦于以下问题:C++ DIScope类的具体用法?C++ DIScope怎么用?C++ DIScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DIScope类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: processLexicalBlock

/// processLexicalBlock
void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) {
  DIScope Context = LB.getContext();
  if (Context.isLexicalBlock())
    return processLexicalBlock(DILexicalBlock(Context));
  else
    return processSubprogram(DISubprogram(Context));
}
开发者ID:emorins,项目名称:llvm-mirror,代码行数:8,代码来源:DebugInfo.cpp

示例2: emitInstructionAnnot

void LineNumberAnnotatedWriter::emitInstructionAnnot(
      const Instruction *I, formatted_raw_ostream &Out)
{
    DILocation *NewInstrLoc = I->getDebugLoc();
    if (!NewInstrLoc) {
        auto Loc = DebugLoc.find(I);
        if (Loc != DebugLoc.end())
            NewInstrLoc = Loc->second;
    }
    if (!NewInstrLoc || NewInstrLoc == InstrLoc)
        return;
    InstrLoc = NewInstrLoc;
    std::vector<DILineInfo> DIvec;
    do {
        DIvec.emplace_back();
        DILineInfo &DI = DIvec.back();
        DIScope *scope = NewInstrLoc->getScope();
        if (scope)
            DI.FunctionName = scope->getName();
        DI.FileName = NewInstrLoc->getFilename();
        DI.Line = NewInstrLoc->getLine();
        NewInstrLoc = NewInstrLoc->getInlinedAt();
    } while (NewInstrLoc);
    LinePrinter.emit_lineinfo(Out, DIvec);
}
开发者ID:GunnarFarneback,项目名称:julia,代码行数:25,代码来源:disasm.cpp

示例3: assert

/// EmitDeclare - Constructs the debug code for allocation of a new variable.
/// region - "llvm.dbg.declare."
void DebugInfo::EmitDeclare(tree decl, unsigned Tag, const char *Name,
                            tree type, Value *AI, LLVMBuilder &Builder) {

  // Ignore compiler generated temporaries.
  if (DECL_IGNORED_P(decl))
    return;

  assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");

  expanded_location Loc = GetNodeLocation(decl, false);

  // Construct variable.
  DIScope VarScope = DIScope(cast<MDNode>(RegionStack.back()));
  DIType Ty = getOrCreateType(type);
  if (DECL_ARTIFICIAL (decl))
      Ty = DebugFactory.CreateArtificialType(Ty);
  // If type info is not available then do not emit debug info for this var.
  if (!Ty.getNode())
    return;
  llvm::DIVariable D =
    DebugFactory.CreateVariable(Tag, VarScope,
                                Name, getOrCreateFile(Loc.file),
                                Loc.line, Ty, optimize);

  // Insert an llvm.dbg.declare into the current block.
  Instruction *Call = DebugFactory.InsertDeclare(AI, D, 
                                                 Builder.GetInsertBlock());
  
  Call->setDebugLoc(DebugLoc::get(Loc.line, 0, VarScope.getNode()));
}
开发者ID:nickl-,项目名称:xchain-ios,代码行数:32,代码来源:llvm-debug.cpp

示例4: printLocation

// Print source location of function, and display name,
// falls back to printing the module's location and the function's LLVM name.
static void printLocation(const llvm::Function *F) {
  unsigned MDDebugKind = F->getParent()->getMDKindID("dbg");
  if (MDDebugKind) {
    // Try to find the function's name and location
    for (Function::const_iterator I=F->begin(),E=F->end();
         I != E; ++I) {
      if (const TerminatorInst *T = I->getTerminator()) {
        if (MDNode *N = T->getMetadata(MDDebugKind)) {
          DILocation Loc(N);
          DIScope Scope = Loc.getScope();
          while (Scope.isLexicalBlock()) {
            DILexicalBlock LB(Scope.getNode());
            Scope = LB.getContext();
          }
          if (Scope.isSubprogram()) {
            DISubprogram SP(Scope.getNode());
            errs() << /*Loc.getDirectory() << "/" << */Loc.getFilename()
              << ": in function '"
              << SP.getDisplayName()
              << "': ";
            return;
          }
        }
      }
    }
  }
  // Fallback to printing module location and function name
  printLocation(F->getParent());
  errs() << "in function '" << F->getName() << "': ";
}
开发者ID:Udit-Sharma,项目名称:clamav-bytecode-compiler,代码行数:32,代码来源:ClamBCDiagnostics.cpp

示例5: assert

StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) {
  assert(S);
  assert((isa<MDCompileUnit>(S) || isa<MDFile>(S) || isa<MDSubprogram>(S) ||
          isa<MDLexicalBlockBase>(S)) &&
         "Unexpected scope info");

  DIScope Scope = cast<MDScope>(S);
  StringRef Dir = Scope.getDirectory(),
            Filename = Scope.getFilename();
  char *&Result = DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)];
  if (Result)
    return Result;

  // Clang emits directory and relative filename info into the IR, but CodeView
  // operates on full paths.  We could change Clang to emit full paths too, but
  // that would increase the IR size and probably not needed for other users.
  // For now, just concatenate and canonicalize the path here.
  std::string Filepath;
  if (Filename.find(':') == 1)
    Filepath = Filename;
  else
    Filepath = (Dir + "\\" + Filename).str();

  // Canonicalize the path.  We have to do it textually because we may no longer
  // have access the file in the filesystem.
  // First, replace all slashes with backslashes.
  std::replace(Filepath.begin(), Filepath.end(), '/', '\\');

  // Remove all "\.\" with "\".
  size_t Cursor = 0;
  while ((Cursor = Filepath.find("\\.\\", Cursor)) != std::string::npos)
    Filepath.erase(Cursor, 2);

  // Replace all "\XXX\..\" with "\".  Don't try too hard though as the original
  // path should be well-formatted, e.g. start with a drive letter, etc.
  Cursor = 0;
  while ((Cursor = Filepath.find("\\..\\", Cursor)) != std::string::npos) {
    // Something's wrong if the path starts with "\..\", abort.
    if (Cursor == 0)
      break;

    size_t PrevSlash = Filepath.rfind('\\', Cursor - 1);
    if (PrevSlash == std::string::npos)
      // Something's wrong, abort.
      break;

    Filepath.erase(PrevSlash, Cursor + 3 - PrevSlash);
    // The next ".." might be following the one we've just erased.
    Cursor = PrevSlash;
  }

  // Remove all duplicate backslashes.
  Cursor = 0;
  while ((Cursor = Filepath.find("\\\\", Cursor)) != std::string::npos)
    Filepath.erase(Cursor, 1);

  Result = strdup(Filepath.c_str());
  return StringRef(Result);
}
开发者ID:FulcronZ,项目名称:NyuziToolchain,代码行数:59,代码来源:WinCodeViewLineTables.cpp

示例6: LLVMGetDebugLoc

//changed scope was *
LLVMValueRef LLVMGetDebugLoc(unsigned Line, unsigned Col, LLVMValueRef Scope)
{
//  MDNode *S = unwrapDI<DIDescriptor>(*Scope);
//  DebugLoc loc = DebugLoc::get(Line,Col,S);

  DIScope S = unwrapDI<DIScope>(Scope);
  DebugLoc loc = DebugLoc::get(Line,Col,S);
  LLVMContext &ctx = S->getContext();
  MDNode *L = loc.getAsMDNode(ctx);
  return wrap(L);
}
开发者ID:RodneyBates,项目名称:M3Devel,代码行数:12,代码来源:DIBuilderBindings.cpp

示例7: printDebugLoc

static void printDebugLoc(DebugLoc DL, raw_ostream &CommentOS,
                          const LLVMContext &Ctx) {
  if (!DL)
    return;

  DIScope Scope = cast<MDScope>(DL.getScope());
  // Omit the directory, because it's likely to be long and uninteresting.
  CommentOS << Scope.getFilename();
  CommentOS << ':' << DL.getLine();
  if (DL.getCol() != 0)
    CommentOS << ':' << DL.getCol();

  DebugLoc InlinedAtDL = DL.getInlinedAt();
  if (!InlinedAtDL)
    return;

  CommentOS << " @[ ";
  printDebugLoc(InlinedAtDL, CommentOS, Ctx);
  CommentOS << " ]";
}
开发者ID:kunhuahuang,项目名称:llvm,代码行数:20,代码来源:DebugInfo.cpp

示例8: get

const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
                                                const DILocation *LocB) {
  if (!LocA || !LocB)
    return nullptr;

  if (LocA == LocB)
    return LocA;

  SmallPtrSet<DILocation *, 5> InlinedLocationsA;
  for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())
    InlinedLocationsA.insert(L);
  SmallSet<std::pair<DIScope *, DILocation *>, 5> Locations;
  DIScope *S = LocA->getScope();
  DILocation *L = LocA->getInlinedAt();
  while (S) {
    Locations.insert(std::make_pair(S, L));
    S = S->getScope().resolve();
    if (!S && L) {
      S = L->getScope();
      L = L->getInlinedAt();
    }
  }
  const DILocation *Result = LocB;
  S = LocB->getScope();
  L = LocB->getInlinedAt();
  while (S) {
    if (Locations.count(std::make_pair(S, L)))
      break;
    S = S->getScope().resolve();
    if (!S && L) {
      S = L->getScope();
      L = L->getInlinedAt();
    }
  }

  // If the two locations are irreconsilable, just pick one. This is misleading,
  // but on the other hand, it's a "line 0" location.
  if (!S || !isa<DILocalScope>(S))
    S = LocA->getScope();
  return DILocation::get(Result->getContext(), 0, 0, S, L);
}
开发者ID:happz,项目名称:llvm,代码行数:41,代码来源:DebugInfoMetadata.cpp

示例9: addScope

bool DebugInfoFinder::addScope(DIScope Scope) {
  if (!Scope)
    return false;
  // FIXME: Ocaml binding generates a scope with no content, we treat it
  // as null for now.
  if (Scope->getNumOperands() == 0)
    return false;
  if (!NodesSeen.insert(Scope).second)
    return false;
  Scopes.push_back(Scope);
  return true;
}
开发者ID:cschreiner,项目名称:llvm,代码行数:12,代码来源:DebugInfo.cpp

示例10: processScope

void DebugInfoFinder::processScope(DIScope Scope) {
  if (Scope.isType()) {
    DIType Ty(Scope);
    processType(Ty);
    return;
  }
  if (Scope.isCompileUnit()) {
    addCompileUnit(DICompileUnit(Scope));
    return;
  }
  if (Scope.isSubprogram()) {
    processSubprogram(DISubprogram(Scope));
    return;
  }
  if (!addScope(Scope))
    return;
  if (Scope.isLexicalBlock()) {
    DILexicalBlock LB(Scope);
    processScope(LB.getContext());
  } else if (Scope.isLexicalBlockFile()) {
    DILexicalBlockFile LBF = DILexicalBlockFile(Scope);
    processScope(LBF.getScope());
  } else if (Scope.isNameSpace()) {
    DINameSpace NS(Scope);
    processScope(NS.getContext());
  }
}
开发者ID:cschreiner,项目名称:llvm,代码行数:27,代码来源:DebugInfo.cpp

示例11: ShowContext

void DIEItem::ShowContext(DetailsView* detailsView, DIScope scope) {
  // TODO: Fill out these cases.
  if (scope.isCompileUnit()) {
    DICompileUnit diCompileUnit(scope);
    detailsView->Add(_("ContextType"), _("DICompileUnit"));
    detailsView->Add(_("Context"),
        toWxStr(diCompileUnit.getDirectory()) + _("/") +
        toWxStr(diCompileUnit.getFilename()));
  } else if (scope.isFile()) {
    DIFile diFile(scope);
    detailsView->Add(_("ContextType"), _("DIFile"));
    detailsView->Add(_("Context"),
        toWxStr(diFile.getDirectory()) + _("/") +
        toWxStr(diFile.getFilename()));
  } else if (scope.isNameSpace()) {
    DINameSpace diNameSpace(scope);
    detailsView->Add(_("ContextType"), _("DINameSpace"));
    detailsView->Add(_("Context"), diNameSpace.getName());
  } else if (scope.isSubprogram()) {
    DISubprogram diSubprogram(scope);
    detailsView->Add(_("ContextType"), _("DISubprogram"));
    detailsView->Add(_("Context"), diSubprogram.getName());
  } else if (scope.isLexicalBlock()) {
    detailsView->Add(_("ContextType"), _("DILexicalBlock"));
    // TODO: Implement context name.
    detailsView->Add(_("Context"), _("?{}"));
  } else if (scope.isType()) {
    detailsView->Add(_("ContextType"), _("DIType"));
    detailsView->Add(_("Context"), DITypeToString(DIType(scope)));
  } else {
    detailsView->Add(_("Context"), _("??? [Unknown]"));
  }
}
开发者ID:lht,项目名称:llbrowse,代码行数:33,代码来源:TreeView.cpp

示例12:

const char *LLVMGetDirectory(LLVMValueRef Scope)
{
  DIScope S = unwrapDI<DIScope>(Scope);
  StringRef str = S.getDirectory();
  return str.data();
}
开发者ID:RodneyBates,项目名称:M3Devel,代码行数:6,代码来源:DIBuilderBindings.cpp


注:本文中的DIScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。