本文整理汇总了C++中SourceLoc::print方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceLoc::print方法的具体用法?C++ SourceLoc::print怎么用?C++ SourceLoc::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceLoc
的用法示例。
在下文中一共展示了SourceLoc::print方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dump
void AccessScope::dump() const {
llvm::errs() << getAccessLevelSpelling(accessLevelForDiagnostics()) << ": ";
if (isPublic()) {
llvm::errs() << "(null)\n";
return;
}
if (auto *file = dyn_cast<SourceFile>(getDeclContext())) {
llvm::errs() << "file '" << file->getFilename() << "'\n";
return;
}
if (auto *decl = getDeclContext()->getAsDecl()) {
llvm::errs() << Decl::getKindName(decl->getKind()) << " ";
if (auto *ext = dyn_cast<ExtensionDecl>(decl))
llvm::errs() << ext->getExtendedNominal()->getName();
else if (auto *named = dyn_cast<ValueDecl>(decl))
llvm::errs() << named->getFullName();
else
llvm::errs() << (const void *)decl;
SourceLoc loc = decl->getLoc();
if (loc.isValid()) {
llvm::errs() << " at ";
loc.print(llvm::errs(), decl->getASTContext().SourceMgr);
}
llvm::errs() << "\n";
return;
}
// If all else fails, dump the DeclContext tree.
getDeclContext()->printContext(llvm::errs());
}
示例2: printDeclDescription
void swift::printDeclDescription(llvm::raw_ostream &out, const Decl *D,
ASTContext &Context) {
SourceLoc loc = D->getStartLoc();
bool hasPrintedName = false;
if (auto *named = dyn_cast<ValueDecl>(D)) {
if (named->hasName()) {
out << '\'' << named->getFullName() << '\'';
hasPrintedName = true;
} else if (auto *accessor = dyn_cast<AccessorDecl>(named)) {
auto ASD = accessor->getStorage();
if (ASD->hasName()) {
switch (accessor->getAccessorKind()) {
case AccessorKind::Get:
out << "getter";
break;
case AccessorKind::Set:
out << "setter";
break;
case AccessorKind::WillSet:
out << "willset";
break;
case AccessorKind::DidSet:
out << "didset";
break;
case AccessorKind::MaterializeForSet:
out << "materializeForSet";
break;
case AccessorKind::Address:
out << "addressor";
break;
case AccessorKind::MutableAddress:
out << "mutableAddressor";
break;
}
out << " for " << ASD->getFullName();
hasPrintedName = true;
loc = ASD->getStartLoc();
}
}
} else if (auto *extension = dyn_cast<ExtensionDecl>(D)) {
Type extendedTy = extension->getExtendedType();
if (extendedTy) {
out << "extension of " << extendedTy;
hasPrintedName = true;
}
}
if (!hasPrintedName)
out << "declaration " << (const void *)D;
if (loc.isValid()) {
out << " at ";
loc.print(out, Context.SourceMgr);
} else {
out << " in module '" << D->getModuleContext()->getName() << '\'';
}
out << '\n';
}
示例3: printSourceLocDescription
void swift::printSourceLocDescription(llvm::raw_ostream &out,
SourceLoc loc, ASTContext &ctx) {
loc.print(out, ctx.SourceMgr);
out << '\n';
}