diff --git a/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp b/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp index c1e1499f85..40fb855b3b 100755 --- a/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp +++ b/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp @@ -14,7 +14,7 @@ ATNDeserializationOptions::ATNDeserializationOptions(ATNDeserializationOptions * _generateRuleBypassTransitions(options->_generateRuleBypassTransitions) {} const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() { - static const ATNDeserializationOptions* const defaultOptions = new ATNDeserializationOptions(); + static const std::unique_ptr defaultOptions = std::make_unique(); return *defaultOptions; } diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg index 6fc4419d02..e557fc811d 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg @@ -147,7 +147,7 @@ struct StaticData final { #if ANTLR4_USE_THREAD_LOCAL_CACHE static thread_local #endif -StaticData *LexerStaticData = nullptr; +std::unique_ptr\<StaticData> LexerStaticData = nullptr; void LexerInitialize() { #if ANTLR4_USE_THREAD_LOCAL_CACHE @@ -175,7 +175,7 @@ void LexerInitialize() { } ); - LexerStaticData = staticData.release(); + LexerStaticData = std::move(staticData); } } @@ -380,7 +380,7 @@ struct StaticData final { #if ANTLR4_USE_THREAD_LOCAL_CACHE static thread_local #endif -StaticData *ParserStaticData = nullptr; +std::unique_ptr\<StaticData> ParserStaticData = nullptr; void ParserInitialize() { #if ANTLR4_USE_THREAD_LOCAL_CACHE @@ -402,7 +402,7 @@ void ParserInitialize() { } ); - ParserStaticData = staticData.release(); + ParserStaticData = std::move(staticData); } }