[flang-commits] [flang] [flang][Driver] Improve error message for assembly file input (PR #174069)

Tarun Prabhu via flang-commits flang-commits at lists.llvm.org
Wed Dec 31 09:25:30 PST 2025


https://github.com/tarunprabhu requested changes to this pull request.

Thanks for the PR. This needs a fair bit of work before it can be accepted.

The [DiagnosticEngine](https://clang.llvm.org/docs/InternalsManual.html#the-diagnostics-subsystem) should nearly always be used to emit diagnostics. They should not be written directly to stderr.

Code to determine the source language of a file from its [extension already exists in Flang](https://github.com/llvm/llvm-project/blob/main/flang/lib/Frontend/FrontendOptions.cpp#L44). Unlike the [corresponding code in Clang](https://github.com/llvm/llvm-project/blob/main/clang/lib/Frontend/FrontendOptions.cpp#L15) though, it does not yet know about assembly files. There should already be code in `flang/lib/Frontend/CompilerInvocation.cpp` that checks the input language. It would be better to issue a diagnostic from there since, by that time, the `DiagnosticEngine` object will already have been set up correctly.

A rule of thumb for these is to see what the code around you is doing. If you don't see much error checking and diagnostics emission, then it's probably not the right place to add it. This is, of course, just a rule of thumb and there are always exceptions. But it's always better to go with the odds :)

https://github.com/llvm/llvm-project/pull/174069


More information about the flang-commits mailing list