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


C++ AnalysisDeclContext::getBody方法代码示例

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


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

示例1: getValidSourceLocation

static SourceLocation getValidSourceLocation(const Stmt* S,
                                             LocationOrAnalysisDeclContext LAC,
                                             bool UseEnd = false) {
  SourceLocation L = UseEnd ? S->getLocEnd() : S->getLocStart();
  assert(!LAC.isNull() && "A valid LocationContext or AnalysisDeclContext should "
                          "be passed to PathDiagnosticLocation upon creation.");

  // S might be a temporary statement that does not have a location in the
  // source code, so find an enclosing statement and use its location.
  if (!L.isValid()) {

    AnalysisDeclContext *ADC;
    if (LAC.is<const LocationContext*>())
      ADC = LAC.get<const LocationContext*>()->getAnalysisDeclContext();
    else
      ADC = LAC.get<AnalysisDeclContext*>();

    ParentMap &PM = ADC->getParentMap();

    const Stmt *Parent = S;
    do {
      Parent = PM.getParent(Parent);

      // In rare cases, we have implicit top-level expressions,
      // such as arguments for implicit member initializers.
      // In this case, fall back to the start of the body (even if we were
      // asked for the statement end location).
      if (!Parent) {
        const Stmt *Body = ADC->getBody();
        if (Body)
          L = Body->getLocStart();
        else
          L = ADC->getDecl()->getLocEnd();
        break;
      }

      L = UseEnd ? Parent->getLocEnd() : Parent->getLocStart();
    } while (!L.isValid());
  }

  return L;
}
开发者ID:TravisWee,项目名称:clang,代码行数:42,代码来源:PathDiagnostic.cpp

示例2: getRuntimeDefinition

RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const {
  const FunctionDecl *FD = getDecl();
  // Note that the AnalysisDeclContext will have the FunctionDecl with
  // the definition (if one exists).
  if (FD) {
    AnalysisDeclContext *AD =
      getLocationContext()->getAnalysisDeclContext()->
      getManager()->getContext(FD);
    bool IsAutosynthesized;
    Stmt* Body = AD->getBody(IsAutosynthesized);
    DEBUG({
        if (IsAutosynthesized)
          llvm::dbgs() << "Using autosynthesized body for " << FD->getName()
                       << "\n";
    });
    if (Body) {
      const Decl* Decl = AD->getDecl();
      return RuntimeDefinition(Decl);
    }
  }
开发者ID:filcab,项目名称:clang,代码行数:20,代码来源:CallEvent.cpp


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