Utils: Move forward declaration of SmallString in an extra header

Change-Id: I6da1cc60d425f654a31570373eb3b4f660d5f975
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-02-01 12:29:27 +01:00
parent 76713d6d26
commit 01a96537a8
14 changed files with 66 additions and 42 deletions

View File

@@ -29,6 +29,8 @@
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#include <utils/smallstringfwd.h>
#ifdef UNIT_TESTS #ifdef UNIT_TESTS
#include <gtest/gtest.h> #include <gtest/gtest.h>
#endif #endif
@@ -51,13 +53,6 @@
#define unitttest_public private #define unitttest_public private
#endif #endif
namespace Utils {
template <uint Size>
class BasicSmallString;
using SmallString = BasicSmallString<31>;
using PathString = BasicSmallString<190>;
}
namespace ClangBackEnd { namespace ClangBackEnd {
enum class DiagnosticSeverity : quint32 // one to one mapping of the clang enum numbers enum class DiagnosticSeverity : quint32 // one to one mapping of the clang enum numbers

View File

@@ -0,0 +1,37 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
namespace Utils {
using uint = unsigned int;
template <uint Size>
class BasicSmallString;
using SmallString = BasicSmallString<31>;
using PathString = BasicSmallString<190>;
} // namespace Utils

View File

@@ -235,7 +235,8 @@ HEADERS += \
$$PWD/sizedarray.h \ $$PWD/sizedarray.h \
$$PWD/smallstringio.h \ $$PWD/smallstringio.h \
$$PWD/guard.h \ $$PWD/guard.h \
$$PWD/asconst.h $$PWD/asconst.h \
$$PWD/smallstringfwd.h
FORMS += $$PWD/filewizardpage.ui \ FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \ $$PWD/projectintropage.ui \

View File

@@ -25,6 +25,8 @@
#pragma once #pragma once
#include <utils/smallstringfwd.h>
#ifdef UNIT_TESTS #ifdef UNIT_TESTS
#define unitttest_public public #define unitttest_public public
#define non_unittest_final #define non_unittest_final
@@ -40,13 +42,6 @@ class SmallVector;
using uint = unsigned int; using uint = unsigned int;
namespace Utils {
template <uint Size>
class BasicSmallString;
using SmallString = BasicSmallString<31>;
using PathString = BasicSmallString<190>;
}
namespace ClangBackEnd { namespace ClangBackEnd {
using USRName = llvm::SmallVector<char, 128>; using USRName = llvm::SmallVector<char, 128>;

View File

@@ -39,8 +39,8 @@ class CollectIncludesAction final : public clang::PreprocessOnlyAction
{ {
public: public:
CollectIncludesAction(std::vector<uint> &includeIds, CollectIncludesAction(std::vector<uint> &includeIds,
StringCache<Utils::SmallString> &filePathCache, StringCache<Utils::PathString> &filePathCache,
const std::vector<uint> &excludedIncludeUID, std::vector<uint> &excludedIncludeUID,
std::vector<uint> &alreadyIncludedFileUIDs) std::vector<uint> &alreadyIncludedFileUIDs)
: m_includeIds(includeIds), : m_includeIds(includeIds),
m_filePathCache(filePathCache), m_filePathCache(filePathCache),
@@ -77,8 +77,8 @@ public:
private: private:
std::vector<uint> &m_includeIds; std::vector<uint> &m_includeIds;
StringCache<Utils::SmallString> &m_filePathCache; StringCache<Utils::PathString> &m_filePathCache;
const std::vector<uint> &m_excludedIncludeUID; std::vector<uint> &m_excludedIncludeUID;
std::vector<uint> &m_alreadyIncludedFileUIDs; std::vector<uint> &m_alreadyIncludedFileUIDs;
}; };

View File

@@ -44,7 +44,7 @@ class CollectIncludesPreprocessorCallbacks final : public clang::PPCallbacks
public: public:
CollectIncludesPreprocessorCallbacks(clang::HeaderSearch &headerSearch, CollectIncludesPreprocessorCallbacks(clang::HeaderSearch &headerSearch,
std::vector<uint> &includeIds, std::vector<uint> &includeIds,
StringCache<Utils::SmallString> &filePathCache, StringCache<Utils::PathString> &filePathCache,
const std::vector<uint> &excludedIncludeUID, const std::vector<uint> &excludedIncludeUID,
std::vector<uint> &alreadyIncludedFileUIDs) std::vector<uint> &alreadyIncludedFileUIDs)
: m_headerSearch(headerSearch), : m_headerSearch(headerSearch),
@@ -119,7 +119,7 @@ public:
private: private:
clang::HeaderSearch &m_headerSearch; clang::HeaderSearch &m_headerSearch;
std::vector<uint> &m_includeIds; std::vector<uint> &m_includeIds;
StringCache<Utils::SmallString> &m_filePathCache; StringCache<Utils::PathString> &m_filePathCache;
const std::vector<uint> &m_excludedIncludeUID; const std::vector<uint> &m_excludedIncludeUID;
std::vector<uint> &m_alreadyIncludedFileUIDs; std::vector<uint> &m_alreadyIncludedFileUIDs;
}; };

View File

@@ -37,7 +37,7 @@ class CollectIncludesToolAction final : public clang::tooling::FrontendActionFac
{ {
public: public:
CollectIncludesToolAction(std::vector<uint> &includeIds, CollectIncludesToolAction(std::vector<uint> &includeIds,
StringCache<Utils::SmallString> &filePathCache, StringCache<Utils::PathString> &filePathCache,
const Utils::PathStringVector &excludedIncludes) const Utils::PathStringVector &excludedIncludes)
: m_includeIds(includeIds), : m_includeIds(includeIds),
m_filePathCache(filePathCache), m_filePathCache(filePathCache),
@@ -87,7 +87,7 @@ private:
std::vector<uint> m_alreadyIncludedFileUIDs; std::vector<uint> m_alreadyIncludedFileUIDs;
std::vector<uint> m_excludedIncludeUIDs; std::vector<uint> m_excludedIncludeUIDs;
std::vector<uint> &m_includeIds; std::vector<uint> &m_includeIds;
StringCache<Utils::SmallString> &m_filePathCache; StringCache<Utils::PathString> &m_filePathCache;
const Utils::PathStringVector &m_excludedIncludes; const Utils::PathStringVector &m_excludedIncludes;
}; };

View File

@@ -33,7 +33,7 @@
namespace ClangBackEnd { namespace ClangBackEnd {
IncludeCollector::IncludeCollector(StringCache<Utils::SmallString> &filePathCache) IncludeCollector::IncludeCollector(StringCache<Utils::PathString> &filePathCache)
: m_filePathCache(filePathCache) : m_filePathCache(filePathCache)
{ {
} }

View File

@@ -34,7 +34,7 @@ namespace ClangBackEnd {
class IncludeCollector : public ClangTool class IncludeCollector : public ClangTool
{ {
public: public:
IncludeCollector(StringCache<Utils::SmallString> &filePathCache); IncludeCollector(StringCache<Utils::PathString> &filePathCache);
void collectIncludes(); void collectIncludes();
@@ -46,7 +46,7 @@ private:
Utils::PathStringVector m_excludedIncludes; Utils::PathStringVector m_excludedIncludes;
std::vector<uint> m_includeIds; std::vector<uint> m_includeIds;
Utils::SmallStringVector m_directories; Utils::SmallStringVector m_directories;
StringCache<Utils::SmallString> &m_filePathCache; StringCache<Utils::PathString> &m_filePathCache;
}; };
} // namespace ClangBackEnd } // namespace ClangBackEnd

View File

@@ -36,7 +36,7 @@
namespace ClangBackEnd { namespace ClangBackEnd {
PchCreator::PchCreator(Environment &environment, StringCache<Utils::SmallString> &filePathCache) PchCreator::PchCreator(Environment &environment, StringCache<Utils::PathString> &filePathCache)
: m_environment(environment), : m_environment(environment),
m_filePathCache(filePathCache) m_filePathCache(filePathCache)
{ {
@@ -44,7 +44,7 @@ PchCreator::PchCreator(Environment &environment, StringCache<Utils::SmallString>
PchCreator::PchCreator(V2::ProjectPartContainers &&projectsParts, PchCreator::PchCreator(V2::ProjectPartContainers &&projectsParts,
Environment &environment, Environment &environment,
StringCache<Utils::SmallString> &filePathCache, StringCache<Utils::PathString> &filePathCache,
PchGeneratorInterface *pchGenerator, PchGeneratorInterface *pchGenerator,
V2::FileContainers &&generatedFiles) V2::FileContainers &&generatedFiles)
: m_projectParts(std::move(projectsParts)), : m_projectParts(std::move(projectsParts)),
@@ -255,9 +255,9 @@ std::vector<uint> PchCreator::generateGlobalPchIncludeIds() const
namespace { namespace {
std::size_t contentSize(const std::vector<Utils::SmallString> &includes) std::size_t contentSize(const std::vector<Utils::PathString> &includes)
{ {
auto countIncludeSize = [] (std::size_t size, const Utils::SmallString &include) { auto countIncludeSize = [] (std::size_t size, const Utils::PathString &include) {
return size + include.size(); return size + include.size();
}; };
@@ -274,7 +274,7 @@ Utils::SmallString PchCreator::generatePchIncludeFileContent(
fileContent.reserve(includes.size() * lineTemplateSize + contentSize(includes)); fileContent.reserve(includes.size() * lineTemplateSize + contentSize(includes));
for (const Utils::SmallString &include : includes) { for (const Utils::PathString &include : includes) {
fileContent += "#include \""; fileContent += "#include \"";
fileContent += include; fileContent += include;
fileContent += "\"\n"; fileContent += "\"\n";

View File

@@ -48,10 +48,10 @@ class PchCreator final : public PchCreatorInterface
{ {
public: public:
PchCreator(Environment &environment, PchCreator(Environment &environment,
StringCache<Utils::SmallString> &filePathCache); StringCache<Utils::PathString> &filePathCache);
PchCreator(V2::ProjectPartContainers &&projectsParts, PchCreator(V2::ProjectPartContainers &&projectsParts,
Environment &environment, Environment &environment,
StringCache<Utils::SmallString> &filePathCache, StringCache<Utils::PathString> &filePathCache,
PchGeneratorInterface *pchGenerator, PchGeneratorInterface *pchGenerator,
V2::FileContainers &&generatedFiles); V2::FileContainers &&generatedFiles);
@@ -123,7 +123,7 @@ private:
std::vector<ProjectPartPch> m_projectPartPchs; std::vector<ProjectPartPch> m_projectPartPchs;
std::vector<IdPaths> m_projectsIncludeIds; std::vector<IdPaths> m_projectsIncludeIds;
Environment &m_environment; Environment &m_environment;
StringCache<Utils::SmallString> &m_filePathCache; StringCache<Utils::PathString> &m_filePathCache;
PchGeneratorInterface *m_pchGenerator = nullptr; PchGeneratorInterface *m_pchGenerator = nullptr;
}; };

View File

@@ -25,16 +25,12 @@
#pragma once #pragma once
#include <utils/smallstringfwd.h>
#include <vector> #include <vector>
using uint = unsigned int; using uint = unsigned int;
namespace Utils {
template <uint Size>
class BasicSmallString;
using SmallString = BasicSmallString<31>;
}
namespace llvm { namespace llvm {
class StringRef; class StringRef;
} }

View File

@@ -43,7 +43,7 @@ protected:
uint id(const Utils::SmallString &path); uint id(const Utils::SmallString &path);
protected: protected:
ClangBackEnd::StringCache<Utils::SmallString> filePathCache; ClangBackEnd::StringCache<Utils::PathString> filePathCache;
ClangBackEnd::IncludeCollector collector{filePathCache}; ClangBackEnd::IncludeCollector collector{filePathCache};
}; };

View File

@@ -61,7 +61,7 @@ protected:
uint id(const Utils::SmallString &path); uint id(const Utils::SmallString &path);
protected: protected:
ClangBackEnd::StringCache<Utils::SmallString> filePathCache; ClangBackEnd::StringCache<Utils::PathString> filePathCache;
PathString main1Path = TESTDATA_DIR "/includecollector_main3.cpp"; PathString main1Path = TESTDATA_DIR "/includecollector_main3.cpp";
PathString main2Path = TESTDATA_DIR "/includecollector_main2.cpp"; PathString main2Path = TESTDATA_DIR "/includecollector_main2.cpp";
PathString header1Path = TESTDATA_DIR "/includecollector_header1.h"; PathString header1Path = TESTDATA_DIR "/includecollector_header1.h";