Commit 3caf1a7a authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Enable modernize-make-shared and modernize-make-unique

parent 2ad55c01
Pipeline #84577 passed with stages
in 20 minutes and 1 second
...@@ -40,7 +40,7 @@ build_clang_libcpp: ...@@ -40,7 +40,7 @@ build_clang_libcpp:
script: script:
- git clone --branch ${CI_COMMIT_REF_NAME} --depth 1 ${TEST_DATA_URL} test-data || git clone --depth 1 ${UPSTREAM_TEST_DATA_URL} test-data - git clone --branch ${CI_COMMIT_REF_NAME} --depth 1 ${TEST_DATA_URL} test-data || git clone --depth 1 ${UPSTREAM_TEST_DATA_URL} test-data
- mkdir -p build && cd build - mkdir -p build && cd build
- CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DTESTDATADIR=$PWD/../test-data -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=-*,performance-*,,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-deprecated-headers,-bugprone-narrowing-conversions,-bugprone-macro-parentheses,-bugprone-suspicious-string-compare,-bugprone-incorrect-roundings,-bugprone-undefined-memory-manipulation;-warnings-as-errors=*" .. - CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DTESTDATADIR=$PWD/../test-data -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=-*,performance-*,,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-deprecated-headers,modernize-make-unique,modernize-make-shared,-bugprone-narrowing-conversions,-bugprone-macro-parentheses,-bugprone-suspicious-string-compare,-bugprone-incorrect-roundings,-bugprone-undefined-memory-manipulation;-warnings-as-errors=*" ..
- ninja - ninja
- ctest --output-on-failure - ctest --output-on-failure
......
...@@ -367,21 +367,21 @@ bool image::save(const std::string &file_name, const std::string &out_format, in ...@@ -367,21 +367,21 @@ bool image::save(const std::string &file_name, const std::string &out_format, in
} }
#if defined(ENABLE_LIBPNG) #if defined(ENABLE_LIBPNG)
else if (fmt == "png") { else if (fmt == "png") {
w.reset(new PNGWriter()); w = std::make_unique<PNGWriter>();
} }
#endif #endif
#if defined(ENABLE_LIBJPEG) #if defined(ENABLE_LIBJPEG)
else if (fmt == "jpeg" || fmt == "jpg") { else if (fmt == "jpeg" || fmt == "jpg") {
w.reset(new JpegWriter()); w = std::make_unique<JpegWriter>();
} }
#endif #endif
#if defined(ENABLE_LIBTIFF) #if defined(ENABLE_LIBTIFF)
else if (fmt == "tiff") { else if (fmt == "tiff") {
w.reset(new TiffWriter()); w = std::make_unique<TiffWriter>();
} }
#endif #endif
else if (fmt == "pnm") { else if (fmt == "pnm") {
w.reset(new NetPBMWriter(pnm_format(d->format))); w = std::make_unique<NetPBMWriter>(pnm_format(d->format));
} }
if (!w.get()) { if (!w.get()) {
return false; return false;
......
...@@ -4463,7 +4463,7 @@ void Gfx::doImage(Object *ref, Stream *str, bool inlineImg) { ...@@ -4463,7 +4463,7 @@ void Gfx::doImage(Object *ref, Stream *str, bool inlineImg) {
if (obj1.isNull()) { if (obj1.isNull()) {
obj1 = maskDict->lookup("D"); obj1 = maskDict->lookup("D");
} }
maskColorMap.reset(new GfxImageColorMap(maskBits, &obj1, maskColorSpace)); maskColorMap = std::make_unique<GfxImageColorMap>(maskBits, &obj1, maskColorSpace);
if (!maskColorMap->isOk()) { if (!maskColorMap->isOk()) {
goto err1; goto err1;
} }
......
...@@ -183,7 +183,7 @@ void OutputDev::opiEnd(GfxState *state, Dict *opiDict) { ...@@ -183,7 +183,7 @@ void OutputDev::opiEnd(GfxState *state, Dict *opiDict) {
#endif #endif
void OutputDev::startProfile() { void OutputDev::startProfile() {
profileHash.reset(new std::unordered_map<std::string, ProfileData>); profileHash = std::make_unique<std::unordered_map<std::string, ProfileData>>();
} }
std::unique_ptr<std::unordered_map<std::string, ProfileData>> OutputDev::endProfile() { std::unique_ptr<std::unordered_map<std::string, ProfileData>> OutputDev::endProfile() {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
// under GPL version 2 or later // under GPL version 2 or later
// //
// Copyright (C) 2006 Dom Lachowicz <cinamod@hotmail.com> // Copyright (C) 2006 Dom Lachowicz <cinamod@hotmail.com>
// Copyright (C) 2007-2010, 2012, 2016-2018 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007-2010, 2012, 2016-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2011 Vittal Aithal <vittal.aithal@cognidox.com> // Copyright (C) 2011 Vittal Aithal <vittal.aithal@cognidox.com>
// Copyright (C) 2012, 2013, 2016-2018 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012, 2013, 2016-2018 Adrian Johnson <ajohnson@redneon.com>
...@@ -447,33 +447,33 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) { ...@@ -447,33 +447,33 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) {
{ {
case subtypePDFA: case subtypePDFA:
printInfoString(info.getDict(), "GTS_PDFA1Version", "PDF subtype: ", uMap); printInfoString(info.getDict(), "GTS_PDFA1Version", "PDF subtype: ", uMap);
typeExp.reset( new GooString("ISO 19005 - Electronic document file format for long-term preservation (PDF/A)") ); typeExp = std::make_unique<GooString>("ISO 19005 - Electronic document file format for long-term preservation (PDF/A)");
standard.reset( new GooString("ISO 19005") ); standard = std::make_unique<GooString>("ISO 19005");
abbr.reset( new GooString("PDF/A") ); abbr = std::make_unique<GooString>("PDF/A");
break; break;
case subtypePDFE: case subtypePDFE:
printInfoString(info.getDict(), "GTS_PDFEVersion", "PDF subtype: ", uMap); printInfoString(info.getDict(), "GTS_PDFEVersion", "PDF subtype: ", uMap);
typeExp.reset( new GooString("ISO 24517 - Engineering document format using PDF (PDF/E)") ); typeExp = std::make_unique<GooString>("ISO 24517 - Engineering document format using PDF (PDF/E)");
standard.reset( new GooString("ISO 24517") ); standard = std::make_unique<GooString>("ISO 24517");
abbr.reset( new GooString("PDF/E") ); abbr = std::make_unique<GooString>("PDF/E");
break; break;
case subtypePDFUA: case subtypePDFUA:
printInfoString(info.getDict(), "GTS_PDFUAVersion", "PDF subtype: ", uMap); printInfoString(info.getDict(), "GTS_PDFUAVersion", "PDF subtype: ", uMap);
typeExp.reset( new GooString("ISO 14289 - Electronic document file format enhancement for accessibility (PDF/UA)") ); typeExp = std::make_unique<GooString>("ISO 14289 - Electronic document file format enhancement for accessibility (PDF/UA)");
standard.reset( new GooString("ISO 14289") ); standard = std::make_unique<GooString>("ISO 14289");
abbr.reset( new GooString("PDF/UA") ); abbr = std::make_unique<GooString>("PDF/UA");
break; break;
case subtypePDFVT: case subtypePDFVT:
printInfoString(info.getDict(), "GTS_PDFVTVersion", "PDF subtype: ", uMap); printInfoString(info.getDict(), "GTS_PDFVTVersion", "PDF subtype: ", uMap);
typeExp.reset( new GooString("ISO 16612 - Electronic document file format for variable data exchange (PDF/VT)") ); typeExp = std::make_unique<GooString>("ISO 16612 - Electronic document file format for variable data exchange (PDF/VT)");
standard.reset( new GooString("ISO 16612") ); standard = std::make_unique<GooString>("ISO 16612");
abbr.reset( new GooString("PDF/VT") ); abbr = std::make_unique<GooString>("PDF/VT");
break; break;
case subtypePDFX: case subtypePDFX:
printInfoString(info.getDict(), "GTS_PDFXVersion", "PDF subtype: ", uMap); printInfoString(info.getDict(), "GTS_PDFXVersion", "PDF subtype: ", uMap);
typeExp.reset( new GooString("ISO 15930 - Electronic document file format for prepress digital data exchange (PDF/X)") ); typeExp = std::make_unique<GooString>("ISO 15930 - Electronic document file format for prepress digital data exchange (PDF/X)");
standard.reset( new GooString("ISO 15930") ); standard = std::make_unique<GooString>("ISO 15930");
abbr.reset( new GooString("PDF/X") ); abbr = std::make_unique<GooString>("PDF/X");
break; break;
case subtypeNone: case subtypeNone:
case subtypeNull: case subtypeNull:
...@@ -537,13 +537,13 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) { ...@@ -537,13 +537,13 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) {
case subtypePDFA: case subtypePDFA:
switch (subpart) { switch (subpart) {
case subtypePart1: case subtypePart1:
part.reset( new GooString("Use of PDF 1.4") ); part = std::make_unique<GooString>("Use of PDF 1.4");
break; break;
case subtypePart2: case subtypePart2:
part.reset( new GooString("Use of ISO 32000-1") ); part = std::make_unique<GooString>("Use of ISO 32000-1");
break; break;
case subtypePart3: case subtypePart3:
part.reset( new GooString("Use of ISO 32000-1 with support for embedded files") ); part = std::make_unique<GooString>("Use of ISO 32000-1 with support for embedded files");
break; break;
default: default:
break; break;
...@@ -552,7 +552,7 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) { ...@@ -552,7 +552,7 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) {
case subtypePDFE: case subtypePDFE:
switch (subpart) { switch (subpart) {
case subtypePart1: case subtypePart1:
part.reset( new GooString("Use of PDF 1.6") ); part = std::make_unique<GooString>("Use of PDF 1.6");
break; break;
default: default:
break; break;
...@@ -561,13 +561,13 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) { ...@@ -561,13 +561,13 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) {
case subtypePDFUA: case subtypePDFUA:
switch (subpart) { switch (subpart) {
case subtypePart1: case subtypePart1:
part.reset( new GooString("Use of ISO 32000-1") ); part = std::make_unique<GooString>("Use of ISO 32000-1");
break; break;
case subtypePart2: case subtypePart2:
part.reset( new GooString("Use of ISO 32000-2") ); part = std::make_unique<GooString>("Use of ISO 32000-2");
break; break;
case subtypePart3: case subtypePart3:
part.reset( new GooString("Use of ISO 32000-1 with support for embedded files") ); part = std::make_unique<GooString>("Use of ISO 32000-1 with support for embedded files");
break; break;
default: default:
break; break;
...@@ -576,13 +576,13 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) { ...@@ -576,13 +576,13 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) {
case subtypePDFVT: case subtypePDFVT:
switch (subpart) { switch (subpart) {
case subtypePart1: case subtypePart1:
part.reset( new GooString("Using PPML 2.1 and PDF 1.4") ); part = std::make_unique<GooString>("Using PPML 2.1 and PDF 1.4");
break; break;
case subtypePart2: case subtypePart2:
part.reset( new GooString("Using PDF/X-4 and PDF/X-5 (PDF/VT-1 and PDF/VT-2)") ); part = std::make_unique<GooString>("Using PDF/X-4 and PDF/X-5 (PDF/VT-1 and PDF/VT-2)");
break; break;
case subtypePart3: case subtypePart3:
part.reset( new GooString("Using PDF/X-6 (PDF/VT-3)") ); part = std::make_unique<GooString>("Using PDF/X-6 (PDF/VT-3)");
break; break;
default: default:
break; break;
...@@ -591,25 +591,25 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) { ...@@ -591,25 +591,25 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) {
case subtypePDFX: case subtypePDFX:
switch (subpart) { switch (subpart) {
case subtypePart1: case subtypePart1:
part.reset( new GooString("Complete exchange using CMYK data (PDF/X-1 and PDF/X-1a)") ); part = std::make_unique<GooString>("Complete exchange using CMYK data (PDF/X-1 and PDF/X-1a)");
break; break;
case subtypePart3: case subtypePart3:
part.reset( new GooString("Complete exchange suitable for colour-managed workflows (PDF/X-3)") ); part = std::make_unique<GooString>("Complete exchange suitable for colour-managed workflows (PDF/X-3)");
break; break;
case subtypePart4: case subtypePart4:
part.reset( new GooString("Complete exchange of CMYK and spot colour printing data using PDF 1.4 (PDF/X-1a)") ); part = std::make_unique<GooString>("Complete exchange of CMYK and spot colour printing data using PDF 1.4 (PDF/X-1a)");
break; break;
case subtypePart5: case subtypePart5:
part.reset( new GooString("Partial exchange of printing data using PDF 1.4 (PDF/X-2) [Withdrawn]") ); part = std::make_unique<GooString>("Partial exchange of printing data using PDF 1.4 (PDF/X-2) [Withdrawn]");
break; break;
case subtypePart6: case subtypePart6:
part.reset( new GooString("Complete exchange of printing data suitable for colour-managed workflows using PDF 1.4 (PDF/X-3)") ); part = std::make_unique<GooString>("Complete exchange of printing data suitable for colour-managed workflows using PDF 1.4 (PDF/X-3)");
break; break;
case subtypePart7: case subtypePart7:
part.reset( new GooString("Complete exchange of printing data (PDF/X-4) and partial exchange of printing data with external profile reference (PDF/X-4p) using PDF 1.6") ); part = std::make_unique<GooString>("Complete exchange of printing data (PDF/X-4) and partial exchange of printing data with external profile reference (PDF/X-4p) using PDF 1.6");
break; break;
case subtypePart8: case subtypePart8:
part.reset( new GooString("Partial exchange of printing data using PDF 1.6 (PDF/X-5)") ); part = std::make_unique<GooString>("Partial exchange of printing data using PDF 1.6 (PDF/X-5)");
break; break;
default: default:
break; break;
...@@ -623,25 +623,25 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) { ...@@ -623,25 +623,25 @@ static void printPdfSubtype(PDFDoc *doc, UnicodeMap *uMap) {
switch (doc->getPDFSubtypeConformance()) switch (doc->getPDFSubtypeConformance())
{ {
case subtypeConfA: case subtypeConfA:
confExp.reset( new GooString("Level A, Accessible") ); confExp = std::make_unique<GooString>("Level A, Accessible");
break; break;
case subtypeConfB: case subtypeConfB:
confExp.reset( new GooString("Level B, Basic") ); confExp = std::make_unique<GooString>("Level B, Basic");
break; break;
case subtypeConfG: case subtypeConfG:
confExp.reset( new GooString("Level G, External graphical content") ); confExp = std::make_unique<GooString>("Level G, External graphical content");
break; break;
case subtypeConfN: case subtypeConfN:
confExp.reset( new GooString("Level N, External ICC profile") ); confExp = std::make_unique<GooString>("Level N, External ICC profile");
break; break;
case subtypeConfP: case subtypeConfP:
confExp.reset( new GooString("Level P, Embedded ICC profile") ); confExp = std::make_unique<GooString>("Level P, Embedded ICC profile");
break; break;
case subtypeConfPG: case subtypeConfPG:
confExp.reset( new GooString("Level PG, Embedded ICC profile and external graphical content") ); confExp = std::make_unique<GooString>("Level PG, Embedded ICC profile and external graphical content");
break; break;
case subtypeConfU: case subtypeConfU:
confExp.reset( new GooString("Level U, Unicode support") ); confExp = std::make_unique<GooString>("Level U, Unicode support");
break; break;
case subtypeConfNone: case subtypeConfNone:
case subtypeConfNull: case subtypeConfNull:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment