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


C++ ASTUnit::getLocation方法代码示例

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


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

示例1: lfort_getLocation

CXSourceLocation lfort_getLocation(CXProgram tu,
                                   CXFile file,
                                   unsigned line,
                                   unsigned column) {
  if (!tu || !file)
    return lfort_getNullLocation();
  
  bool Logging = ::getenv("LIBLFORT_LOGGING");
  ASTUnit *CXXUnit = static_cast<ASTUnit *>(tu->PgmData);
  ASTUnit::ConcurrencyCheck Check(*CXXUnit);
  const FileEntry *File = static_cast<const FileEntry *>(file);
  SourceLocation SLoc = CXXUnit->getLocation(File, line, column);
  if (SLoc.isInvalid()) {
    if (Logging)
      llvm::errs() << "lfort_getLocation(\"" << File->getName() 
      << "\", " << line << ", " << column << ") = invalid\n";
    return lfort_getNullLocation();
  }
  
  if (Logging)
    llvm::errs() << "lfort_getLocation(\"" << File->getName() 
    << "\", " << line << ", " << column << ") = " 
    << SLoc.getRawEncoding() << "\n";
  
  return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
}
开发者ID:gwelymernans,项目名称:lfort,代码行数:26,代码来源:CXSourceLocation.cpp

示例2: clang_getLocation

CXSourceLocation clang_getLocation(CXTranslationUnit TU,
                                   CXFile file,
                                   unsigned line,
                                   unsigned column) {
  if (cxtu::isNotUsableTU(TU)) {
    LOG_BAD_TU(TU);
    return clang_getNullLocation();
  }
  if (!file)
    return clang_getNullLocation();
  if (line == 0 || column == 0)
    return clang_getNullLocation();
  
  LogRef Log = Logger::make(__func__);
  ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
  ASTUnit::ConcurrencyCheck Check(*CXXUnit);
  const FileEntry *File = static_cast<const FileEntry *>(file);
  SourceLocation SLoc = CXXUnit->getLocation(File, line, column);
  if (SLoc.isInvalid()) {
    if (Log)
      *Log << llvm::format("(\"%s\", %d, %d) = invalid",
                           File->getName().str().c_str(), line, column);
    return clang_getNullLocation();
  }
  
  CXSourceLocation CXLoc =
      cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
  if (Log)
    *Log << llvm::format("(\"%s\", %d, %d) = ", File->getName().str().c_str(),
                         line, column)
         << CXLoc;

  return CXLoc;
}
开发者ID:JaredCJR,项目名称:clang,代码行数:34,代码来源:CXSourceLocation.cpp

示例3: lfort_getLocationForOffset

CXSourceLocation lfort_getLocationForOffset(CXProgram tu,
                                            CXFile file,
                                            unsigned offset) {
  if (!tu || !file)
    return lfort_getNullLocation();
  
  ASTUnit *CXXUnit = static_cast<ASTUnit *>(tu->PgmData);

  SourceLocation SLoc 
    = CXXUnit->getLocation(static_cast<const FileEntry *>(file), offset);

  if (SLoc.isInvalid())
    return lfort_getNullLocation();
  
  return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
}
开发者ID:gwelymernans,项目名称:lfort,代码行数:16,代码来源:CXSourceLocation.cpp

示例4: clang_getLocationForOffset

CXSourceLocation clang_getLocationForOffset(CXTranslationUnit TU,
                                            CXFile file,
                                            unsigned offset) {
  if (cxtu::isNotUsableTU(TU)) {
    LOG_BAD_TU(TU);
    return clang_getNullLocation();
  }
  if (!file)
    return clang_getNullLocation();

  ASTUnit *CXXUnit = cxtu::getASTUnit(TU);

  SourceLocation SLoc 
    = CXXUnit->getLocation(static_cast<const FileEntry *>(file), offset);

  if (SLoc.isInvalid())
    return clang_getNullLocation();
  
  return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
}
开发者ID:JaredCJR,项目名称:clang,代码行数:20,代码来源:CXSourceLocation.cpp


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