GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Modernize optrecord JSON writer with smart pointers.

The `optrecord_json_writer` class is updated to use modern C++ features like `std::unique_ptr` for memory management.

The optrecord_json_writer class has been modernized to use std::unique_ptr for memory management, replacing raw new and delete calls. This improves code safety and reduces the risk of memory leaks. The change also updates the code to use nullptr instead of NULL and passes non-null values by const-reference instead of const-pointer where appropriate.

In Details

The optrecord_json_writer class is responsible for emitting optimization information in JSON format. This commit modernizes the class by replacing naked new and delete with std::make_unique and std::unique_ptr. It touches dump-context.h, dumpfile.cc, optinfo-emit-json.cc, optinfo-emit-json.h, and optinfo.cc. No functional changes are intended.

For Context

This commit modernizes the way GCC handles the output of optimization information in JSON format. It replaces manual memory management (using new and delete) with smart pointers (std::unique_ptr). This makes the code safer and easier to maintain, as the memory will be automatically released when it's no longer needed.

Filed Under: optimizationjsonmodern C++