ClangStaticAnalyzer: Fix path for intrinsics for clang toolchains

Ignore the include path for intrinsics coming from the toolchain. The
clang static analyzer comes with its own intrinsics and does not cope
well with intrinsics from other clang versions.

Move the relevant implementation from LibClangOptionsBuilder into the
base class so that ClangStaticAnalyzer profits from this, too.

Task-number: QTCREATORBUG-17102
Change-Id: Id9a28ddebb889c862939332dce888a80b3bb7e63
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Nikolai Kosjar
2016-10-10 17:31:19 +02:00
parent 3d68a8d0de
commit 6884ab080e
4 changed files with 20 additions and 25 deletions

View File

@@ -28,6 +28,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <QDir>
#include <QRegularExpression>
namespace CppTools {
@@ -393,7 +394,15 @@ bool CompilerOptionsBuilder::excludeDefineLine(const QByteArray &defineLine) con
bool CompilerOptionsBuilder::excludeHeaderPath(const QString &headerPath) const
{
Q_UNUSED(headerPath);
// A clang tool chain might have another version and passing in the
// intrinsics path from that version will lead to errors (unknown
// intrinsics, unfavorable order with regard to include_next).
if (m_projectPart.toolchainType == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID) {
static QRegularExpression clangIncludeDir(
QLatin1String("\\A.*/lib/clang/\\d+\\.\\d+(\\.\\d+)?/include\\z"));
return clangIncludeDir.match(headerPath).hasMatch();
}
return false;
}