[llvm] r255852 - Use std::unique_ptr. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 16 15:49:14 PST 2015
Author: rafael
Date: Wed Dec 16 17:49:14 2015
New Revision: 255852
URL: http://llvm.org/viewvc/llvm-project?rev=255852&view=rev
Log:
Use std::unique_ptr. NFC.
Modified:
llvm/trunk/include/llvm/MC/MCContext.h
llvm/trunk/lib/MC/MCContext.cpp
llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=255852&r1=255851&r2=255852&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Wed Dec 16 17:49:14 2015
@@ -113,7 +113,7 @@ namespace llvm {
/// directive is used or it is an error.
char *SecureLogFile;
/// The stream that gets written to for the .secure_log_unique directive.
- raw_ostream *SecureLog;
+ std::unique_ptr<raw_fd_ostream> SecureLog;
/// Boolean toggled when .secure_log_unique / .secure_log_reset is seen to
/// catch errors if .secure_log_unique appears twice without
/// .secure_log_reset appearing between them.
@@ -506,9 +506,11 @@ namespace llvm {
/// @}
char *getSecureLogFile() { return SecureLogFile; }
- raw_ostream *getSecureLog() { return SecureLog; }
+ raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
bool getSecureLogUsed() { return SecureLogUsed; }
- void setSecureLog(raw_ostream *Value) { SecureLog = Value; }
+ void setSecureLog(std::unique_ptr<raw_fd_ostream> Value) {
+ SecureLog = std::move(Value);
+ }
void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
void *allocate(unsigned Size, unsigned Align = 8) {
Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=255852&r1=255851&r2=255852&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Wed Dec 16 17:49:14 2015
@@ -63,9 +63,6 @@ MCContext::~MCContext() {
// NOTE: The symbols are all allocated out of a bump pointer allocator,
// we don't need to free them here.
-
- // If the stream for the .secure_log_unique directive was created free it.
- delete (raw_ostream *)SecureLog;
}
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp?rev=255852&r1=255851&r2=255852&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp Wed Dec 16 17:49:14 2015
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#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"
@@ -666,17 +667,16 @@ bool DarwinAsmParser::parseDirectiveSecu
"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.
More information about the llvm-commits
mailing list