[flang-commits] [flang] [flang][openacc] Make OpenACC block construct parse errors less verbose. (PR #131042)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Mar 17 14:16:08 PDT 2025
================
@@ -272,19 +272,51 @@ static llvm::raw_ostream::Colors PrefixColor(Severity severity) {
return llvm::raw_ostream::SAVEDCOLOR;
}
+// TODO: Make these configurable, based on verbosity level.
+const int MAX_CONTEXTS_EMITTED = 2;
+const bool OMIT_SHARED_CONTEXTS = true;
+
void Message::Emit(llvm::raw_ostream &o, const AllCookedSources &allCooked,
bool echoSourceLine) const {
std::optional<ProvenanceRange> provenanceRange{GetProvenanceRange(allCooked)};
const AllSources &sources{allCooked.allSources()};
sources.EmitMessage(o, provenanceRange, ToString(), Prefix(severity()),
PrefixColor(severity()), echoSourceLine);
+ // Always refers to if the attachment in the loop below is a context.
bool isContext{attachmentIsContext_};
+ int contextsEmitted{0};
+ // Emit attachments.
for (const Message *attachment{attachment_.get()}; attachment;
- attachment = attachment->attachment_.get()) {
+ isContext = attachment->attachmentIsContext_,
+ attachment = attachment->attachment_.get()) {
Severity severity = isContext ? Severity::Context : attachment->severity();
- sources.EmitMessage(o, attachment->GetProvenanceRange(allCooked),
- attachment->ToString(), Prefix(severity), PrefixColor(severity),
- echoSourceLine);
+ auto emitAttachment = [&]() {
+ sources.EmitMessage(o, attachment->GetProvenanceRange(allCooked),
+ attachment->ToString(), Prefix(severity), PrefixColor(severity),
+ echoSourceLine);
+ };
+
+ if (isContext) {
+ // Truncate the number of contexts emitted.
+ if (contextsEmitted < MAX_CONTEXTS_EMITTED) {
+ emitAttachment();
+ contextsEmitted += 1;
+ }
+ if (OMIT_SHARED_CONTEXTS) {
----------------
klausler wrote:
`if constexpr`
https://github.com/llvm/llvm-project/pull/131042
More information about the flang-commits
mailing list