summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2017-02-01 12:29:27 +0100
committerMarco Bubke <marco.bubke@qt.io>2017-02-02 12:46:44 +0000
commit01a96537a83d13a9f473b2b16b040bd26f411d83 (patch)
treeffc00aa36dd9c6ab5d1fc20cc181d28f25953f1a
parent76713d6d26975b358066508733192598ec70b212 (diff)
downloadqt-creator-01a96537a83d13a9f473b2b16b040bd26f411d83.tar.gz
Utils: Move forward declaration of SmallString in an extra header
Change-Id: I6da1cc60d425f654a31570373eb3b4f660d5f975 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--src/libs/clangbackendipc/clangbackendipc_global.h9
-rw-r--r--src/libs/utils/smallstringfwd.h37
-rw-r--r--src/libs/utils/utils-lib.pri3
-rw-r--r--src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend_global.h9
-rw-r--r--src/tools/clangpchmanagerbackend/source/collectincludesaction.h8
-rw-r--r--src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h4
-rw-r--r--src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h4
-rw-r--r--src/tools/clangpchmanagerbackend/source/includecollector.cpp2
-rw-r--r--src/tools/clangpchmanagerbackend/source/includecollector.h4
-rw-r--r--src/tools/clangpchmanagerbackend/source/pchcreator.cpp10
-rw-r--r--src/tools/clangpchmanagerbackend/source/pchcreator.h6
-rw-r--r--src/tools/clangrefactoringbackend/source/sourcerangeextractor.h8
-rw-r--r--tests/unit/unittest/includecollector-test.cpp2
-rw-r--r--tests/unit/unittest/pchcreator-test.cpp2
14 files changed, 66 insertions, 42 deletions
diff --git a/src/libs/clangbackendipc/clangbackendipc_global.h b/src/libs/clangbackendipc/clangbackendipc_global.h
index 5c12e159b8..33775c7cac 100644
--- a/src/libs/clangbackendipc/clangbackendipc_global.h
+++ b/src/libs/clangbackendipc/clangbackendipc_global.h
@@ -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
diff --git a/src/libs/utils/smallstringfwd.h b/src/libs/utils/smallstringfwd.h
new file mode 100644
index 0000000000..90af2c7b42
--- /dev/null
+++ b/src/libs/utils/smallstringfwd.h
@@ -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
diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri
index aa5ff4716b..6d67f87b4c 100644
--- a/src/libs/utils/utils-lib.pri
+++ b/src/libs/utils/utils-lib.pri
@@ -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 \
diff --git a/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend_global.h b/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend_global.h
index 9794f2bb60..b5b5fdc0c7 100644
--- a/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend_global.h
+++ b/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend_global.h
@@ -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>;
diff --git a/src/tools/clangpchmanagerbackend/source/collectincludesaction.h b/src/tools/clangpchmanagerbackend/source/collectincludesaction.h
index 3f98b307e1..292a263808 100644
--- a/src/tools/clangpchmanagerbackend/source/collectincludesaction.h
+++ b/src/tools/clangpchmanagerbackend/source/collectincludesaction.h
@@ -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;
};
diff --git a/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h b/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h
index 137b462ada..2fddb22a74 100644
--- a/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h
+++ b/src/tools/clangpchmanagerbackend/source/collectincludespreprocessorcallbacks.h
@@ -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;
};
diff --git a/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h b/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h
index 7b81228b09..eea42ca9f3 100644
--- a/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h
+++ b/src/tools/clangpchmanagerbackend/source/collectincludestoolaction.h
@@ -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;
};
diff --git a/src/tools/clangpchmanagerbackend/source/includecollector.cpp b/src/tools/clangpchmanagerbackend/source/includecollector.cpp
index cf9dd75933..b380fa2b8b 100644
--- a/src/tools/clangpchmanagerbackend/source/includecollector.cpp
+++ b/src/tools/clangpchmanagerbackend/source/includecollector.cpp
@@ -33,7 +33,7 @@
namespace ClangBackEnd {
-IncludeCollector::IncludeCollector(StringCache<Utils::SmallString> &filePathCache)
+IncludeCollector::IncludeCollector(StringCache<Utils::PathString> &filePathCache)
: m_filePathCache(filePathCache)
{
}
diff --git a/src/tools/clangpchmanagerbackend/source/includecollector.h b/src/tools/clangpchmanagerbackend/source/includecollector.h
index 09575abd42..ba485ea33d 100644
--- a/src/tools/clangpchmanagerbackend/source/includecollector.h
+++ b/src/tools/clangpchmanagerbackend/source/includecollector.h
@@ -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
diff --git a/src/tools/clangpchmanagerbackend/source/pchcreator.cpp b/src/tools/clangpchmanagerbackend/source/pchcreator.cpp
index 7ab04738eb..2ca4acb5e6 100644
--- a/src/tools/clangpchmanagerbackend/source/pchcreator.cpp
+++ b/src/tools/clangpchmanagerbackend/source/pchcreator.cpp
@@ -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";
diff --git a/src/tools/clangpchmanagerbackend/source/pchcreator.h b/src/tools/clangpchmanagerbackend/source/pchcreator.h
index 70fddd2964..1ea1e08037 100644
--- a/src/tools/clangpchmanagerbackend/source/pchcreator.h
+++ b/src/tools/clangpchmanagerbackend/source/pchcreator.h
@@ -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;
};
diff --git a/src/tools/clangrefactoringbackend/source/sourcerangeextractor.h b/src/tools/clangrefactoringbackend/source/sourcerangeextractor.h
index 05ba1f7132..5bd6cf75ab 100644
--- a/src/tools/clangrefactoringbackend/source/sourcerangeextractor.h
+++ b/src/tools/clangrefactoringbackend/source/sourcerangeextractor.h
@@ -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;
}
diff --git a/tests/unit/unittest/includecollector-test.cpp b/tests/unit/unittest/includecollector-test.cpp
index 663de3fedd..e574733892 100644
--- a/tests/unit/unittest/includecollector-test.cpp
+++ b/tests/unit/unittest/includecollector-test.cpp
@@ -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};
};
diff --git a/tests/unit/unittest/pchcreator-test.cpp b/tests/unit/unittest/pchcreator-test.cpp
index b4d3977c2f..274cd207f2 100644
--- a/tests/unit/unittest/pchcreator-test.cpp
+++ b/tests/unit/unittest/pchcreator-test.cpp
@@ -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";