GCC Middle and Back End API Reference
diagnostic_output_file Class Reference

#include <diagnostic-output-file.h>

Public Member Functions

 diagnostic_output_file ()
 
 diagnostic_output_file (FILE *outf, bool owned, label_text filename)
 
 ~diagnostic_output_file ()
 
 diagnostic_output_file (const diagnostic_output_file &other)=delete
 
 diagnostic_output_file (diagnostic_output_file &&other)
 
diagnostic_output_fileoperator= (const diagnostic_output_file &other)=delete
 
diagnostic_output_fileoperator= (diagnostic_output_file &&other)
 
 operator bool () const
 
FILE * get_open_file () const
 
const char * get_filename () const
 

Static Public Member Functions

static diagnostic_output_file try_to_open (diagnostic_context &context, line_maps *line_maps, const char *base_file_name, const char *extension, bool binary)
 

Private Attributes

FILE * m_outf
 
bool m_owned
 
label_text m_filename
 

Detailed Description

RAII class for managing FILE * for diagnostic formats. Copyright (C) 2024-2025 Free Software Foundation, Inc. Contributed by David Malcolm <dmalcolm@redhat.com>. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
RAII class for wrapping a FILE * that could be borrowed or owned, along with the underlying filename.

Constructor & Destructor Documentation

◆ diagnostic_output_file() [1/4]

diagnostic_output_file::diagnostic_output_file ( )
inline

◆ diagnostic_output_file() [2/4]

diagnostic_output_file::diagnostic_output_file ( FILE * outf,
bool owned,
label_text filename )
inline

References gcc_assert, m_filename, m_outf, and m_owned.

◆ ~diagnostic_output_file()

diagnostic_output_file::~diagnostic_output_file ( )
inline

References gcc_assert, m_outf, and m_owned.

◆ diagnostic_output_file() [3/4]

diagnostic_output_file::diagnostic_output_file ( const diagnostic_output_file & other)
delete

◆ diagnostic_output_file() [4/4]

diagnostic_output_file::diagnostic_output_file ( diagnostic_output_file && other)
inline

Member Function Documentation

◆ get_filename()

const char * diagnostic_output_file::get_filename ( ) const
inline

References m_filename.

◆ get_open_file()

FILE * diagnostic_output_file::get_open_file ( ) const
inline

References m_outf.

◆ operator bool()

diagnostic_output_file::operator bool ( ) const
inline

References m_outf.

◆ operator=() [1/2]

diagnostic_output_file & diagnostic_output_file::operator= ( const diagnostic_output_file & other)
delete

◆ operator=() [2/2]

diagnostic_output_file & diagnostic_output_file::operator= ( diagnostic_output_file && other)
inline

◆ try_to_open()

diagnostic_output_file diagnostic_output_file::try_to_open ( diagnostic_context & context,
line_maps * line_maps,
const char * base_file_name,
const char * extension,
bool is_binary )
static
Attempt to open "BASE_FILE_NAME""EXTENSION" for writing. Return a non-null diagnostic_output_file, or return a null diagnostic_output_file and complain to CONTEXT using LINE_MAPS.

References base_file_name(), diagnostic_output_file(), diagnostic_context::emit_diagnostic_with_group(), fopen, gcc_assert, and UNKNOWN_LOCATION.

Referenced by diagnostic_output_format_open_sarif_file().

Field Documentation

◆ m_filename

label_text diagnostic_output_file::m_filename
private

◆ m_outf

◆ m_owned


The documentation for this class was generated from the following files: