forked from qt-creator/qt-creator
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:
@@ -29,6 +29,8 @@
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#include <utils/smallstringfwd.h>
|
||||
|
||||
#ifdef UNIT_TESTS
|
||||
#include <gtest/gtest.h>
|
||||
#endif
|
||||
@@ -51,13 +53,6 @@
|
||||
#define unitttest_public private
|
||||
#endif
|
||||
|
||||
namespace Utils {
|
||||
template <uint Size>
|
||||
class BasicSmallString;
|
||||
using SmallString = BasicSmallString<31>;
|
||||
using PathString = BasicSmallString<190>;
|
||||
}
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
enum class DiagnosticSeverity : quint32 // one to one mapping of the clang enum numbers
|
||||
|
37
src/libs/utils/smallstringfwd.h
Normal file
37
src/libs/utils/smallstringfwd.h
Normal 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
|
@@ -235,7 +235,8 @@ HEADERS += \
|
||||
$$PWD/sizedarray.h \
|
||||
$$PWD/smallstringio.h \
|
||||
$$PWD/guard.h \
|
||||
$$PWD/asconst.h
|
||||
$$PWD/asconst.h \
|
||||
$$PWD/smallstringfwd.h
|
||||
|
||||
FORMS += $$PWD/filewizardpage.ui \
|
||||
$$PWD/projectintropage.ui \
|
||||
|
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/smallstringfwd.h>
|
||||
|
||||
#ifdef UNIT_TESTS
|
||||
#define unitttest_public public
|
||||
#define non_unittest_final
|
||||
@@ -40,13 +42,6 @@ class SmallVector;
|
||||
|
||||
using uint = unsigned int;
|
||||
|
||||
namespace Utils {
|
||||
template <uint Size>
|
||||
class BasicSmallString;
|
||||
using SmallString = BasicSmallString<31>;
|
||||
using PathString = BasicSmallString<190>;
|
||||
}
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
using USRName = llvm::SmallVector<char, 128>;
|
||||
|
@@ -39,8 +39,8 @@ class CollectIncludesAction final : public clang::PreprocessOnlyAction
|
||||
{
|
||||
public:
|
||||
CollectIncludesAction(std::vector<uint> &includeIds,
|
||||
StringCache<Utils::SmallString> &filePathCache,
|
||||
const std::vector<uint> &excludedIncludeUID,
|
||||
StringCache<Utils::PathString> &filePathCache,
|
||||
std::vector<uint> &excludedIncludeUID,
|
||||
std::vector<uint> &alreadyIncludedFileUIDs)
|
||||
: m_includeIds(includeIds),
|
||||
m_filePathCache(filePathCache),
|
||||
@@ -77,8 +77,8 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<uint> &m_includeIds;
|
||||
StringCache<Utils::SmallString> &m_filePathCache;
|
||||
const std::vector<uint> &m_excludedIncludeUID;
|
||||
StringCache<Utils::PathString> &m_filePathCache;
|
||||
std::vector<uint> &m_excludedIncludeUID;
|
||||
std::vector<uint> &m_alreadyIncludedFileUIDs;
|
||||
};
|
||||
|
||||
|
@@ -44,7 +44,7 @@ class CollectIncludesPreprocessorCallbacks final : public clang::PPCallbacks
|
||||
public:
|
||||
CollectIncludesPreprocessorCallbacks(clang::HeaderSearch &headerSearch,
|
||||
std::vector<uint> &includeIds,
|
||||
StringCache<Utils::SmallString> &filePathCache,
|
||||
StringCache<Utils::PathString> &filePathCache,
|
||||
const std::vector<uint> &excludedIncludeUID,
|
||||
std::vector<uint> &alreadyIncludedFileUIDs)
|
||||
: m_headerSearch(headerSearch),
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
private:
|
||||
clang::HeaderSearch &m_headerSearch;
|
||||
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_alreadyIncludedFileUIDs;
|
||||
};
|
||||
|
@@ -37,7 +37,7 @@ class CollectIncludesToolAction final : public clang::tooling::FrontendActionFac
|
||||
{
|
||||
public:
|
||||
CollectIncludesToolAction(std::vector<uint> &includeIds,
|
||||
StringCache<Utils::SmallString> &filePathCache,
|
||||
StringCache<Utils::PathString> &filePathCache,
|
||||
const Utils::PathStringVector &excludedIncludes)
|
||||
: m_includeIds(includeIds),
|
||||
m_filePathCache(filePathCache),
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
std::vector<uint> m_alreadyIncludedFileUIDs;
|
||||
std::vector<uint> m_excludedIncludeUIDs;
|
||||
std::vector<uint> &m_includeIds;
|
||||
StringCache<Utils::SmallString> &m_filePathCache;
|
||||
StringCache<Utils::PathString> &m_filePathCache;
|
||||
const Utils::PathStringVector &m_excludedIncludes;
|
||||
};
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
IncludeCollector::IncludeCollector(StringCache<Utils::SmallString> &filePathCache)
|
||||
IncludeCollector::IncludeCollector(StringCache<Utils::PathString> &filePathCache)
|
||||
: m_filePathCache(filePathCache)
|
||||
{
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ namespace ClangBackEnd {
|
||||
class IncludeCollector : public ClangTool
|
||||
{
|
||||
public:
|
||||
IncludeCollector(StringCache<Utils::SmallString> &filePathCache);
|
||||
IncludeCollector(StringCache<Utils::PathString> &filePathCache);
|
||||
|
||||
void collectIncludes();
|
||||
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
Utils::PathStringVector m_excludedIncludes;
|
||||
std::vector<uint> m_includeIds;
|
||||
Utils::SmallStringVector m_directories;
|
||||
StringCache<Utils::SmallString> &m_filePathCache;
|
||||
StringCache<Utils::PathString> &m_filePathCache;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
PchCreator::PchCreator(Environment &environment, StringCache<Utils::SmallString> &filePathCache)
|
||||
PchCreator::PchCreator(Environment &environment, StringCache<Utils::PathString> &filePathCache)
|
||||
: m_environment(environment),
|
||||
m_filePathCache(filePathCache)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ PchCreator::PchCreator(Environment &environment, StringCache<Utils::SmallString>
|
||||
|
||||
PchCreator::PchCreator(V2::ProjectPartContainers &&projectsParts,
|
||||
Environment &environment,
|
||||
StringCache<Utils::SmallString> &filePathCache,
|
||||
StringCache<Utils::PathString> &filePathCache,
|
||||
PchGeneratorInterface *pchGenerator,
|
||||
V2::FileContainers &&generatedFiles)
|
||||
: m_projectParts(std::move(projectsParts)),
|
||||
@@ -255,9 +255,9 @@ std::vector<uint> PchCreator::generateGlobalPchIncludeIds() const
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
@@ -274,7 +274,7 @@ Utils::SmallString PchCreator::generatePchIncludeFileContent(
|
||||
|
||||
fileContent.reserve(includes.size() * lineTemplateSize + contentSize(includes));
|
||||
|
||||
for (const Utils::SmallString &include : includes) {
|
||||
for (const Utils::PathString &include : includes) {
|
||||
fileContent += "#include \"";
|
||||
fileContent += include;
|
||||
fileContent += "\"\n";
|
||||
|
@@ -48,10 +48,10 @@ class PchCreator final : public PchCreatorInterface
|
||||
{
|
||||
public:
|
||||
PchCreator(Environment &environment,
|
||||
StringCache<Utils::SmallString> &filePathCache);
|
||||
StringCache<Utils::PathString> &filePathCache);
|
||||
PchCreator(V2::ProjectPartContainers &&projectsParts,
|
||||
Environment &environment,
|
||||
StringCache<Utils::SmallString> &filePathCache,
|
||||
StringCache<Utils::PathString> &filePathCache,
|
||||
PchGeneratorInterface *pchGenerator,
|
||||
V2::FileContainers &&generatedFiles);
|
||||
|
||||
@@ -123,7 +123,7 @@ private:
|
||||
std::vector<ProjectPartPch> m_projectPartPchs;
|
||||
std::vector<IdPaths> m_projectsIncludeIds;
|
||||
Environment &m_environment;
|
||||
StringCache<Utils::SmallString> &m_filePathCache;
|
||||
StringCache<Utils::PathString> &m_filePathCache;
|
||||
PchGeneratorInterface *m_pchGenerator = nullptr;
|
||||
};
|
||||
|
||||
|
@@ -25,16 +25,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/smallstringfwd.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
using uint = unsigned int;
|
||||
|
||||
namespace Utils {
|
||||
template <uint Size>
|
||||
class BasicSmallString;
|
||||
using SmallString = BasicSmallString<31>;
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
class StringRef;
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ protected:
|
||||
uint id(const Utils::SmallString &path);
|
||||
|
||||
protected:
|
||||
ClangBackEnd::StringCache<Utils::SmallString> filePathCache;
|
||||
ClangBackEnd::StringCache<Utils::PathString> filePathCache;
|
||||
ClangBackEnd::IncludeCollector collector{filePathCache};
|
||||
};
|
||||
|
||||
|
@@ -61,7 +61,7 @@ protected:
|
||||
uint id(const Utils::SmallString &path);
|
||||
|
||||
protected:
|
||||
ClangBackEnd::StringCache<Utils::SmallString> filePathCache;
|
||||
ClangBackEnd::StringCache<Utils::PathString> filePathCache;
|
||||
PathString main1Path = TESTDATA_DIR "/includecollector_main3.cpp";
|
||||
PathString main2Path = TESTDATA_DIR "/includecollector_main2.cpp";
|
||||
PathString header1Path = TESTDATA_DIR "/includecollector_header1.h";
|
||||
|
Reference in New Issue
Block a user