[flang-commits] [flang] 09a4058 - [flang][debuginfo] Use <stdin> for file name when reading from stdin

via flang-commits flang-commits at lists.llvm.org
Fri Jan 16 10:51:13 PST 2026


Author: Tarun Prabhu
Date: 2026-01-16T11:51:09-07:00
New Revision: 09a4058474dfee09f031b9ef0e4872e75256c1c3

URL: https://github.com/llvm/llvm-project/commit/09a4058474dfee09f031b9ef0e4872e75256c1c3
DIFF: https://github.com/llvm/llvm-project/commit/09a4058474dfee09f031b9ef0e4872e75256c1c3.diff

LOG: [flang][debuginfo] Use <stdin> for file name when reading from stdin

Currently, the DIFile debuginfo nodes use "standard input" as the file
name when compiling with -g and reading input from stdin. This has been
changed to "<stdin>" for consistency with clang and gfortran.

Fixes #60288

Added: 
    flang/test/Driver/input-from-stdin/debug-info-filename.f90

Modified: 
    flang/lib/Parser/source.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/source.cpp b/flang/lib/Parser/source.cpp
index ae834dc241652..6313373675e5b 100644
--- a/flang/lib/Parser/source.cpp
+++ b/flang/lib/Parser/source.cpp
@@ -142,7 +142,7 @@ bool SourceFile::Open(std::string path, llvm::raw_ostream &error) {
 
 bool SourceFile::ReadStandardInput(llvm::raw_ostream &error) {
   Close();
-  path_ = "standard input";
+  path_ = "<stdin>";
   auto buf_or = llvm::MemoryBuffer::getSTDIN();
   if (!buf_or) {
     auto err = buf_or.getError();

diff  --git a/flang/test/Driver/input-from-stdin/debug-info-filename.f90 b/flang/test/Driver/input-from-stdin/debug-info-filename.f90
new file mode 100644
index 0000000000000..9dd950ce87ea0
--- /dev/null
+++ b/flang/test/Driver/input-from-stdin/debug-info-filename.f90
@@ -0,0 +1,14 @@
+! When compiling with debug info, the "file name" should be "<stdin>" for
+! consistency with clang and gfortran. The exception is the first file that is
+! referenced from the DICompileUnit in which the file name is "-". This is also
+! consistent with clang.
+!
+! RUN: cat %s \
+! RUN:     | %flang -g -x f95 -S -emit-llvm -o - - \
+! RUN:     | FileCheck %s
+!
+! CHECK: !DICompileUnit({{.*}}file: ![[DASH:[0-9]+]]
+! CHECK: ![[DASH]] = !DIFile({{.*}}filename: "-"
+! CHECK: !DIFile({{.*}}filename: "<stdin>"
+
+end program


        


More information about the flang-commits mailing list