Enable ClangTidy check modernize-make-unique.
The majority of existing call sites were automatically updated using
clang-tidy -fix. A small handful required a manual update,
e.g. CppCodeGen.
This check is a bit lenient, and in particular will not flag cases like
`std::unique_ptr<Base>(new Derived())` which is still pretty common
throughout our codebase. This CL does not attempt to replace all the
cases that ClangTidy does not flag.
Change-Id: I5eba48ef880e25d22de80f321a68c389ba769e36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307459
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 5342d69..101d71c 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -7,6 +7,8 @@
#include "src/sksl/SkSLCompiler.h"
+#include <memory>
+
#include "src/sksl/SkSLByteCodeGenerator.h"
#include "src/sksl/SkSLCFGGenerator.h"
#include "src/sksl/SkSLCPPCodeGenerator.h"
@@ -1602,14 +1604,14 @@
std::unique_ptr<String> textPtr(new String(std::move(text)));
fSource = textPtr.get();
fIRGenerator->convertProgram(kind, textPtr->c_str(), textPtr->size(), &elements);
- auto result = std::unique_ptr<Program>(new Program(kind,
- std::move(textPtr),
- settings,
- fContext,
- inherited,
- std::move(elements),
- fIRGenerator->fSymbolTable,
- fIRGenerator->fInputs));
+ auto result = std::make_unique<Program>(kind,
+ std::move(textPtr),
+ settings,
+ fContext,
+ inherited,
+ std::move(elements),
+ fIRGenerator->fSymbolTable,
+ fIRGenerator->fInputs);
if (fErrorCount) {
return nullptr;
}