Clang: Improve interfaces

The interfaces should never used to handle ownership. So it is now using
protected destructors. Copy operations are forbidden too.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c35-a-base-class-destructor-should-be-either-public-and-virtual-or-protected-and-nonvirtual

Change-Id: Ib0b60a73a7ec130973b5cb0095cc5b2f10fa0758
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-03-12 14:08:18 +01:00
parent f1e02c0826
commit 9c4bfbe20a
52 changed files with 186 additions and 316 deletions

View File

@@ -67,6 +67,5 @@ SOURCES += \
$$PWD/sourcerangefilter.cpp \
$$PWD/symbolindexer.cpp \
$$PWD/symbolentry.cpp \
$$PWD/symbolstorageinterface.cpp \
$$PWD/projectpartartefact.cpp \
$$PWD/filestatuscache.cpp

View File

@@ -56,6 +56,8 @@ public:
using size_type = Internal::FileStatusCacheEntries::size_type;
FileStatusCache(FilePathCachingInterface &filePathCache);
FileStatusCache &operator=(const FileStatusCache &) = delete;
FileStatusCache(const FileStatusCache &) = delete;
long long lastModifiedTime(ClangBackEnd::FilePathId filePathId) const;
void update(ClangBackEnd::FilePathId filePathId);

View File

@@ -27,4 +27,9 @@
namespace ClangBackEnd {
void SymbolIndexing::updateProjectParts(V2::ProjectPartContainers &&projectParts, V2::FileContainers &&generatedFiles)
{
m_indexer.updateProjectParts(std::move(projectParts), std::move(generatedFiles));
}
} // namespace ClangBackEnd

View File

@@ -62,10 +62,7 @@ public:
}
void updateProjectParts(V2::ProjectPartContainers &&projectParts,
V2::FileContainers &&generatedFiles)
{
m_indexer.updateProjectParts(std::move(projectParts), std::move(generatedFiles));
}
V2::FileContainers &&generatedFiles);
private:
FilePathCachingInterface &m_filePathCache;

View File

@@ -33,8 +33,15 @@ namespace ClangBackEnd {
class SymbolIndexingInterface
{
public:
SymbolIndexingInterface() = default;
SymbolIndexingInterface(const SymbolIndexingInterface&) = delete;
SymbolIndexingInterface &operator=(const SymbolIndexingInterface&) = delete;
virtual void updateProjectParts(V2::ProjectPartContainers &&projectParts,
V2::FileContainers &&generatedFiles) = 0;
protected:
~SymbolIndexingInterface() = default;
};
} // namespace ClangBackEnd

View File

@@ -43,6 +43,10 @@ namespace ClangBackEnd {
class SymbolsCollectorInterface
{
public:
SymbolsCollectorInterface() = default;
SymbolsCollectorInterface(const SymbolsCollectorInterface &) = delete;
SymbolsCollectorInterface &operator=(const SymbolsCollectorInterface &) = delete;
virtual void addFiles(const FilePathIds &filePathIds,
const Utils::SmallStringVector &arguments) = 0;
@@ -58,6 +62,9 @@ public:
virtual const UsedMacros &usedMacros() const = 0;
virtual const FileStatuses &fileStatuses() const = 0;
virtual const SourceDependencies &sourceDependencies() const = 0;
protected:
~SymbolsCollectorInterface() = default;
};
} // namespace ClangBackEnd

View File

@@ -44,7 +44,6 @@ class SymbolStorageInterface
{
public:
SymbolStorageInterface() = default;
virtual ~SymbolStorageInterface();
SymbolStorageInterface(const SymbolStorageInterface &) = delete;
SymbolStorageInterface &operator=(const SymbolStorageInterface &) = delete;
@@ -65,6 +64,9 @@ public:
virtual Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(Utils::SmallStringView projectPartName) const = 0;
virtual long long fetchLowestLastModifiedTime(FilePathId sourceId) const = 0;
virtual Utils::optional<ProjectPartPch> fetchPrecompiledHeader(int projectPartId) const = 0;
protected:
~SymbolStorageInterface() = default;
};
} // namespace ClangBackEnd