Skip to content

Commit 5b7f7cd

Browse files
committed
Address review comments
1 parent 94b34fb commit 5b7f7cd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

generator/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
#include <QTextStream>
5757
#include <QRegularExpression>
5858

59+
#include <memory>
60+
5961
void displayHelp(GeneratorSet *generatorSet);
6062

6163
namespace
@@ -129,7 +131,7 @@ namespace
129131
{
130132
simplecpp::DUI dui; // settings
131133

132-
foreach(QString include, getIncludeDirectories(commandLineIncludes)) {
134+
for(QString include : getIncludeDirectories(commandLineIncludes)) {
133135
dui.includePaths.push_back(QDir::toNativeSeparators(include).toStdString());
134136
}
135137
dui.defines.push_back("__cplusplus=1");
@@ -147,17 +149,16 @@ namespace
147149
QByteArray ba = file.readAll();
148150
file.close();
149151

150-
// Perform preprocessing
152+
// Perform preprocessing (code originally taken from simplecpp/main.cpp and modified)
151153
simplecpp::OutputList outputList;
152154
std::vector<std::string> files;
153-
simplecpp::TokenList* rawtokens = new simplecpp::TokenList(ba.constData(), ba.size(), files, {}, &outputList);
155+
std::unique_ptr<simplecpp::TokenList> rawtokens(new simplecpp::TokenList(ba.constData(), ba.size(), files, {}, &outputList));
154156
rawtokens->removeComments();
155157
simplecpp::TokenList outputTokens(files);
156158
std::map<std::string, simplecpp::TokenList*> filedata;
157159
simplecpp::preprocess(outputTokens, *rawtokens, files, filedata, dui, &outputList);
158160
simplecpp::cleanup(filedata);
159-
delete rawtokens;
160-
rawtokens = nullptr;
161+
rawtokens.reset();
161162

162163
for (const simplecpp::Output& output : outputList) {
163164
if (output.type == simplecpp::Output::MISSING_HEADER) {

0 commit comments

Comments
 (0)