//===----------------------------------------------------------------------===//
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
"environment variable unset.");
// Open the secure log file if we haven't already.
- raw_ostream *OS = getContext().getSecureLog();
+ raw_fd_ostream *OS = getContext().getSecureLog();
if (!OS) {
std::error_code EC;
- OS = new raw_fd_ostream(SecureLogFile, EC,
- sys::fs::F_Append | sys::fs::F_Text);
- if (EC) {
- delete OS;
+ auto NewOS = llvm::make_unique<raw_fd_ostream>(
+ SecureLogFile, EC, sys::fs::F_Append | sys::fs::F_Text);
+ if (EC)
return Error(IDLoc, Twine("can't open secure log file: ") +
SecureLogFile + " (" + EC.message() + ")");
- }
- getContext().setSecureLog(OS);
+ OS = NewOS.get();
+ getContext().setSecureLog(std::move(NewOS));
}
// Write the message.