MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / runAddonsAndTools

Method runAddonsAndTools

gui/checkthread.cpp:191–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void CheckThread::runAddonsAndTools(const Settings& settings, const FileSettings *fileSettings, const QString &fileName)
192{
193 for (const QString& addon : utils::as_const(mAddonsAndTools)) {
194 if (addon == CLANG_ANALYZER || addon == CLANG_TIDY) {
195 if (!fileSettings)
196 continue;
197
198 if (!fileSettings->cfg.empty() && !startsWith(fileSettings->cfg,"Debug"))
199 continue;
200
201 QStringList args;
202 for (auto incIt = fileSettings->includePaths.cbegin(); incIt != fileSettings->includePaths.cend(); ++incIt)
203 args << ("-I" + QString::fromStdString(*incIt));
204 for (auto i = fileSettings->systemIncludePaths.cbegin(); i != fileSettings->systemIncludePaths.cend(); ++i)
205 args << "-isystem" << QString::fromStdString(*i);
206 for (const QString& def : QString::fromStdString(fileSettings->defines).split(";")) {
207 args << ("-D" + def);
208 }
209 for (const std::string& U : fileSettings->undefs) {
210 args << QString::fromStdString("-U" + U);
211 }
212
213 const QString clangPath = CheckThread::clangTidyCmd();
214 if (!clangPath.isEmpty()) {
215 QDir dir(clangPath + "/../lib/clang");
216 for (const QString& ver : dir.entryList()) {
217 QString includePath = dir.absolutePath() + '/' + ver + "/include";
218 if (ver[0] != '.' && QDir(includePath).exists()) {
219 args << "-isystem" << includePath;
220 break;
221 }
222 }
223 }
224
225#ifdef Q_OS_WIN
226 // To create compile_commands.json in windows see:
227 // https://bitsmaker.gitlab.io/post/clang-tidy-from-vs2015/
228
229 for (QString includePath : mClangIncludePaths) {
230 if (!includePath.isEmpty()) {
231 includePath.replace("\\", "/");
232 args << "-isystem" << includePath.trimmed();
233 }
234 }
235
236 args << "-U__STDC__" << "-fno-ms-compatibility";
237#endif
238
239 if (!fileSettings->standard.empty())
240 args << ("-std=" + QString::fromStdString(fileSettings->standard));
241 else {
242 // TODO: pass C or C++ standard based on file type
243 const std::string std = settings.standards.getCPP();
244 if (!std.empty()) {
245 args << ("-std=" + QString::fromStdString(std));
246 }
247 }
248

Callers

nothing calls this directly

Calls 11

isEmptyMethod · 0.80
fsFileIdMethod · 0.80
readAllMethod · 0.80
startsWithFunction · 0.50
emptyMethod · 0.45
existsMethod · 0.45
replaceMethod · 0.45
getCPPMethod · 0.45
openMethod · 0.45
closeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected