r213439 - Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ".reset()"

David Blaikie dblaikie at gmail.com
Fri Jul 18 18:06:45 PDT 2014


Author: dblaikie
Date: Fri Jul 18 20:06:45 2014
New Revision: 213439

URL: http://llvm.org/viewvc/llvm-project?rev=213439&view=rev
Log:
Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ".reset()"

It's also possible to just write "= nullptr", but there's some question
of whether that's as readable, so I leave it up to authors to pick which
they prefer for now. If we want to discuss standardizing on one or the
other, we can do that at some point in the future.

Modified:
    cfe/trunk/include/clang/Basic/FileManager.h
    cfe/trunk/lib/Basic/FileManager.cpp
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
    cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
    cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=213439&r1=213438&r2=213439&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jul 18 20:06:45 2014
@@ -74,7 +74,7 @@ class FileEntry {
   friend class FileManager;
 
   void closeFile() const {
-    File.reset(nullptr); // rely on destructor to close File
+    File.reset(); // rely on destructor to close File
   }
 
   void operator=(const FileEntry &) LLVM_DELETED_FUNCTION;

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=213439&r1=213438&r2=213439&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Fri Jul 18 20:06:45 2014
@@ -100,7 +100,7 @@ void FileManager::removeStatCache(FileSy
 }
 
 void FileManager::clearStatCaches() {
-  StatCache.reset(nullptr);
+  StatCache.reset();
 }
 
 /// \brief Retrieve the directory that the given file name resides in.

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=213439&r1=213438&r2=213439&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jul 18 20:06:45 2014
@@ -627,8 +627,7 @@ private:
         CurrentToken->Type != TT_RegexLiteral &&
         CurrentToken->Type != TT_TrailingReturnArrow)
       CurrentToken->Type = TT_Unknown;
-    if (CurrentToken->Role)
-      CurrentToken->Role.reset(nullptr);
+    CurrentToken->Role.reset();
     CurrentToken->FakeLParens.clear();
     CurrentToken->FakeRParens = 0;
   }

Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=213439&r1=213438&r2=213439&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Fri Jul 18 20:06:45 2014
@@ -702,5 +702,5 @@ void SDiagsWriter::finish() {
   State->OS->write((char *)&State->Buffer.front(), State->Buffer.size());
   State->OS->flush();
 
-  State->OS.reset(nullptr);
+  State->OS.reset();
 }

Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=213439&r1=213438&r2=213439&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Fri Jul 18 20:06:45 2014
@@ -43,7 +43,7 @@ void TextDiagnosticPrinter::BeginSourceF
 }
 
 void TextDiagnosticPrinter::EndSourceFile() {
-  TextDiag.reset(nullptr);
+  TextDiag.reset();
 }
 
 /// \brief Print any diagnostic option information to a raw_ostream.

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=213439&r1=213438&r2=213439&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Fri Jul 18 20:06:45 2014
@@ -546,7 +546,7 @@ void AnalysisConsumer::HandleTranslation
   // FIXME: This should be replaced with something that doesn't rely on
   // side-effects in PathDiagnosticConsumer's destructor. This is required when
   // used with option -disable-free.
-  Mgr.reset(nullptr);
+  Mgr.reset();
 
   if (TUTotalTimer) TUTotalTimer->stopTimer();
 
@@ -712,7 +712,7 @@ class UbigraphViz : public ExplodedNode:
   VMap M;
 
 public:
-  UbigraphViz(raw_ostream *Out, StringRef Filename);
+  UbigraphViz(std::unique_ptr<raw_ostream> Out, StringRef Filename);
 
   ~UbigraphViz();
 
@@ -727,10 +727,9 @@ static ExplodedNode::Auditor* CreateUbiV
   llvm::sys::fs::createTemporaryFile("llvm_ubi", "", FD, P);
   llvm::errs() << "Writing '" << P.str() << "'.\n";
 
-  std::unique_ptr<llvm::raw_fd_ostream> Stream;
-  Stream.reset(new llvm::raw_fd_ostream(FD, true));
+  auto Stream = llvm::make_unique<llvm::raw_fd_ostream>(FD, true);
 
-  return new UbigraphViz(Stream.release(), P);
+  return new UbigraphViz(std::move(Stream), P);
 }
 
 void UbigraphViz::AddEdge(ExplodedNode *Src, ExplodedNode *Dst) {
@@ -767,8 +766,8 @@ void UbigraphViz::AddEdge(ExplodedNode *
        << ", ('arrow','true'), ('oriented', 'true'))\n";
 }
 
-UbigraphViz::UbigraphViz(raw_ostream *Out, StringRef Filename)
-  : Out(Out), Filename(Filename), Cntr(0) {
+UbigraphViz::UbigraphViz(std::unique_ptr<raw_ostream> Out, StringRef Filename)
+    : Out(std::move(Out)), Filename(Filename), Cntr(0) {
 
   *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
   *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"
@@ -776,7 +775,7 @@ UbigraphViz::UbigraphViz(raw_ostream *Ou
 }
 
 UbigraphViz::~UbigraphViz() {
-  Out.reset(nullptr);
+  Out.reset();
   llvm::errs() << "Running 'ubiviz' program... ";
   std::string ErrMsg;
   std::string Ubiviz = llvm::sys::FindProgramByName("ubiviz");





More information about the cfe-commits mailing list