Commit 8ac76922 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

Clang: Filter out "#pragma once in main file" warning for headers



This is a libclang bug and unfortunately there is no option to disable
this warning.

Change-Id: I12cdaa0155e7d94a70b8fccd8c9290835704e06b
Task-number: QTCREATORBUG-12067
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent 9f2b5eac
......@@ -33,6 +33,7 @@
#include "utils_p.h"
#include "cxraii.h"
#include <utils/mimetypes/mimedatabase.h>
#include <utils/qtcassert.h>
using namespace ClangCodeModel;
......@@ -131,12 +132,23 @@ static void appendDiagnostic(const CXDiagnostic &diag,
}
}
static bool isBlackListedDiagnostic(const Utils::MimeType &mimeType, const QString &diagnostic)
{
static QString pragmaOnceInMainFile = QLatin1String("#pragma once in main file");
return diagnostic == pragmaOnceInMainFile
&& mimeType.inherits(QLatin1String("text/x-chdr"));
}
QList<Diagnostic> SemanticMarker::diagnostics() const
{
QList<Diagnostic> diagnostics;
if (!m_unit || !m_unit->isLoaded())
return diagnostics;
Utils::MimeDatabase mimeDatabase;
const Utils::MimeType mimeType = mimeDatabase.mimeTypeForFile(fileName());
const unsigned diagCount = m_unit->getNumDiagnostics();
for (unsigned i = 0; i < diagCount; ++i) {
ScopedCXDiagnostic diag(m_unit->getDiagnostic(i));
......@@ -148,6 +160,9 @@ QList<Diagnostic> SemanticMarker::diagnostics() const
CXSourceLocation cxLocation = clang_getDiagnosticLocation(diag);
QString spelling = Internal::getQString(clang_getDiagnosticSpelling(diag));
if (isBlackListedDiagnostic(mimeType, spelling))
continue;
// Attach messages with Diagnostic::Note severity
ScopedCXDiagnosticSet cxChildren(clang_getChildDiagnostics(diag));
const unsigned numChildren = clang_getNumDiagnosticsInSet(cxChildren);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment