本文整理汇总了C++中llvm::raw_ostream类的典型用法代码示例。如果您正苦于以下问题:C++ raw_ostream类的具体用法?C++ raw_ostream怎么用?C++ raw_ostream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了raw_ostream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printGroup
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";
}
}
}
示例2: writeSymbol
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);
}
示例3: print
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 << "]>";
}
示例4: PrintHelpOptionList
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';
}
}
示例5: formatDiagnosticText
/// \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);
}
}
示例6: printAccesses
/// 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";
}
示例7: OS
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;
}
}
}
示例8: printDetail
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";
}
}
}
}
示例9: WriteFixedFile
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;
}
示例10: printVersion
// 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);
}
示例11: Dump
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";
}
}
示例12: StreamChar
static void StreamChar(llvm::raw_ostream& o, const char v) {
if (isprint(v))
o << '\'' << v << '\'';
else {
o << "\\0x";
o.write_hex(v);
}
}
示例13: writeRefs
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);
}
}
示例14: print
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;
}
}
}
}
示例15: dump
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";
}
}