forked from OSchip/llvm-project
[flang] Support resolution of provenances in messages from CharBlocks to ProvenanceRanges
Original-commit: flang-compiler/f18@aa57287959 Reviewed-on: https://github.com/flang-compiler/f18/pull/151 Tree-same-pre-rewrite: false
This commit is contained in:
parent
28ed1390cd
commit
108e9b4678
|
@ -134,6 +134,18 @@ std::string Message::ToString() const {
|
|||
text_);
|
||||
}
|
||||
|
||||
void Message::ResolveProvenances(const CookedSource &cooked) {
|
||||
if (CharBlock * cb{std::get_if<CharBlock>(&location_)}) {
|
||||
if (std::optional<ProvenanceRange> resolved{
|
||||
cooked.GetProvenanceRange(*cb)}) {
|
||||
location_ = *resolved;
|
||||
}
|
||||
}
|
||||
if (Message * attachment{attachment_.get()}) {
|
||||
attachment->ResolveProvenances(cooked);
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<ProvenanceRange> Message::GetProvenanceRange(
|
||||
const CookedSource &cooked) const {
|
||||
return std::visit(common::visitors{[&](const CharBlock &cb) {
|
||||
|
@ -221,6 +233,12 @@ void Messages::Copy(const Messages &that) {
|
|||
}
|
||||
}
|
||||
|
||||
void Messages::ResolveProvenances(const CookedSource &cooked) {
|
||||
for (Message &m : messages_) {
|
||||
m.ResolveProvenances(cooked);
|
||||
}
|
||||
}
|
||||
|
||||
void Messages::Emit(
|
||||
std::ostream &o, const CookedSource &cooked, bool echoSourceLines) const {
|
||||
std::vector<const Message *> sorted;
|
||||
|
|
|
@ -144,6 +144,7 @@ public:
|
|||
bool SortBefore(const Message &that) const;
|
||||
bool IsFatal() const;
|
||||
std::string ToString() const;
|
||||
void ResolveProvenances(const CookedSource &);
|
||||
std::optional<ProvenanceRange> GetProvenanceRange(const CookedSource &) const;
|
||||
void Emit(
|
||||
std::ostream &, const CookedSource &, bool echoSourceLine = true) const;
|
||||
|
@ -207,6 +208,7 @@ public:
|
|||
|
||||
void Incorporate(Messages &);
|
||||
void Copy(const Messages &);
|
||||
void ResolveProvenances(const CookedSource &);
|
||||
void Emit(std::ostream &, const CookedSource &cooked,
|
||||
bool echoSourceLines = true) const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue