UnitTests: Fix compile without Clang

I moved the clang depend code under the condition that it is only compiled
if LLVM is present.

Change-Id: If1e37f677464ff38833c81dbebdfe8eaa563cdde
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Marco Bubke
2019-07-11 17:40:46 +02:00
parent 5af1f95f25
commit ec3c7946af
7 changed files with 81 additions and 71 deletions

View File

@@ -2,7 +2,6 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/clangrefactoringbackend_global.h \
$$PWD/filestatuspreprocessorcallbacks.h \
$$PWD/sourcerangefilter.h \
$$PWD/symbolindexer.h \
$$PWD/symbolentry.h \
@@ -14,10 +13,8 @@ HEADERS += \
$$PWD/symbolindexinginterface.h \
$$PWD/collectmacrospreprocessorcallbacks.h \
$$PWD/projectpartentry.h \
$$PWD/symbolsvisitorbase.h \
$$PWD/usedmacro.h \
$$PWD/sourcedependency.h \
$$PWD/indexdataconsumer.h \
$$PWD/sourcesmanager.h \
$$PWD/symbolindexertaskqueue.h \
$$PWD/symbolindexertaskqueueinterface.h \
@@ -35,6 +32,7 @@ SOURCES += \
$$PWD/collectsymbolsaction.cpp \
$$PWD/collectmacrossourcefilecallbacks.cpp \
$$PWD/symbolscollector.cpp \
$$PWD/filestatuspreprocessorcallbacks.cpp \
$$PWD/clangquerygatherer.cpp \
$$PWD/symbolindexing.cpp \
$$PWD/indexdataconsumer.cpp
@@ -51,10 +49,12 @@ HEADERS += \
$$PWD/collectsymbolsaction.h \
$$PWD/collectmacrossourcefilecallbacks.h \
$$PWD/symbolscollector.h \
$$PWD/symbolsvisitorbase.h \
$$PWD/indexdataconsumer.h \
$$PWD/filestatuspreprocessorcallbacks.h \
$$PWD/clangquerygatherer.h
}
SOURCES += \
$$PWD/filestatuspreprocessorcallbacks.cpp \
$$PWD/sourcerangefilter.cpp \
$$PWD/symbolindexer.cpp

View File

@@ -1,6 +1,6 @@
GOOGLEBENCHMARK_DIR = $$(GOOGLEBENCHMARK_DIR)
exists($$GOOGLEBENCHMARK_DIR) {
!isEmpty(GOOGLEBENCHMARK_DIR):exists($$GOOGLEBENCHMARK_DIR) {
INCLUDEPATH += $$GOOGLEBENCHMARK_DIR/include
DEFINES += HAVE_STD_REGEX WITH_BENCHMARKS

View File

@@ -24,9 +24,6 @@
****************************************************************************/
#include <QtGlobal>
#include <clang-c/Index.h>
#include <clangbackend_global.h>
#ifdef Q_OS_WIN
# define DISABLED_ON_WINDOWS(x) DISABLED_##x

View File

@@ -23,9 +23,17 @@
**
****************************************************************************/
#include "gtest-creator-printing.h"
#ifdef CLANG_UNIT_TESTS
#include <clang/Basic/SourceLocation.h>
#include <clang/Basic/SourceManager.h>
#include <clangdocumentsuspenderresumer.h>
#include <clangreferencescollector.h>
#include <fulltokeninfo.h>
#include <tokenprocessor.h>
#endif
#include <gtest/gtest-printers.h>
@@ -77,3 +85,52 @@ void PrintTo(const SourceRange &sourceRange, ::std::ostream *os)
}
}
namespace ClangBackEnd {
std::ostream &operator<<(std::ostream &os, const TokenInfo &tokenInfo)
{
os << "(type: " << tokenInfo.types() << ", "
<< " line: " << tokenInfo.line() << ", "
<< " column: " << tokenInfo.column() << ", "
<< " length: " << tokenInfo.length() << ")";
return os;
}
template<class T>
std::ostream &operator<<(std::ostream &out, const TokenProcessor<T> &tokenInfos)
{
out << "[";
for (const T &entry : tokenInfos)
out << entry;
out << "]";
return out;
}
template std::ostream &operator<<(std::ostream &out, const TokenProcessor<TokenInfo> &tokenInfos);
template std::ostream &operator<<(std::ostream &out, const TokenProcessor<FullTokenInfo> &tokenInfos);
std::ostream &operator<<(std::ostream &out, const SuspendResumeJobsEntry &entry)
{
return out << "(" << entry.document.filePath() << ", " << entry.jobRequestType << ", "
<< entry.preferredTranslationUnit << ")";
}
std::ostream &operator<<(std::ostream &os, const ReferencesResult &value)
{
os << "ReferencesResult(";
os << value.isLocalVariable << ", {";
for (const SourceRangeContainer &r : value.references) {
os << r.start.line << ",";
os << r.start.column << ",";
os << r.end.column - r.start.column << ",";
}
os << "})";
return os;
}
} // namespace ClangBackEnd

View File

@@ -27,6 +27,8 @@
#include <iosfwd>
#include <gtest/gtest-printers.h>
namespace llvm {
class StringRef;
@@ -48,3 +50,17 @@ namespace TestGlobal {
void setSourceManager(const clang::SourceManager *sourceManager);
}
namespace ClangBackEnd {
class TokenInfo;
template<typename T>
class TokenProcessor;
class SuspendResumeJobsEntry;
class ReferencesResult;
std::ostream &operator<<(std::ostream &os, const TokenInfo &tokenInfo);
template<class T>
std::ostream &operator<<(std::ostream &out, const TokenProcessor<T> &tokenInfos);
std::ostream &operator<<(std::ostream &out, const SuspendResumeJobsEntry &entry);
std::ostream &operator<<(std::ostream &os, const ReferencesResult &value);
} // namespace ClangBackEnd

View File

@@ -35,15 +35,12 @@
#include <builddependency.h>
#include <clangcodemodelclientmessages.h>
#include <clangcodemodelservermessages.h>
#include <clangdocumentsuspenderresumer.h>
#include <clangpathwatcher.h>
#include <clangrefactoringmessages.h>
#include <clangreferencescollector.h>
#include <filepath.h>
#include <filepathcaching.h>
#include <filepathview.h>
#include <filestatus.h>
#include <fulltokeninfo.h>
#include <includesearchpath.h>
#include <nativefilepath.h>
#include <pchpaths.h>
@@ -58,16 +55,12 @@
#include <symbol.h>
#include <symbolentry.h>
#include <symbolindexertaskqueue.h>
#include <tokenprocessor.h>
#include <toolchainargumentscache.h>
#include <tooltipinfo.h>
#include <usedmacro.h>
#include <cpptools/usages.h>
#include <projectexplorer/projectmacro.h>
#include <projectexplorer/headerpath.h>
#include <coreplugin/find/searchresultitem.h>
#include <coreplugin/locator/ilocatorfilter.h>
@@ -924,35 +917,6 @@ std::ostream &operator<<(std::ostream &os, const DocumentVisibilityChangedMessag
return os;
}
std::ostream &operator<<(std::ostream &os, const TokenInfo &tokenInfo)
{
os << "(type: " << tokenInfo.types() << ", "
<< " line: " << tokenInfo.line() << ", "
<< " column: " << tokenInfo.column() << ", "
<< " length: " << tokenInfo.length()
<< ")";
return os;
}
template<class T>
std::ostream &operator<<(std::ostream &out, const TokenProcessor<T> &tokenInfos)
{
out << "[";
for (const T &entry : tokenInfos)
out << entry;
out << "]";
return out;
}
template
std::ostream &operator<<(std::ostream &out, const TokenProcessor<TokenInfo> &tokenInfos);
template
std::ostream &operator<<(std::ostream &out, const TokenProcessor<FullTokenInfo> &tokenInfos);
std::ostream &operator<<(std::ostream &out, const FilePath &filePath)
{
return out << "(" << filePath.path() << ", " << filePath.slashIndex() << ")";
@@ -1078,30 +1042,6 @@ std::ostream &operator<<(std::ostream &out, const RemoveGeneratedFilesMessage &m
return out << "(" << message.generatedFiles << ")";
}
std::ostream &operator<<(std::ostream &out, const SuspendResumeJobsEntry &entry)
{
return out << "("
<< entry.document.filePath() << ", "
<< entry.jobRequestType << ", "
<< entry.preferredTranslationUnit
<< ")";
}
std::ostream &operator<<(std::ostream &os, const ReferencesResult &value)
{
os << "ReferencesResult(";
os << value.isLocalVariable << ", {";
for (const SourceRangeContainer &r : value.references) {
os << r.start.line << ",";
os << r.start.column << ",";
EXPECT_THAT(r.start.line, testing::Eq(r.end.line));
os << r.end.column - r.start.column << ",";
}
os << "})";
return os;
}
std::ostream &operator<<(std::ostream &out, const SymbolIndexerTask &task)
{
return out << "(" << task.filePathId << ", " << task.projectPartId << ")";

View File

@@ -97,10 +97,8 @@ SOURCES += \
nativefilepath-test.cpp \
nativefilepathview-test.cpp \
mocktimer.cpp \
tokenprocessor-test.cpp \
projectpartartefact-test.cpp \
filestatuscache-test.cpp \
highlightingresultreporter-test.cpp \
precompiledheaderstorage-test.cpp \
generatedfiles-test.cpp \
sourcesmanager-test.cpp \
@@ -163,6 +161,7 @@ SOURCES += \
diagnosticset-test.cpp \
diagnostic-test.cpp \
fixit-test.cpp \
highlightingresultreporter-test.cpp \
senddocumenttracker-test.cpp \
skippedsourceranges-test.cpp \
sourcelocation-test.cpp \
@@ -174,6 +173,7 @@ SOURCES += \
sqlitetable-test.cpp \
sqlstatementbuilder-test.cpp \
token-test.cpp \
tokenprocessor-test.cpp \
translationunitupdater-test.cpp \
unsavedfiles-test.cpp \
unsavedfile-test.cpp \
@@ -205,7 +205,7 @@ SOURCES += \
SOURCES += clangformat-test.cpp
}
exists($$GOOGLEBENCHMARK_DIR) {
!isEmpty(GOOGLEBENCHMARK_DIR):exists($$GOOGLEBENCHMARK_DIR) {
SOURCES += \
smallstring-benchmark.cpp
}