Changeset View
Changeset View
Standalone View
Standalone View
analyzers/cppcheck/parameters.cpp
Show All 40 Lines | 40 | { | |||
---|---|---|---|---|---|
41 | foreach (auto child, parent->children()) { | 41 | foreach (auto child, parent->children()) { | ||
42 | if (child->type() == KDevelop::ProjectBaseItem::ProjectItemType::File) | 42 | if (child->type() == KDevelop::ProjectBaseItem::ProjectItemType::File) | ||
43 | continue; | 43 | continue; | ||
44 | 44 | | |||
45 | else if (child->type() == KDevelop::ProjectBaseItem::ProjectItemType::ExecutableTarget || | 45 | else if (child->type() == KDevelop::ProjectBaseItem::ProjectItemType::ExecutableTarget || | ||
46 | child->type() == KDevelop::ProjectBaseItem::ProjectItemType::LibraryTarget || | 46 | child->type() == KDevelop::ProjectBaseItem::ProjectItemType::LibraryTarget || | ||
47 | child->type() == KDevelop::ProjectBaseItem::ProjectItemType::Target) { | 47 | child->type() == KDevelop::ProjectBaseItem::ProjectItemType::Target) { | ||
48 | 48 | | |||
49 | foreach (auto dir, child->project()->buildSystemManager()->includeDirectories(child)) | 49 | if (auto buildSystemManager = child->project()->buildSystemManager()) { | ||
50 | foreach (auto dir, buildSystemManager->includeDirectories(child)) { | ||||
50 | includes.insert(dir); | 51 | includes.insert(dir); | ||
51 | } | 52 | } | ||
53 | } | ||||
54 | } | ||||
52 | 55 | | |||
53 | includesForItem(child, includes); | 56 | includesForItem(child, includes); | ||
54 | } | 57 | } | ||
55 | } | 58 | } | ||
56 | 59 | | |||
57 | QList<KDevelop::Path> includesForProject(KDevelop::IProject* project) | 60 | QList<KDevelop::Path> includesForProject(KDevelop::IProject* project) | ||
58 | { | 61 | { | ||
59 | QSet<KDevelop::Path> includesSet; | 62 | QSet<KDevelop::Path> includesSet; | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 70 | { | |||
102 | 105 | | |||
103 | useProjectIncludes = projectSettings.useProjectIncludes(); | 106 | useProjectIncludes = projectSettings.useProjectIncludes(); | ||
104 | useSystemIncludes = projectSettings.useSystemIncludes(); | 107 | useSystemIncludes = projectSettings.useSystemIncludes(); | ||
105 | ignoredIncludes = projectSettings.ignoredIncludes(); | 108 | ignoredIncludes = projectSettings.ignoredIncludes(); | ||
106 | 109 | | |||
107 | extraParameters = projectSettings.extraParameters(); | 110 | extraParameters = projectSettings.extraParameters(); | ||
108 | 111 | | |||
109 | m_projectRootPath = m_project->path(); | 112 | m_projectRootPath = m_project->path(); | ||
110 | m_projectBuildPath = m_project->buildSystemManager()->buildDirectory(m_project->projectItem()); | 113 | | ||
114 | if (auto buildSystemManager = m_project->buildSystemManager()) { | ||||
115 | m_projectBuildPath = buildSystemManager->buildDirectory(m_project->projectItem()); | ||||
116 | } | ||||
111 | m_includeDirectories = includesForProject(project); | 117 | m_includeDirectories = includesForProject(project); | ||
112 | } | 118 | } | ||
113 | 119 | | |||
114 | QStringList Parameters::commandLine() const | 120 | QStringList Parameters::commandLine() const | ||
115 | { | 121 | { | ||
116 | QString temp; | 122 | QString temp; | ||
117 | return commandLine(temp); | 123 | return commandLine(temp); | ||
118 | } | 124 | } | ||
119 | 125 | | |||
120 | QStringList Parameters::commandLine(QString& infoMessage) const | 126 | QStringList Parameters::commandLine(QString& infoMessage) const | ||
121 | { | 127 | { | ||
122 | static const auto mocHeaderRegex = QRegularExpression("#define\\s+Q_MOC_OUTPUT_REVISION\\s+(.+)"); | 128 | static const auto mocHeaderRegex = QRegularExpression("#define\\s+Q_MOC_OUTPUT_REVISION\\s+(.+)"); | ||
123 | static const auto mocParametersRegex = QRegularExpression("-DQ_MOC_OUTPUT_REVISION=\\d{2,}"); | 129 | static const auto mocParametersRegex = QRegularExpression("-DQ_MOC_OUTPUT_REVISION=\\d{2,}"); | ||
124 | 130 | | |||
125 | const QString mocMessage = i18n( | 131 | const QString mocMessage = i18n( | ||
126 | "It seems that this project uses Qt library. For correctly work of cppcheck " | 132 | "It seems that this project uses Qt library. For correctly work of cppcheck " | ||
127 | "the value for define Q_MOC_OUTPUT_REVISION must be set. Unfortunatly, the plugin is unable " | 133 | "the value for define Q_MOC_OUTPUT_REVISION must be set. Unfortunately, the plugin is unable " | ||
128 | "to find this value automatically - you should set it manually by adding " | 134 | "to find this value automatically - you should set it manually by adding " | ||
129 | "'-DQ_MOC_OUTPUT_REVISION=XX' to extra parameters. The 'XX' value can be found in any project's " | 135 | "'-DQ_MOC_OUTPUT_REVISION=XX' to extra parameters. The 'XX' value can be found in any project's " | ||
130 | "moc-generated file or in the <QtCore/qobjectdefs.h> header file."); | 136 | "moc-generated file or in the <QtCore/qobjectdefs.h> header file."); | ||
131 | 137 | | |||
132 | QStringList result; | 138 | QStringList result; | ||
133 | 139 | | |||
134 | result << executablePath; | 140 | result << executablePath; | ||
135 | result << QStringLiteral("--xml-version=2"); | 141 | result << QStringLiteral("--xml-version=2"); | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
193 | } | 199 | } | ||
194 | 200 | | |||
195 | if (!extraParameters.isEmpty()) | 201 | if (!extraParameters.isEmpty()) | ||
196 | result << KShell::splitArgs(applyPlaceholders(extraParameters)); | 202 | result << KShell::splitArgs(applyPlaceholders(extraParameters)); | ||
197 | 203 | | |||
198 | if (m_project && useProjectIncludes) { | 204 | if (m_project && useProjectIncludes) { | ||
199 | QList<KDevelop::Path> ignored; | 205 | QList<KDevelop::Path> ignored; | ||
200 | 206 | | |||
201 | foreach (QString element, applyPlaceholders(ignoredIncludes).split(';')) { | 207 | foreach (const QString& element, applyPlaceholders(ignoredIncludes).split(';')) { | ||
202 | if (!element.trimmed().isEmpty()) | 208 | if (!element.trimmed().isEmpty()) | ||
203 | ignored.append(KDevelop::Path(element)); | 209 | ignored.append(KDevelop::Path(element)); | ||
204 | } | 210 | } | ||
205 | 211 | | |||
206 | foreach (auto dir, m_includeDirectories) { | 212 | foreach (const auto& dir, m_includeDirectories) { | ||
207 | if (ignored.contains(dir)) | 213 | if (ignored.contains(dir)) | ||
208 | continue; | 214 | continue; | ||
209 | 215 | | |||
210 | else if (useSystemIncludes || | 216 | else if (useSystemIncludes || | ||
211 | dir == m_projectRootPath || m_projectRootPath.isParentOf(dir) || | 217 | dir == m_projectRootPath || m_projectRootPath.isParentOf(dir) || | ||
212 | dir == m_projectBuildPath || m_projectBuildPath.isParentOf(dir)) { | 218 | dir == m_projectBuildPath || m_projectBuildPath.isParentOf(dir)) { | ||
213 | 219 | | |||
214 | result << QStringLiteral("-I"); | 220 | result << QStringLiteral("-I"); | ||
Show All 28 Lines |