static void printGroup(llvm::raw_ostream &out, const GroupRecord &Group, bool FlagsOnly, unsigned Indent = 0) { out.indent(Indent * 2); bool ShowColors = showColors(out); setColor(ShowColors, out, llvm::raw_ostream::YELLOW); out << "-W" << Group.getName() << "\n"; resetColor(ShowColors, out); ++Indent; for (GroupRecord::subgroup_iterator I = Group.subgroup_begin(), E = Group.subgroup_end(); I != E; ++I) { printGroup(out, *I, FlagsOnly, Indent); } if (!FlagsOnly) { for (GroupRecord::diagnostics_iterator I = Group.diagnostics_begin(), E = Group.diagnostics_end(); I != E; ++I) { if (ShowColors) { if (getLevel(I->DiagID) != DiagnosticsEngine::Ignored) { setColor(ShowColors, out, llvm::raw_ostream::GREEN); } } out.indent(Indent * 2); out << I->getName(); resetColor(ShowColors, out); out << "\n"; } } }
void writeSymbol(const Symbol &Sym, const StringTableOut &Strings, llvm::raw_ostream &OS) { OS << Sym.ID.raw(); // TODO: once we start writing xrefs and posting lists, // symbol IDs should probably be in a string table. OS.write(static_cast<uint8_t>(Sym.SymInfo.Kind)); OS.write(static_cast<uint8_t>(Sym.SymInfo.Lang)); writeVar(Strings.index(Sym.Name), OS); writeVar(Strings.index(Sym.Scope), OS); writeVar(Strings.index(Sym.TemplateSpecializationArgs), OS); writeLocation(Sym.Definition, Strings, OS); writeLocation(Sym.CanonicalDeclaration, Strings, OS); writeVar(Sym.References, OS); OS.write(static_cast<uint8_t>(Sym.Flags)); OS.write(static_cast<uint8_t>(Sym.Origin)); writeVar(Strings.index(Sym.Signature), OS); writeVar(Strings.index(Sym.CompletionSnippetSuffix), OS); writeVar(Strings.index(Sym.Documentation), OS); writeVar(Strings.index(Sym.ReturnType), OS); writeVar(Strings.index(Sym.Type), OS); auto WriteInclude = [&](const Symbol::IncludeHeaderWithReferences &Include) { writeVar(Strings.index(Include.IncludeHeader), OS); writeVar(Include.References, OS); }; writeVar(Sym.IncludeHeaders.size(), OS); for (const auto &Include : Sym.IncludeHeaders) WriteInclude(Include); }
void CGBitFieldInfo::print(llvm::raw_ostream &OS) const { OS << "<CGBitFieldInfo"; OS << " Size:" << Size; OS << " IsSigned:" << IsSigned << "\n"; OS.indent(4 + strlen("<CGBitFieldInfo")); OS << " NumComponents:" << getNumComponents(); OS << " Components: ["; if (getNumComponents()) { OS << "\n"; for (unsigned i = 0, e = getNumComponents(); i != e; ++i) { const AccessInfo &AI = getComponent(i); OS.indent(8); OS << "<AccessInfo" << " FieldIndex:" << AI.FieldIndex << " FieldByteOffset:" << AI.FieldByteOffset << " FieldBitStart:" << AI.FieldBitStart << " AccessWidth:" << AI.AccessWidth << "\n"; OS.indent(8 + strlen("<AccessInfo")); OS << " AccessAlignment:" << AI.AccessAlignment << " TargetBitOffset:" << AI.TargetBitOffset << " TargetBitWidth:" << AI.TargetBitWidth << ">\n"; } OS.indent(4); } OS << "]>"; }
static void PrintHelpOptionList(llvm::raw_ostream &OS, llvm::StringRef Title, std::vector<std::pair<std::string, const char*> > &OptionHelp) { OS << Title << ":\n"; // Find the maximum option length. unsigned OptionFieldWidth = 0; for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) { // Skip titles. if (!OptionHelp[i].second) continue; // Limit the amount of padding we are willing to give up for alignment. unsigned Length = OptionHelp[i].first.size(); if (Length <= 23) OptionFieldWidth = std::max(OptionFieldWidth, Length); } const unsigned InitialPad = 2; for (unsigned i = 0, e = OptionHelp.size(); i != e; ++i) { const std::string &Option = OptionHelp[i].first; int Pad = OptionFieldWidth - int(Option.size()); OS.indent(InitialPad) << Option; // Break on long option names. if (Pad < 0) { OS << "\n"; Pad = OptionFieldWidth + InitialPad; } OS.indent(Pad + 1) << OptionHelp[i].second << '\n'; } }
/// \brief Format the given diagnostic text and place the result in the given /// buffer. static void formatDiagnosticText(StringRef InText, ArrayRef<DiagnosticArgument> Args, llvm::raw_ostream &Out) { while (!InText.empty()) { size_t Percent = InText.find('%'); if (Percent == StringRef::npos) { // Write the rest of the string; we're done. Out.write(InText.data(), InText.size()); break; } // Write the string up to (but not including) the %, then drop that text // (including the %). Out.write(InText.data(), Percent); InText = InText.substr(Percent + 1); // '%%' -> '%'. if (InText[0] == '%') { Out.write('%'); InText = InText.substr(1); continue; } // Parse an optional modifier. StringRef Modifier; { unsigned Length = 0; while (isalpha(InText[Length])) ++Length; Modifier = InText.substr(0, Length); InText = InText.substr(Length); } // Parse the optional argument list for a modifier, which is brace-enclosed. StringRef ModifierArguments; if (InText[0] == '{') { InText = InText.substr(1); ModifierArguments = skipToDelimiter(InText, '}'); } // Find the digit sequence. unsigned Length = 0; for (size_t N = InText.size(); Length != N; ++Length) { if (!isdigit(InText[Length])) break; } // Parse the digit sequence into an argument index. unsigned ArgIndex; bool Result = InText.substr(0, Length).getAsInteger(10, ArgIndex); assert(!Result && "Unparseable argument index value?"); (void)Result; assert(ArgIndex < Args.size() && "Out-of-range argument index"); InText = InText.substr(Length); // Convert the argument to a string. formatDiagnosticArgument(Modifier, ModifierArguments, Args, ArgIndex, Out); } }
/// Print the current state of all MemoryAccesses to @p OS. void printAccesses(llvm::raw_ostream &OS, int Indent = 0) const { OS.indent(Indent) << "After accesses {\n"; for (auto &Stmt : *S) { OS.indent(Indent + 4) << Stmt.getBaseName() << "\n"; for (auto *MA : Stmt) MA->print(OS); } OS.indent(Indent) << "}\n"; }
WithColor::WithColor(llvm::raw_ostream &OS, enum HighlightColor Type) : OS(OS) { // Detect color from terminal type unless the user passed the --color option. if (UseColor == cl::BOU_UNSET ? OS.has_colors() : UseColor == cl::BOU_TRUE) { switch (Type) { case Address: OS.changeColor(llvm::raw_ostream::YELLOW); break; case String: OS.changeColor(llvm::raw_ostream::GREEN); break; case Tag: OS.changeColor(llvm::raw_ostream::BLUE); break; case Attribute: OS.changeColor(llvm::raw_ostream::CYAN); break; case Enumerator: OS.changeColor(llvm::raw_ostream::MAGENTA); break; } } }
void TempScop::printDetail(llvm::raw_ostream &OS, ScalarEvolution *SE, LoopInfo *LI, const Region *CurR, unsigned ind) const { // Print the loop bounds, if the current region is a loop. LoopBoundMapType::const_iterator at = LoopBounds.find(castToLoop(*CurR, *LI)); if (at != LoopBounds.end()) { OS.indent(ind) << "Bounds of Loop: " << at->first->getHeader()->getName() << ":\t{ "; at->second.print(OS, false); OS << " }\n"; ind += 2; } // Iterate over the region nodes of this Scop to print the access functions // and loop bounds. for (Region::const_element_iterator I = CurR->element_begin(), E = CurR->element_end(); I != E; ++I) { if (I->isSubRegion()) { Region *subR = I->getNodeAs<Region>(); printDetail(OS, SE, LI, subR, ind + 2); } else { BasicBlock *BB = I->getNodeAs<BasicBlock>(); if (const AccFuncSetType *AccFunc = getAccessFunctions(BB)) { OS.indent(ind) << "BB: " << BB->getName() << "{\n"; for (AccFuncSetType::const_iterator FI = AccFunc->begin(), FE = AccFunc->end(); FI != FE; ++FI) { const SCEVAffFunc &AF = FI->first; const Value *Ptr = AF.getBaseAddr(); OS.indent(ind + 2) << AF << " Refs: "; for (MayAliasSetInfo::const_alias_iterator MI = MayASInfo->alias_begin(Ptr), ME = MayASInfo->alias_end(Ptr); MI != ME; ++MI) { MI->second->print(OS); OS << ", "; } OS << '\n'; } if (Reductions.count(BB)) OS.indent(ind + 2) << "Reduction\n"; OS.indent(ind) << "}\n"; } } } }
bool FixItRewriter::WriteFixedFile(FileID ID, llvm::raw_ostream &OS) { const RewriteBuffer *RewriteBuf = Rewrite.getRewriteBufferFor(ID); if (!RewriteBuf) return true; RewriteBuf->write(OS); OS.flush(); return false; }
bool FixItRewriter::WriteFixedFile(FileID ID, llvm::raw_ostream &OS) { const RewriteBuffer *RewriteBuf = Rewrite.getRewriteBufferFor(ID); if (!RewriteBuf) return true; OS << std::string(RewriteBuf->begin(), RewriteBuf->end()); OS.flush(); return false; }
// This function exits the program. void printVersion(llvm::raw_ostream &OS) { OS << "LDC - the LLVM D compiler (" << global.ldc_version << "):\n"; OS << " based on DMD " << global.version << " and LLVM " << global.llvm_version << "\n"; OS << " built with " << ldc::built_with_Dcompiler_version << "\n"; #if defined(__has_feature) #if __has_feature(address_sanitizer) OS << " compiled with address sanitizer enabled\n"; #endif #endif OS << " Default target: " << llvm::sys::getDefaultTargetTriple() << "\n"; std::string CPU = llvm::sys::getHostCPUName(); if (CPU == "generic") { CPU = "(unknown)"; } OS << " Host CPU: " << CPU << "\n"; OS << " http://dlang.org - http://wiki.dlang.org/LDC\n"; OS << "\n"; // Without explicitly flushing here, only the target list is visible when // redirecting stdout to a file. OS.flush(); llvm::TargetRegistry::printRegisteredTargetsForVersion( #if LDC_LLVM_VER >= 600 OS #endif ); exit(EXIT_SUCCESS); }
void Table::Dump(llvm::raw_ostream &OS, llvm::StringRef Prefix) const { for(unsigned I = 0, E = RowsCount(); I < E; ++I) { if(!Prefix.empty()) { OS.changeColor(llvm::raw_ostream::GREEN) << Prefix << ": "; OS.resetColor(); } for(unsigned J = 0, K = ColsCount(); J < K; ++J) { llvm::StringRef Cell = Columns[J][I]; OS.indent(Columns[J].GetWidth() - Cell.size()) << Cell; if(J != K - 1) OS << " "; } OS << "\n"; } }
static void StreamChar(llvm::raw_ostream& o, const char v) { if (isprint(v)) o << '\'' << v << '\''; else { o << "\\0x"; o.write_hex(v); } }
void writeRefs(const SymbolID &ID, llvm::ArrayRef<Ref> Refs, const StringTableOut &Strings, llvm::raw_ostream &OS) { OS << ID.raw(); writeVar(Refs.size(), OS); for (const auto &Ref : Refs) { OS.write(static_cast<unsigned char>(Ref.Kind)); writeLocation(Ref.Location, Strings, OS); } }
void SymbolicValue::print(llvm::raw_ostream &os, unsigned indent) const { os.indent(indent); switch (representationKind) { case RK_Unknown: { os << "unknown(" << (int)getUnknownReason() << "): "; getUnknownNode()->dump(); return; } case RK_Metatype: os << "metatype: "; getMetatypeValue()->print(os); os << "\n"; return; case RK_Function: { auto fn = getFunctionValue(); os << "fn: " << fn->getName() << ": "; os << Demangle::demangleSymbolAsString(fn->getName()); os << "\n"; return; } case RK_Integer: case RK_IntegerInline: os << "int: " << getIntegerValue() << "\n"; return; case RK_Aggregate: { ArrayRef<SymbolicValue> elements = getAggregateValue(); switch (elements.size()) { case 0: os << "agg: 0 elements []\n"; return; case 1: os << "agg: 1 elt: "; elements[0].print(os, indent + 2); return; default: os << "agg: " << elements.size() << " elements [\n"; for (auto elt : elements) elt.print(os, indent + 2); os.indent(indent) << "]\n"; return; } } } }
void SubstitutionMap::dump(llvm::raw_ostream &out) const { out << "Substitutions:\n"; for (const auto &sub : subMap) { out.indent(2); sub.first->print(out); out << " -> "; sub.second->print(out); out << "\n"; } out << "\nConformance map:\n"; for (const auto &conformances : conformanceMap) { out.indent(2); conformances.first->print(out); out << " -> ["; interleave(conformances.second.begin(), conformances.second.end(), [&](ProtocolConformanceRef conf) { conf.dump(out); }, [&] { out << ", "; }); out << "]\n"; } out << "\nParent map:\n"; for (const auto &parent : parentMap) { out.indent(2); parent.first->print(out); out << " -> ["; interleave(parent.second.begin(), parent.second.end(), [&](SubstitutionMap::ParentType parentType) { parentType.first->print(out); out << " @ "; out << parentType.second->getProtocol()->getName().str() << "." << parentType.second->getName().str(); }, [&] { out << ", "; }); out << "]\n"; } }
/// Print simplification statistics to @p OS. void printStatistics(llvm::raw_ostream &OS, int Indent = 0) const { OS.indent(Indent) << "Statistics {\n"; OS.indent(Indent + 4) << "Overwrites removed: " << OverwritesRemoved << '\n'; OS.indent(Indent + 4) << "Partial writes coalesced: " << WritesCoalesced << "\n"; OS.indent(Indent + 4) << "Redundant writes removed: " << RedundantWritesRemoved << "\n"; OS.indent(Indent + 4) << "Accesses with empty domains removed: " << EmptyPartialAccessesRemoved << "\n"; OS.indent(Indent + 4) << "Dead accesses removed: " << DeadAccessesRemoved << '\n'; OS.indent(Indent + 4) << "Dead instructions removed: " << DeadInstructionsRemoved << '\n'; OS.indent(Indent + 4) << "Stmts removed: " << StmtsRemoved << "\n"; OS.indent(Indent) << "}\n"; }
void writeIncludeGraphNode(const IncludeGraphNode &IGN, const StringTableOut &Strings, llvm::raw_ostream &OS) { OS.write(IGN.IsTU); writeVar(Strings.index(IGN.URI), OS); llvm::StringRef Hash(reinterpret_cast<const char *>(IGN.Digest.data()), IGN.Digest.size()); OS << Hash; writeVar(IGN.DirectIncludes.size(), OS); for (llvm::StringRef Include : IGN.DirectIncludes) writeVar(Strings.index(Include), OS); }
void CheckerRegistry::printHelp(llvm::raw_ostream &out, size_t maxNameChars) const { // FIXME: Alphabetical sort puts 'experimental' in the middle. // Would it be better to name it '~experimental' or something else // that's ASCIIbetically last? std::sort(Checkers.begin(), Checkers.end(), checkerNameLT); // FIXME: Print available packages. out << "CHECKERS:\n"; // Find the maximum option length. size_t optionFieldWidth = 0; for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end(); i != e; ++i) { // Limit the amount of padding we are willing to give up for alignment. // Package.Name Description [Hidden] size_t nameLength = i->FullName.size(); if (nameLength <= maxNameChars) optionFieldWidth = std::max(optionFieldWidth, nameLength); } const size_t initialPad = 2; for (CheckerInfoList::const_iterator i = Checkers.begin(), e = Checkers.end(); i != e; ++i) { out.indent(initialPad) << i->FullName; int pad = optionFieldWidth - i->FullName.size(); // Break on long option names. if (pad < 0) { out << '\n'; pad = optionFieldWidth + initialPad; } out.indent(pad + 2) << i->Desc; out << '\n'; } }
void ClangInternalState::printAST(llvm::raw_ostream& Out, ASTContext& C) { TranslationUnitDecl* TU = C.getTranslationUnitDecl(); unsigned Indentation = 0; bool PrintInstantiation = false; std::string ErrMsg; clang::PrintingPolicy policy = C.getPrintingPolicy(); TU->print(Out, policy, Indentation, PrintInstantiation); // TODO: For future when we relpace the bump allocation with slab. // //Out << "Allocated memory: " << C.getAllocatedMemory(); //Out << "Side table allocated memory: " << C.getSideTableAllocatedMemory(); Out.flush(); }
void CGRecordLayout::print(llvm::raw_ostream &OS) const { OS << "<CGRecordLayout\n"; OS << " LLVMType:" << *LLVMType << "\n"; OS << " ContainsPointerToDataMember:" << ContainsPointerToDataMember << "\n"; OS << " BitFields:[\n"; for (llvm::DenseMap<const FieldDecl*, CGBitFieldInfo>::const_iterator it = BitFields.begin(), ie = BitFields.end(); it != ie; ++it) { OS.indent(4); it->second.print(OS); OS << "\n"; } OS << "]>\n"; }
bool ASTUnit::serialize(llvm::raw_ostream &OS) { if (getDiagnostics().hasErrorOccurred()) return true; SmallString<128> Buffer; llvm::BitstreamWriter Stream(Buffer); ASTWriter Writer(Stream); Writer.WriteAST(getSema(), 0, std::string(), 0); // Write the generated bitstream to "Out". if (!Buffer.empty()) OS.write((char *)&Buffer.front(), Buffer.size()); return false; }
void Transaction::DelayCallInfo::print(llvm::raw_ostream& Out, const PrintingPolicy& Policy, unsigned Indent, bool PrintInstantiation, llvm::StringRef prependInfo /*=""*/) const { static const char* const stateNames[Transaction::kCCINumStates] = { "kCCINone", "kCCIHandleTopLevelDecl", "kCCIHandleInterestingDecl", "kCCIHandleTagDeclDefinition", "kCCIHandleVTable", "kCCIHandleCXXImplicitFunctionInstantiation", "kCCIHandleCXXStaticMemberVarInstantiation", }; assert((sizeof(stateNames) /sizeof(void*)) == Transaction::kCCINumStates && "Missing states?"); if (!prependInfo.empty()) { Out.changeColor(llvm::raw_ostream::RED); Out << prependInfo; Out.resetColor(); Out << ", "; } Out.changeColor(llvm::raw_ostream::BLUE); Out << stateNames[m_Call]; Out.changeColor(llvm::raw_ostream::GREEN); Out << " <- "; Out.resetColor(); for (DeclGroupRef::const_iterator I = m_DGR.begin(), E = m_DGR.end(); I != E; ++I) { if (*I) (*I)->print(Out, Policy, Indent, PrintInstantiation); else Out << "<<NULL DECL>>"; Out << '\n'; } }
void ConstraintGraph::printConnectedComponents(llvm::raw_ostream &out) { SmallVector<TypeVariableType *, 16> typeVars; SmallVector<unsigned, 16> components; unsigned numComponents = computeConnectedComponents(typeVars, components); for (unsigned component = 0; component != numComponents; ++component) { out.indent(2); out << component << ":"; for (unsigned i = 0, n = typeVars.size(); i != n; ++i) { if (components[i] == component) { out << ' '; typeVars[i]->print(out); } } out << '\n'; } }
void RawSyntax::dump(llvm::raw_ostream &OS, unsigned Indent) const { auto indent = [&](unsigned Amount) { for (decltype(Amount) i = 0; i < Amount; ++i) { OS << ' '; } }; indent(Indent); OS << '('; dumpSyntaxKind(OS, getKind()); if (isMissing()) OS << " [missing] "; if (isToken()) { OS << " "; dumpTokenKind(OS, getTokenKind()); for (auto &Leader : getLeadingTrivia()) { OS << "\n"; Leader.dump(OS, Indent + 1); } OS << "\n"; indent(Indent + 1); OS << "(text=\""; OS.write_escaped(getTokenText(), /*UseHexEscapes=*/true); OS << "\")"; for (auto &Trailer : getTrailingTrivia()) { OS << "\n"; Trailer.dump(OS, Indent + 1); } } else { for (auto &Child : getLayout()) { if (!Child) continue; OS << "\n"; Child->dump(OS, Indent + 1); } } OS << ')'; }
void OptTable::PrintHelp(llvm::raw_ostream &OS, const char *Name, const char *Title, bool ShowHidden) const { OS << "OVERVIEW: " << Title << "\n"; OS << '\n'; OS << "USAGE: " << Name << " [options] <inputs>\n"; OS << '\n'; // Render help text into a map of group-name to a list of (option, help) // pairs. typedef std::map<std::string, std::vector<std::pair<std::string, const char*> > > helpmap_ty; helpmap_ty GroupedOptionHelp; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned Id = i + 1; // FIXME: Split out option groups. if (getOptionKind(Id) == Option::GroupClass) continue; if (!ShowHidden && isOptionHelpHidden(Id)) continue; if (const char *Text = getOptionHelpText(Id)) { const char *HelpGroup = getOptionHelpGroup(*this, Id); const std::string &OptName = getOptionHelpName(*this, Id); GroupedOptionHelp[HelpGroup].push_back(std::make_pair(OptName, Text)); } } for (helpmap_ty::iterator it = GroupedOptionHelp .begin(), ie = GroupedOptionHelp.end(); it != ie; ++it) { if (it != GroupedOptionHelp .begin()) OS << "\n"; PrintHelpOptionList(OS, it->first, it->second); } OS.flush(); }
void ClangInternalState::printMacroDefinitions(llvm::raw_ostream& Out, const clang::Preprocessor& PP) { stdstrstream contentsOS; PP.printMacros(contentsOS); Out << "Ordered Alphabetically:\n"; std::vector<std::string> elems; { // Split the string into lines. char delim = '\n'; std::stringstream ss(contentsOS.str()); std::string item; while (std::getline(ss, item, delim)) { elems.push_back(item); } // Sort them alphabetically std::sort(elems.begin(), elems.end()); } for(std::vector<std::string>::iterator I = elems.begin(), E = elems.end(); I != E; ++I) Out << *I << '\n'; Out.flush(); }
static void printProfileData(const ProfileData &Profile, llvm::raw_ostream &OS) { // Time is first to allow for sorting by it. std::vector<std::pair<llvm::TimeRecord, StringRef>> Timers; TimeRecord Total; for (const auto& P : Profile.Records) { Timers.emplace_back(P.getValue(), P.getKey()); Total += P.getValue(); } std::sort(Timers.begin(), Timers.end()); std::string Line = "===" + std::string(73, '-') + "===\n"; OS << Line; if (Total.getUserTime()) OS << " ---User Time---"; if (Total.getSystemTime()) OS << " --System Time--"; if (Total.getProcessTime()) OS << " --User+System--"; OS << " ---Wall Time---"; if (Total.getMemUsed()) OS << " ---Mem---"; OS << " --- Name ---\n"; // Loop through all of the timing data, printing it out. for (auto I = Timers.rbegin(), E = Timers.rend(); I != E; ++I) { I->first.print(Total, OS); OS << I->second << '\n'; } Total.print(Total, OS); OS << "Total\n"; OS << Line << "\n"; OS.flush(); }
void printName(llvm::raw_ostream &out, ObjectPtr x) { switch (x->objKind) { case IDENTIFIER : { Identifier *y = (Identifier *)x.ptr(); if (_safeNames > 0) { out << "#"; for (unsigned i = 0; i < y->str.size(); ++i) { char ch = y->str[i]; if (isSafe(ch)) out << ch; else out << 'c' << (unsigned int)ch; } } else { out << "\""; for (unsigned i = 0; i < y->str.size(); ++i) { char ch = y->str[i]; switch (ch) { case '\0': out << "\\0"; break; case '\n': out << "\\n"; break; case '\r': out << "\\r"; break; case '\t': out << "\\t"; break; case '\f': out << "\\f"; break; case '\\': out << "\\\\"; break; case '\'': out << "\\'"; break; case '\"': out << "\\\""; break; default: if (ch >= '\x20' && ch <= '\x7E') out << ch; else { out << "\\x"; if (ch < 16) out << '0'; out.write_hex((unsigned long long int)ch); } break; } } out << "\""; } break; } case GLOBAL_VARIABLE : { GlobalVariable *y = (GlobalVariable *)x.ptr(); out << y->name->str; break; } case GLOBAL_ALIAS : { GlobalAlias *y = (GlobalAlias *)x.ptr(); out << y->name->str; break; } case RECORD_DECL : { RecordDecl *y = (RecordDecl *)x.ptr(); out << y->name->str; break; } case VARIANT_DECL : { VariantDecl *y = (VariantDecl *)x.ptr(); out << y->name->str; break; } case PROCEDURE : { Procedure *y = (Procedure *)x.ptr(); out << y->name->str; break; } case MODULE : { Module *m = (Module *)x.ptr(); out << m->moduleName; break; } case INTRINSIC : { IntrinsicSymbol *intrin = (IntrinsicSymbol *)x.ptr(); out << intrin->name->str; break; } case PRIM_OP : { out << primOpName((PrimOp *)x.ptr()); break; } case TYPE : { typePrint(out, (Type *)x.ptr()); break; } case VALUE_HOLDER : { ValueHolder *y = (ValueHolder *)x.ptr(); if (isStaticOrTupleOfStatics(y->type)) { printStaticOrTupleOfStatics(out, y->type); } else { EValuePtr ev = new EValue(y->type, y->buf); printValue(out, ev); } break; } case EXTERNAL_PROCEDURE : { ExternalProcedure *proc = (ExternalProcedure*)x.ptr(); out << "external " << proc->name->str; break; } default : { out << "UnknownNamedObject(" << x->objKind << ")"; break; } } }
void swift::markup::printInlinesUnder(const MarkupASTNode *Node, llvm::raw_ostream &OS, bool PrintDecorators) { auto printChildren = [](const ArrayRef<const MarkupASTNode *> Children, llvm::raw_ostream &OS) { for (auto Child = Children.begin(); Child != Children.end(); Child++) swift::markup::printInlinesUnder(*Child, OS); }; switch (Node->getKind()) { case swift::markup::ASTNodeKind::HTML: { auto H = cast<HTML>(Node); OS << H->getLiteralContent(); break; } case swift::markup::ASTNodeKind::InlineHTML: { auto IH = cast<InlineHTML>(Node); OS << IH->getLiteralContent(); break; } case swift::markup::ASTNodeKind::HRule: OS << '\n'; break; case swift::markup::ASTNodeKind::Text: { auto T = cast<Text>(Node); OS << T->getLiteralContent(); break; } case swift::markup::ASTNodeKind::SoftBreak: OS << ' '; break; case swift::markup::ASTNodeKind::LineBreak: OS << '\n'; break; case swift::markup::ASTNodeKind::Code: { auto C = cast<Code>(Node); if (PrintDecorators) OS << '`'; OS << C->getLiteralContent(); if (PrintDecorators) OS << '`'; break; } case swift::markup::ASTNodeKind::CodeBlock: { auto CB = cast<CodeBlock>(Node); if (PrintDecorators) OS << "``"; OS << CB->getLiteralContent(); if (PrintDecorators) OS << "``"; break; } case swift::markup::ASTNodeKind::Emphasis: { auto E = cast<Emphasis>(Node); if (PrintDecorators) OS << '*'; printChildren(E->getChildren(), OS); if (PrintDecorators) OS << '*'; break; } case swift::markup::ASTNodeKind::Strong: { auto S = cast<Strong>(Node); if (PrintDecorators) OS << "**"; printChildren(S->getChildren(), OS); if (PrintDecorators) OS << "**"; break; } default: printChildren(Node->getChildren(), OS); } OS.flush(); }