Commit afa85f42 authored by Kevin Funk's avatar Kevin Funk
Browse files

Clazy fixit: fix-fromCharPtrAllocations

parent 624bd403
......@@ -38,7 +38,7 @@ ProjectConfigPage::ProjectConfigPage(KDevelop::IPlugin* plugin, KDevelop::IProje
ui->setupUi(this);
ui->commandLine->setFontFamily("Monospace");
ui->commandLine->setFontFamily(QStringLiteral("Monospace"));
connect(this, &ProjectConfigPage::changed, this, &ProjectConfigPage::updateCommandLine);
connect(ui->commandLineFilter->lineEdit(), &QLineEdit::textChanged, this, &ProjectConfigPage::updateCommandLine);
......@@ -102,7 +102,7 @@ void ProjectConfigPage::updateCommandLine()
return;
}
commandLine.replace(" -", "\n-");
commandLine.replace(QLatin1String(" -"), QLatin1String("\n-"));
QString filterText = ui->commandLineFilter->lineEdit()->text();
if (filterText.isEmpty()) {
ui->commandLine->setText(commandLine);
......
......@@ -70,8 +70,8 @@ Job::~Job()
void Job::postProcessStdout(const QStringList& lines)
{
static const auto fileNameRegex = QRegularExpression("Checking ([^:]*)\\.{3}");
static const auto percentRegex = QRegularExpression("(\\d+)% done");
static const auto fileNameRegex = QRegularExpression(QStringLiteral("Checking ([^:]*)\\.{3}"));
static const auto percentRegex = QRegularExpression(QStringLiteral("(\\d+)% done"));
QRegularExpressionMatch match;
......@@ -98,7 +98,7 @@ void Job::postProcessStdout(const QStringList& lines)
void Job::postProcessStderr(const QStringList& lines)
{
static const auto xmlStartRegex = QRegularExpression("\\s*<");
static const auto xmlStartRegex = QRegularExpression(QStringLiteral("\\s*<"));
for (const QString & line : lines) {
// unfortunately sometime cppcheck send non-XML messages to stderr.
......@@ -122,7 +122,7 @@ void Job::postProcessStderr(const QStringList& lines)
problem->setSeverity(KDevelop::IProblem::Error);
problem->setDescription(line);
problem->setExplanation("Check your cppcheck settings");
problem->setExplanation(QStringLiteral("Check your cppcheck settings"));
m_problems = {problem};
emitProblems();
......
......@@ -126,8 +126,8 @@ QStringList Parameters::commandLine() const
QStringList Parameters::commandLine(QString& infoMessage) const
{
static const auto mocHeaderRegex = QRegularExpression("#define\\s+Q_MOC_OUTPUT_REVISION\\s+(.+)");
static const auto mocParametersRegex = QRegularExpression("-DQ_MOC_OUTPUT_REVISION=\\d{2,}");
static const auto mocHeaderRegex = QRegularExpression(QStringLiteral("#define\\s+Q_MOC_OUTPUT_REVISION\\s+(.+)"));
static const auto mocParametersRegex = QRegularExpression(QStringLiteral("-DQ_MOC_OUTPUT_REVISION=\\d{2,}"));
const QString mocMessage = i18n(
"It seems that this project uses Qt library. For correctly work of cppcheck "
......@@ -184,7 +184,7 @@ QStringList Parameters::commandLine(QString& infoMessage) const
bool qtUsed = false;
bool mocDefineFound = false;
foreach (auto dir, m_includeDirectories) {
if (dir.path().endsWith("QtCore")) {
if (dir.path().endsWith(QLatin1String("QtCore"))) {
qtUsed = true;
QFile qtHeader(dir.path() + QStringLiteral("/qobjectdefs.h"));
......@@ -252,8 +252,8 @@ QString Parameters::applyPlaceholders(const QString& text) const
QString result(text);
if (m_project) {
result.replace("%p", m_projectRootPath.toLocalFile());
result.replace("%b", m_projectBuildPath.toLocalFile());
result.replace(QLatin1String("%p"), m_projectRootPath.toLocalFile());
result.replace(QLatin1String("%b"), m_projectBuildPath.toLocalFile());
}
return result;
......
......@@ -52,13 +52,13 @@ namespace cppcheck
*/
QString verboseMessageToHtml( const QString & input )
{
QString output(QString("<html>%1</html>").arg(input.toHtmlEscaped()));
QString output(QStringLiteral("<html>%1</html>").arg(input.toHtmlEscaped()));
output.replace("\\012", "\n");
output.replace(QLatin1String("\\012"), QLatin1String("\n"));
if (output.count('\n') >= 2) {
output.replace(output.indexOf('\n'), 1, "<pre>" );
output.replace(output.lastIndexOf('\n'), 1, "</pre><br>" );
output.replace(output.indexOf('\n'), 1, QLatin1String("<pre>") );
output.replace(output.lastIndexOf('\n'), 1, QLatin1String("</pre><br>") );
}
return output;
......@@ -98,45 +98,45 @@ bool CppcheckParser::startElement()
else if (name() == "location") {
newState = Location;
if (attributes().hasAttribute("file") && attributes().hasAttribute("line")) {
QString errorFile = attributes().value("file").toString();
if (attributes().hasAttribute(QStringLiteral("file")) && attributes().hasAttribute(QStringLiteral("line"))) {
QString errorFile = attributes().value(QStringLiteral("file")).toString();
// Usually when "file0" attribute exists it associated with source and
// attribute "file" associated with header).
// But sometimes cppcheck produces errors with "file" and "file0" attributes
// both associated with same *source* file. In such cases attribute "file" contains
// only file name, without full path. Therefore we should use "file0" instead "file".
if (!QFile::exists(errorFile) && attributes().hasAttribute("file0")) {
errorFile = attributes().value("file0").toString();
if (!QFile::exists(errorFile) && attributes().hasAttribute(QStringLiteral("file0"))) {
errorFile = attributes().value(QStringLiteral("file0")).toString();
}
m_errorFiles += errorFile;
m_errorLines += attributes().value("line").toString().toInt();
m_errorLines += attributes().value(QStringLiteral("line")).toString().toInt();
}
}
else if (name() == "error") {
newState = Error;
m_errorSeverity = "unknown";
m_errorSeverity = QLatin1String("unknown");
m_errorInconclusive = false;
m_errorFiles.clear();
m_errorLines.clear();
m_errorMessage.clear();
m_errorVerboseMessage.clear();
if (attributes().hasAttribute("msg")) {
m_errorMessage = attributes().value("msg").toString();
if (attributes().hasAttribute(QStringLiteral("msg"))) {
m_errorMessage = attributes().value(QStringLiteral("msg")).toString();
}
if (attributes().hasAttribute("verbose")) {
m_errorVerboseMessage = verboseMessageToHtml(attributes().value("verbose").toString());
if (attributes().hasAttribute(QStringLiteral("verbose"))) {
m_errorVerboseMessage = verboseMessageToHtml(attributes().value(QStringLiteral("verbose")).toString());
}
if (attributes().hasAttribute("severity")) {
m_errorSeverity = attributes().value("severity").toString();
if (attributes().hasAttribute(QStringLiteral("severity"))) {
m_errorSeverity = attributes().value(QStringLiteral("severity")).toString();
}
if (attributes().hasAttribute("inconclusive")) {
if (attributes().hasAttribute(QStringLiteral("inconclusive"))) {
m_errorInconclusive = true;
}
}
......@@ -159,8 +159,8 @@ bool CppcheckParser::endElement(QVector<KDevelop::IProblem::Ptr>& problems)
switch (state) {
case CppCheck:
if (attributes().hasAttribute("version")) {
qCDebug(KDEV_CPPCHECK) << "Cppcheck report version: " << attributes().value("version");
if (attributes().hasAttribute(QStringLiteral("version"))) {
qCDebug(KDEV_CPPCHECK) << "Cppcheck report version: " << attributes().value(QStringLiteral("version"));
}
break;
......@@ -170,8 +170,8 @@ bool CppcheckParser::endElement(QVector<KDevelop::IProblem::Ptr>& problems)
case Error:
qCDebug(KDEV_CPPCHECK) << "CppcheckParser::endElement: new error elem: line: "
<< (m_errorLines.isEmpty() ? "?" : QString::number(m_errorLines.first()))
<< " at " << (m_errorFiles.isEmpty() ? "?" : m_errorFiles.first())
<< (m_errorLines.isEmpty() ? QStringLiteral("?") : QString::number(m_errorLines.first()))
<< " at " << (m_errorFiles.isEmpty() ? QStringLiteral("?") : m_errorFiles.first())
<< ", msg: " << m_errorMessage;
storeError(problems);
......@@ -263,11 +263,11 @@ KDevelop::IProblem::Ptr CppcheckParser::getProblem(int locationIdx) const
QStringList messagePrefix;
QString errorMessage(m_errorMessage);
if (m_errorSeverity == "error") {
if (m_errorSeverity == QLatin1String("error")) {
problem->setSeverity(KDevelop::IProblem::Error);
}
else if (m_errorSeverity == "warning") {
else if (m_errorSeverity == QLatin1String("warning")) {
problem->setSeverity(KDevelop::IProblem::Warning);
}
......@@ -278,11 +278,11 @@ KDevelop::IProblem::Ptr CppcheckParser::getProblem(int locationIdx) const
}
if (m_errorInconclusive) {
messagePrefix.push_back("inconclusive");
messagePrefix.push_back(QStringLiteral("inconclusive"));
}
if (!messagePrefix.isEmpty()) {
errorMessage = QString("(%1) %2").arg(messagePrefix.join(", ")).arg(m_errorMessage);
errorMessage = QStringLiteral("(%1) %2").arg(messagePrefix.join(QStringLiteral(", "))).arg(m_errorMessage);
}
problem->setDescription(errorMessage);
......
......@@ -49,27 +49,27 @@ namespace cppcheck
{
Plugin::Plugin(QObject* parent, const QVariantList&)
: IPlugin("kdevcppcheck", parent)
: IPlugin(QStringLiteral("kdevcppcheck"), parent)
, m_job(nullptr)
, m_currentProject(nullptr)
, m_model(new ProblemModel(this))
{
qCDebug(KDEV_CPPCHECK) << "setting cppcheck rc file";
setXMLFile("kdevcppcheck.rc");
setXMLFile(QStringLiteral("kdevcppcheck.rc"));
m_actionFile = new QAction(QIcon::fromTheme("cppcheck"), i18n("Cppcheck (Current File)"), this);
m_actionFile = new QAction(QIcon::fromTheme(QStringLiteral("cppcheck")), i18n("Cppcheck (Current File)"), this);
connect(m_actionFile, &QAction::triggered, [this](){
runCppcheck(false);
});
actionCollection()->addAction("cppcheck_file", m_actionFile);
actionCollection()->addAction(QStringLiteral("cppcheck_file"), m_actionFile);
m_actionProject = new QAction(QIcon::fromTheme("cppcheck"), i18n("Cppcheck (Current Project)"), this);
m_actionProject = new QAction(QIcon::fromTheme(QStringLiteral("cppcheck")), i18n("Cppcheck (Current Project)"), this);
connect(m_actionProject, &QAction::triggered, [this](){
runCppcheck(true);
});
actionCollection()->addAction("cppcheck_project", m_actionProject);
actionCollection()->addAction(QStringLiteral("cppcheck_project"), m_actionProject);
m_actionProjectItem = new QAction(QIcon::fromTheme("cppcheck"), i18n("Cppcheck"), this);
m_actionProjectItem = new QAction(QIcon::fromTheme(QStringLiteral("cppcheck")), i18n("Cppcheck"), this);
connect(core()->documentController(), &KDevelop::IDocumentController::documentClosed,
this, &Plugin::updateActions);
......@@ -175,7 +175,7 @@ void Plugin::runCppcheck(KDevelop::IProject* project, const QString& path)
connect(m_job, &Job::problemsDetected, m_model.data(), &ProblemModel::addProblems);
connect(m_job, &Job::finished, this, &Plugin::result);
core()->uiController()->registerStatus(new KDevelop::JobStatus(m_job, "Cppcheck"));
core()->uiController()->registerStatus(new KDevelop::JobStatus(m_job, QStringLiteral("Cppcheck")));
core()->runController()->registerJob(m_job);
if (params.hideOutputView) {
......
......@@ -140,7 +140,7 @@ void ProblemModel::reset(KDevelop::IProject* project, const QString& path)
QString tooltip = i18nc("@info:tooltip", "Re-Run Last Cppcheck Analysis");
if (m_project) {
tooltip += QString(" (%1)").arg(prettyPathName(m_path));
tooltip += QStringLiteral(" (%1)").arg(prettyPathName(m_path));
}
setFullUpdateTooltip(tooltip);
}
......
......@@ -112,7 +112,7 @@ Job::~Job()
QString Job::statusName() const
{
QString target = m_pid < 0 ? QFileInfo(m_analyzedExecutable).fileName()
: QString("PID: %1").arg(m_pid);
: QStringLiteral("PID: %1").arg(m_pid);
return i18n("Heaptrack Analysis (%1)", target);
}
......
......@@ -35,7 +35,7 @@ void KDevIDEExtension::init()
QString KDevIDEExtension::xmlFile()
{
return "kdevelopui.rc";
return QStringLiteral("kdevelopui.rc");
}
QString KDevIDEExtension::executableFilePath()
......@@ -51,7 +51,7 @@ KDevelop::AreaParams KDevIDEExtension::defaultArea()
QString KDevIDEExtension::projectFileExtension()
{
return "kdev4";
return QStringLiteral("kdev4");
}
QString KDevIDEExtension::projectFileDescription()
......
This diff is collapsed.
......@@ -41,7 +41,7 @@ void KDevelopSessionsEngine::init()
{
m_dirWatch = new KDirWatch( this );
const QStringList sessionDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "kdevelop/sessions", QStandardPaths::LocateDirectory );
const QStringList sessionDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kdevelop/sessions"), QStandardPaths::LocateDirectory );
for ( int i = 0; i < sessionDirs.count(); ++i )
m_dirWatch->addDir( sessionDirs[i], KDirWatch::WatchSubDirs );
......@@ -58,13 +58,13 @@ Plasma::Service *KDevelopSessionsEngine::serviceForSource(const QString &source)
QStringList findSessions()
{
QStringList sessionDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "kdevelop/sessions", QStandardPaths::LocateDirectory);
QStringList sessionDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kdevelop/sessions"), QStandardPaths::LocateDirectory);
QStringList sessionrcs;
Q_FOREACH(const QString& dir, sessionDirs) {
QDir d(dir);
Q_FOREACH(const QString& sessionDir, d.entryList(QDir::Dirs)) {
QDir sd(d.absoluteFilePath(sessionDir));
QString path(sd.filePath("sessionrc"));
QString path(sd.filePath(QStringLiteral("sessionrc")));
if(QFile::exists(path)) {
sessionrcs += path;
}
......@@ -108,8 +108,8 @@ void KDevelopSessionsEngine::updateSessions()
// Publish new session.
m_currentSessions.insert( session.hash, session );
setData( session.hash, "sessionName", session.name );
setData( session.hash, "sessionString", session.description );
setData( session.hash, QStringLiteral("sessionName"), session.name );
setData( session.hash, QStringLiteral("sessionString"), session.description );
}
else
{
......@@ -123,14 +123,14 @@ void KDevelopSessionsEngine::updateSessions()
{
oldSession.name = session.name;
modified = true;
setData( session.hash, "sessionName", session.name );
setData( session.hash, QStringLiteral("sessionName"), session.name );
}
if ( session.description != oldSession.description )
{
oldSession.description = session.description;
modified = true;
setData( session.hash, "sessionString", session.description );
setData( session.hash, QStringLiteral("sessionString"), session.description );
}
if ( modified )
......
......@@ -24,7 +24,7 @@
KDevelopSessionsService::KDevelopSessionsService(QObject* parent, const QString& sessionName)
: Plasma::Service(parent)
{
setName("org.kde.plasma.dataengine.kdevelopsessions");
setName(QStringLiteral("org.kde.plasma.dataengine.kdevelopsessions"));
setDestination(sessionName);
}
......@@ -40,11 +40,11 @@ SessionJob::SessionJob(KDevelopSessionsService *service, const QString &operatio
void SessionJob::start()
{
if (operationName() == "open")
if (operationName() == QLatin1String("open"))
{
QStringList args;
args << "--open-session" << destination();
KToolInvocation::kdeinitExec("kdevelop", args);
args << QStringLiteral("--open-session") << destination();
KToolInvocation::kdeinitExec(QStringLiteral("kdevelop"), args);
setResult(true);
}
......
......@@ -340,7 +340,7 @@ namespace KDevMI { namespace MI {
inline PromptRecord() { Record::kind = Prompt; }
QString toString() const override
{ return "(prompt)\n"; }
{ return QStringLiteral("(prompt)\n"); }
};
struct StreamRecord : public Record
......
......@@ -70,9 +70,9 @@ QString MICommand::initialString() const
result += miCommand();
if (m_thread != -1)
result = result + QString(" --thread %1").arg(m_thread);
result = result + QStringLiteral(" --thread %1").arg(m_thread);
if (m_frame != -1)
result = result + QString(" --frame %1").arg(m_frame);
result = result + QStringLiteral(" --frame %1").arg(m_frame);
if (!command_.isEmpty())
result += ' ' + command_;
......@@ -150,268 +150,268 @@ QString MICommand::miCommand() const
switch (type()) {
case NonMI:
command = "";
command = QLatin1String("");
break;
case BreakAfter:
command = "break-after";//"ignore"
command = QLatin1String("break-after");//"ignore"
break;
case BreakCommands:
command = "break-commands";
command = QLatin1String("break-commands");
break;
case BreakCondition:
command = "break-condition";//"cond"
command = QLatin1String("break-condition");//"cond"
break;
case BreakDelete:
command = "break-delete";//"delete breakpoint"
command = QLatin1String("break-delete");//"delete breakpoint"
break;
case BreakDisable:
command = "break-disable";//"disable breakpoint"
command = QLatin1String("break-disable");//"disable breakpoint"
break;
case BreakEnable:
command = "break-enable";//"enable breakpoint"
command = QLatin1String("break-enable");//"enable breakpoint"
break;
case BreakInfo:
command = "break-info";//"info break"
command = QLatin1String("break-info");//"info break"
break;
case BreakInsert:
command = "break-insert -f";
command = QLatin1String("break-insert -f");
break;
case BreakList:
command = "break-list";//"info break"
command = QLatin1String("break-list");//"info break"
break;
case BreakWatch:
command = "break-watch";
command = QLatin1String("break-watch");
break;
case DataDisassemble:
command = "data-disassemble";
command = QLatin1String("data-disassemble");
break;
case DataEvaluateExpression:
command = "data-evaluate-expression";
command = QLatin1String("data-evaluate-expression");
break;
case DataListChangedRegisters:
command = "data-list-changed-registers";
command = QLatin1String("data-list-changed-registers");
break;
case DataListRegisterNames:
command = "data-list-register-names";
command = QLatin1String("data-list-register-names");
break;
case DataListRegisterValues:
command = "data-list-register-values";
command = QLatin1String("data-list-register-values");
break;
case DataReadMemory:
command = "data-read-memory";
command = QLatin1String("data-read-memory");
break;
case DataWriteMemory:
command = "data-write-memory";
command = QLatin1String("data-write-memory");
break;
case DataWriteRegisterVariables:
command = "data-write-register-values";
command = QLatin1String("data-write-register-values");
break;
case EnablePrettyPrinting:
command = "enable-pretty-printing";
command = QLatin1String("enable-pretty-printing");
break;
case EnableTimings:
command = "enable-timings";
command = QLatin1String("enable-timings");
break;
case EnvironmentCd:
command = "environment-cd";
command = QLatin1String("environment-cd");
break;
case EnvironmentDirectory:
command = "environment-directory";
command = QLatin1String("environment-directory");
break;
case EnvironmentPath:
command = "environment-path";
command = QLatin1String("environment-path");
break;
case EnvironmentPwd:
command = "environment-pwd";
command = QLatin1String("environment-pwd");
break;
case ExecAbort:
command = "exec-abort";
command = QLatin1String("exec-abort");
break;
case ExecArguments:
command = "exec-arguments";//"set args"
command = QLatin1String("exec-arguments");//"set args"
break;
case ExecContinue:
command = "exec-continue";
command = QLatin1String("exec-continue");
break;
case ExecFinish:
command = "exec-finish";
command = QLatin1String("exec-finish");
break;
case ExecInterrupt:
command = "exec-interrupt";
command = QLatin1String("exec-interrupt");
break;
case ExecNext:
command = "exec-next";
command = QLatin1String("exec-next");
break;
case ExecNextInstruction:
command = "exec-next-instruction";
command = QLatin1String("exec-next-instruction");
break;
case ExecRun:
command = "exec-run";
command = QLatin1String("exec-run");
break;
case ExecStep:
command = "exec-step";
command = QLatin1String("exec-step");
break;
case ExecStepInstruction:
command = "exec-step-instruction";
command = QLatin1String("exec-step-instruction");
break;
case ExecUntil:
command = "exec-until";
command = QLatin1String("exec-until");
break;
case FileExecAndSymbols:
command = "file-exec-and-symbols";//"file"
command = QLatin1String("file-exec-and-symbols");//"file"
break;
case FileExecFile:
command = "file-exec-file";//"exec-file"
command = QLatin1String("file-exec-file");//"exec-file"
break;
case FileListExecSourceFile:
command = "file-list-exec-source-file";
command = QLatin1String("file-list-exec-source-file");
break;
case FileListExecSourceFiles:
command = "file-list-exec-source-files";
command = QLatin1String("file-list-exec-source-files");
break;
case FileSymbolFile:
command = "file-symbol-file";//"symbol-file"
command = QLatin1String("file-symbol-file");//"symbol-file"
break;
case GdbExit:
command = "gdb-exit";
command = QLatin1String("gdb-exit");
break;
case GdbSet:
command = "gdb-set";//"set"
command = QLatin1String("gdb-set");//"set"
break;
case GdbShow:
command = "gdb-show";//"show"
command = QLatin1String("gdb-show");//"show"
break;
case GdbVersion:
command = "gdb-version";//"show version"
command = QLatin1String("gdb-version");//"show version"
break;
case InferiorTtySet:
command = "inferior-tty-set";
command = QLatin1String("inferior-tty-set");
break;
case InferiorTtyShow:
command = "inferior-tty-show";
command = QLatin1String("inferior-tty-show");
break;
case InterpreterExec:
command = "interpreter-exec";
command = QLatin1String("interpreter-exec");
break;
case ListFeatures:
command = "list-features";
command = QLatin1String("list-features");
break;