本文整理汇总了C++中ASTPrinter::printNewline方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTPrinter::printNewline方法的具体用法?C++ ASTPrinter::printNewline怎么用?C++ ASTPrinter::printNewline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTPrinter
的用法示例。
在下文中一共展示了ASTPrinter::printNewline方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print
void DeclAttribute::print(ASTPrinter &Printer, const PrintOptions &Options,
const Decl *D) const {
if (!printImpl(Printer, Options, D))
return; // Nothing printed.
if (isLongAttribute() && Options.PrintLongAttrsOnSeparateLines)
Printer.printNewline();
else
Printer << " ";
}
示例2: printShortFormAvailable
/// Print the short-form @available() attribute for an array of long-form
/// AvailableAttrs that can be represented in the short form.
/// For example, for:
/// @available(OSX, introduced=10.10)
/// @available(iOS, introduced=8.0)
/// this will print:
/// @available(OSX 10.10, iOS 8.0, *)
static void printShortFormAvailable(ArrayRef<const DeclAttribute *> Attrs,
ASTPrinter &Printer,
const PrintOptions &Options) {
assert(!Attrs.empty());
Printer << "@available(";
for (auto *DA : Attrs) {
auto *AvailAttr = cast<AvailableAttr>(DA);
assert(AvailAttr->Introduced.hasValue());
Printer << platformString(AvailAttr->Platform) << " "
<< AvailAttr->Introduced.getValue().getAsString() << ", ";
}
Printer << "*)";
Printer.printNewline();
}
示例3: printShortFormAvailable
/// Print the short-form @available() attribute for an array of long-form
/// AvailableAttrs that can be represented in the short form.
/// For example, for:
/// @available(OSX, introduced: 10.10)
/// @available(iOS, introduced: 8.0)
/// this will print:
/// @available(OSX 10.10, iOS 8.0, *)
static void printShortFormAvailable(ArrayRef<const DeclAttribute *> Attrs,
ASTPrinter &Printer,
const PrintOptions &Options) {
assert(!Attrs.empty());
Printer << "@available(";
auto FirstAvail = cast<AvailableAttr>(Attrs.front());
if (Attrs.size() == 1 &&
FirstAvail->isLanguageVersionSpecific()) {
assert(FirstAvail->Introduced.hasValue());
Printer << "swift "
<< FirstAvail->Introduced.getValue().getAsString()
<< ")";
} else {
for (auto *DA : Attrs) {
auto *AvailAttr = cast<AvailableAttr>(DA);
assert(AvailAttr->Introduced.hasValue());
Printer << platformString(AvailAttr->Platform) << " "
<< AvailAttr->Introduced.getValue().getAsString() << ", ";
}
Printer << "*)";
}
Printer.printNewline();
}
示例4: print
//.........这里部分代码省略.........
case DAK_Available: {
Printer << "@available(";
auto Attr = cast<AvailableAttr>(this);
Printer << Attr->platformString();
if (Attr->isUnconditionallyUnavailable())
Printer << ", unavailable";
else if (Attr->isUnconditionallyDeprecated())
Printer << ", deprecated";
if (Attr->Introduced)
Printer << ", introduced=" << Attr->Introduced.getValue().getAsString();
if (Attr->Deprecated)
Printer << ", deprecated=" << Attr->Deprecated.getValue().getAsString();
if (Attr->Obsoleted)
Printer << ", obsoleted=" << Attr->Obsoleted.getValue().getAsString();
// If there's no message, but this is specifically an imported
// "unavailable in Swift" attribute, synthesize a message to look good in
// the generated interface.
if (!Attr->Message.empty())
Printer << ", message=\"" << Attr->Message << "\"";
else if (Attr->getUnconditionalAvailability()
== UnconditionalAvailabilityKind::UnavailableInSwift)
Printer << ", message=\"Not available in Swift\"";
Printer << ")";
break;
}
case DAK_AutoClosure:
Printer << "@autoclosure";
if (cast<AutoClosureAttr>(this)->isEscaping())
Printer << "(escaping)";
break;
case DAK_ObjC: {
if (Options.PrintForSIL && isImplicit())
break;
Printer << "@objc";
llvm::SmallString<32> scratch;
if (auto Name = cast<ObjCAttr>(this)->getName()) {
if (!cast<ObjCAttr>(this)->isNameImplicit())
Printer << "(" << Name->getString(scratch) << ")";
}
break;
}
case DAK_SetterAccessibility:
Printer << getAttrName() << "(set)";
break;
case DAK_SwiftNativeObjCRuntimeBase: {
auto *attr = cast<SwiftNativeObjCRuntimeBaseAttr>(this);
Printer << "@_swift_native_objc_runtime_base("
<< attr->BaseClassName.str() << ")";
break;
}
case DAK_RawDocComment:
// Not printed.
return;
case DAK_ObjCBridged:
// Not printed.
return;
case DAK_SynthesizedProtocol:
// Not printed.
return;
case DAK_WarnUnusedResult: {
Printer << "@warn_unused_result";
auto *attr = cast<WarnUnusedResultAttr>(this);
bool printedParens = false;
if (!attr->getMessage().empty()) {
Printer << "(message=\"" << attr->getMessage() << "\"";
printedParens = true;
}
if (!attr->getMutableVariant().empty()) {
if (printedParens)
Printer << ", ";
else
Printer << "(";
Printer << "mutable_variant=\"" << attr->getMutableVariant() << "\"";
printedParens = true;
}
if (printedParens)
Printer << ")";
break;
}
case DAK_Count:
llvm_unreachable("exceed declaration attribute kinds");
}
if (isLongAttribute() && Options.PrintLongAttrsOnSeparateLines)
Printer.printNewline();
else
Printer << " ";
}