Index: plugins/clazy/jobparameters.cpp =================================================================== --- plugins/clazy/jobparameters.cpp +++ plugins/clazy/jobparameters.cpp @@ -142,6 +142,7 @@ Q_ASSERT(project); auto projectRootPath = project->path().toLocalFile(); + auto projectCanonicalRootPath = QFileInfo(projectRootPath).canonicalFilePath(); auto buildPath = project->buildSystemManager()->buildDirectory(project->projectItem()); m_projectBuildPath = buildPath.toLocalFile(); @@ -153,25 +154,34 @@ m_error = i18n("Compile commands file '%1' does not exist.", commandsFilePath); return; } + + const auto pathInfo = QFileInfo(m_checkPath); + const bool checkPathIsFile = pathInfo.isFile(); + const auto canonicalPathToCheck = checkPathIsFile ? pathInfo.canonicalFilePath() : QStringLiteral(""); if (!m_checkPath.isEmpty()) { const auto allFiles = compileCommandsFiles(commandsFilePath, m_error); if (!m_error.isEmpty()) { return; } - if (m_checkPath == projectRootPath) { + if (m_checkPath == projectRootPath || canonicalPathToCheck == projectCanonicalRootPath) { m_sources = allFiles; } else { - const bool checkPathIsFile = QFileInfo(m_checkPath).isFile(); for (auto& file : allFiles) { if (checkPathIsFile) { if (file == m_checkPath) { m_sources.clear(); + // handle this separately so users don't see a filename they might not be expecting to see. m_sources += m_checkPath; break; } - } else if (file.startsWith(m_checkPath)) { + else if (file == canonicalPathToCheck) { + m_sources.clear(); + m_sources += canonicalPathToCheck; + break; + } + } else if (file.startsWith(m_checkPath) || file.startsWith(canonicalPathToCheck)) { m_sources += file; } }