本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}