From 1614d5cef41e00b329593b4ceb35525b0e1d84af Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sat, 19 Jul 2014 01:06:45 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213439 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/FileManager.h | 2 +- lib/Basic/FileManager.cpp | 2 +- lib/Format/TokenAnnotator.cpp | 3 +-- lib/Frontend/SerializedDiagnosticPrinter.cpp | 2 +- lib/Frontend/TextDiagnosticPrinter.cpp | 2 +- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 15 +++++++-------- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h index dd1ad0da1d..0ad53c4df5 100644 --- a/include/clang/Basic/FileManager.h +++ b/include/clang/Basic/FileManager.h @@ -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; diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 22beed7dcc..94210320bf 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -100,7 +100,7 @@ void FileManager::removeStatCache(FileSystemStatCache *statCache) { } void FileManager::clearStatCaches() { - StatCache.reset(nullptr); + StatCache.reset(); } /// \brief Retrieve the directory that the given file name resides in. diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 41d30d1fce..017afe1a37 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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; } diff --git a/lib/Frontend/SerializedDiagnosticPrinter.cpp b/lib/Frontend/SerializedDiagnosticPrinter.cpp index db89f25ebc..29c58a8ac3 100644 --- a/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -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(); } diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 6271509d36..66b46b7814 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -43,7 +43,7 @@ void TextDiagnosticPrinter::BeginSourceFile(const LangOptions &LO, } void TextDiagnosticPrinter::EndSourceFile() { - TextDiag.reset(nullptr); + TextDiag.reset(); } /// \brief Print any diagnostic option information to a raw_ostream. diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 12e514b322..f0dd274235 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -546,7 +546,7 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { // 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::Auditor { VMap M; public: - UbigraphViz(raw_ostream *Out, StringRef Filename); + UbigraphViz(std::unique_ptr Out, StringRef Filename); ~UbigraphViz(); @@ -727,10 +727,9 @@ static ExplodedNode::Auditor* CreateUbiViz() { llvm::sys::fs::createTemporaryFile("llvm_ubi", "", FD, P); llvm::errs() << "Writing '" << P.str() << "'.\n"; - std::unique_ptr Stream; - Stream.reset(new llvm::raw_fd_ostream(FD, true)); + auto Stream = llvm::make_unique(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 *Src, ExplodedNode *Dst) { << ", ('arrow','true'), ('oriented', 'true'))\n"; } -UbigraphViz::UbigraphViz(raw_ostream *Out, StringRef Filename) - : Out(Out), Filename(Filename), Cntr(0) { +UbigraphViz::UbigraphViz(std::unique_ptr 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 *Out, StringRef Filename) } UbigraphViz::~UbigraphViz() { - Out.reset(nullptr); + Out.reset(); llvm::errs() << "Running 'ubiviz' program... "; std::string ErrMsg; std::string Ubiviz = llvm::sys::FindProgramByName("ubiviz"); -- 2.40.0