Clang: Require LLVM/Clang >= 5.0.0

...for the code model parts and declare 5.0 as the supported version for
the clang static analyzer.

Adapt versions and tests, remove code assuming clang <= 5.0.

LLVM/Clang 5 was released on 07 Sep 2017.

Task-number: QTCREATORBUG-18931
Task-number: QTCREATORBUG-18657
Task-number: QTCREATORBUG-17187
Task-number: QTCREATORBUG-14881
Change-Id: I53b00258ca06a1d2e57f9379dacc54b310687295
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-09-29 13:46:53 +02:00
parent 6de3eb7a1a
commit 5ba40cb7fb
25 changed files with 85 additions and 125 deletions

View File

@@ -25,6 +25,7 @@
#pragma once
#include "sourcelocationsutils.h"
#include <filepathcachinginterface.h>
#include <filepathid.h>
@@ -51,15 +52,17 @@ public:
FilePathIds &includeIds,
FilePathCachingInterface &filePathCache,
const std::vector<uint> &excludedIncludeUID,
std::vector<uint> &alreadyIncludedFileUIDs)
std::vector<uint> &alreadyIncludedFileUIDs,
clang::SourceManager &sourceManager)
: m_headerSearch(headerSearch),
m_includeIds(includeIds),
m_filePathCache(filePathCache),
m_excludedIncludeUID(excludedIncludeUID),
m_alreadyIncludedFileUIDs(alreadyIncludedFileUIDs)
m_alreadyIncludedFileUIDs(alreadyIncludedFileUIDs),
m_sourceManager(sourceManager)
{}
void InclusionDirective(clang::SourceLocation /*hashLocation*/,
void InclusionDirective(clang::SourceLocation hashLocation,
const clang::Token &/*includeToken*/,
llvm::StringRef /*fileName*/,
bool /*isAngled*/,
@@ -71,8 +74,9 @@ public:
{
if (!m_skipInclude && file) {
auto fileUID = file->getUID();
if (isNotInExcludedIncludeUID(fileUID)) {
flagIncludeAlreadyRead(file);
auto sourceFileID = m_sourceManager.getFileID(hashLocation);
auto sourceFileUID = m_sourceManager.getFileEntryForID(sourceFileID)->getUID();
if (isNotInExcludedIncludeUID(fileUID) && isNotAlreadyIncluded(sourceFileUID).first) {
auto notAlreadyIncluded = isNotAlreadyIncluded(fileUID);
if (notAlreadyIncluded.first) {
@@ -142,35 +146,13 @@ public:
return {range.first == range.second, range.first};
}
void flagIncludeAlreadyRead(const clang::FileEntry *file)
{
auto &headerFileInfo = m_headerSearch.getFileInfo(file);
headerFileInfo.isImport = true;
++headerFileInfo.NumIncludes;
}
static Utils::PathString fromNativePath(Utils::PathString &&filePath)
{
#ifdef _WIN32
if (filePath.startsWith("\\\\?\\"))
filePath = Utils::PathString(filePath.mid(4));
filePath.replace('\\', '/');
#endif
return std::move(filePath);
}
static Utils::PathString filePathFromFile(const clang::FileEntry *file)
{
clang::StringRef realPath = file->tryGetRealPathName();
if (!realPath.empty())
return fromNativePath({realPath.data(), realPath.size()});
return fromNativePath(realPath);
#if LLVM_VERSION_MAJOR >= 4
return fromNativePath({file->getName().data(), file->getName().size()});
#else
return fromNativePath(file->getName());
#endif
return fromNativePath(absolutePath(file->getName()));
}
private:
@@ -179,6 +161,7 @@ private:
FilePathCachingInterface &m_filePathCache;
const std::vector<uint> &m_excludedIncludeUID;
std::vector<uint> &m_alreadyIncludedFileUIDs;
clang::SourceManager &m_sourceManager;
bool m_skipInclude = false;
};