summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-11-05 15:55:28 +0100
committerStephan Bergmann <sbergman@redhat.com>2022-11-06 01:14:05 +0100
commit7533d93cdcf3b6076275167b53450a1cbde045a7 (patch)
treed293d3395aa163dff1171b19a70505d99b5e7792 /compilerplugins
parent4280a3257948e57cdf194a6e23718b46d907bbd6 (diff)
-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): compilerplugins
Change-Id: I9a4d20cd42d6c836aa74837688a272f849d9d373 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142322 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/pluginhandler.cxx10
1 files changed, 4 insertions, 6 deletions
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index ffa4e3668def..f5d27dd76b2b 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -21,8 +21,8 @@
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendPluginRegistry.h>
#include <clang/Lex/PPCallbacks.h>
+#include <llvm/ADT/StringExtras.h>
#include <llvm/Support/TimeProfiler.h>
-#include <stdio.h>
#if defined _WIN32
#include <process.h>
@@ -384,8 +384,7 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
report( DiagnosticsEngine::Warning, pathWarning ) << name;
if( bSkip )
continue;
- char* filename = new char[ modifyFile.length() + 100 ];
- sprintf( filename, "%s.new.%d", modifyFile.c_str(), getpid());
+ auto const filename = modifyFile + ".new." + itostr(getpid());
std::string error;
bool bOk = false;
std::error_code ec;
@@ -395,16 +394,15 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
{
it->second.write( *ostream );
ostream->close();
- if( !ostream->has_error() && rename( filename, modifyFile.c_str()) == 0 )
+ if( !ostream->has_error() && rename( filename.c_str(), modifyFile.c_str()) == 0 )
bOk = true;
}
else
error = "error: " + ec.message();
ostream->clear_error();
- unlink( filename );
+ unlink( filename.c_str() );
if( !bOk )
report( DiagnosticsEngine::Error, "cannot write modified source to %0 (%1)" ) << modifyFile << error;
- delete[] filename;
}
#endif
}