[flang] Spruce up formatting of error message output.

Original-commit: flang-compiler/f18@0750985bdf
Reviewed-on: https://github.com/flang-compiler/f18/pull/9
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2018-02-15 13:36:50 -08:00 committed by GitHub
parent edbec459fb
commit 59bb0866c3

View file

@ -153,24 +153,38 @@ void AllSources::Identify(std::ostream &o, Provenance at,
o << ' '; o << ' ';
} }
o << "in the " << (inc.isModule ? "module " : "file ") o << "in the " << (inc.isModule ? "module " : "file ")
<< inc.source.path() << '\n'; << inc.source.path();
if (IsValid(origin.replaces)) { if (IsValid(origin.replaces)) {
o << prefix << " that was " o << (inc.isModule ? " used\n" : " included\n");
<< (inc.isModule ? "used\n" : "included\n");
Identify(o, origin.replaces.LocalOffsetToProvenance(0), indented); Identify(o, origin.replaces.LocalOffsetToProvenance(0), indented);
} else {
o << '\n';
} }
}, },
[&](const Macro &mac) { [&](const Macro &mac) {
o << prefix << "in the expansion of a macro that was defined\n"; o << prefix << "in the expansion of a macro that was defined\n";
Identify(o, mac.definition.LocalOffsetToProvenance(0), indented); Identify(o, mac.definition.LocalOffsetToProvenance(0), indented,
o << prefix << "... and called\n"; echoSourceLine);
Identify(o, origin.replaces.LocalOffsetToProvenance(0), indented); o << prefix << "and called\n";
o << prefix << "... and expanded to\n" Identify(o, origin.replaces.LocalOffsetToProvenance(0), indented,
<< indented << mac.expansion << '\n'; echoSourceLine);
if (echoSourceLine) {
o << prefix << "and expanded to\n"
<< indented << " " << mac.expansion << '\n'
<< indented << " ";
for (size_t j{0}; origin.covers.LocalOffsetToProvenance(j) < at;
++j) {
o << (mac.expansion[j] == '\t' ? '\t' : ' ');
}
o << "^\n";
}
}, },
[&](const CompilerInsertion &ins) { [&](const CompilerInsertion &ins) {
o << prefix << "in text '" << ins.text o << prefix << "in text ";
<< "' inserted by the compiler\n"; if (echoSourceLine) {
o << '\'' << ins.text << "' ";
}
o << "inserted by the compiler\n";
}}, }},
origin.u); origin.u);
} }