summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/clangbackendipc/codecompletion.h4
-rw-r--r--src/tools/clangbackend/ipcsource/clangdocument.cpp13
-rw-r--r--src/tools/clangbackend/ipcsource/clangdocument.h2
-rw-r--r--src/tools/clangbackend/ipcsource/clangstring.h7
-rw-r--r--src/tools/clangbackend/ipcsource/clangtype.cpp13
-rw-r--r--src/tools/clangbackend/ipcsource/clangtype.h4
-rw-r--r--src/tools/clangbackend/ipcsource/codecompletionsextractor.cpp18
-rw-r--r--src/tools/clangbackend/ipcsource/codecompletionsextractor.h6
-rw-r--r--src/tools/clangbackend/ipcsource/cursor.cpp20
-rw-r--r--src/tools/clangbackend/ipcsource/cursor.h5
-rw-r--r--src/tools/clangbackend/ipcsource/sourcelocation.cpp12
-rw-r--r--src/tools/clangbackend/ipcsource/sourcelocation.h2
-rw-r--r--src/tools/clangbackend/ipcsource/sourcerange.cpp13
-rw-r--r--src/tools/clangbackend/ipcsource/sourcerange.h2
-rw-r--r--src/tools/clangbackend/ipcsource/unsavedfile.cpp12
-rw-r--r--src/tools/clangbackend/ipcsource/unsavedfile.h2
16 files changed, 71 insertions, 64 deletions
diff --git a/src/libs/clangbackendipc/codecompletion.h b/src/libs/clangbackendipc/codecompletion.h
index 4b9b2ed7c2..bd63115da0 100644
--- a/src/libs/clangbackendipc/codecompletion.h
+++ b/src/libs/clangbackendipc/codecompletion.h
@@ -208,6 +208,6 @@ private:
CMBIPC_EXPORT QDebug operator<<(QDebug debug, CodeCompletion::Kind kind);
-std::ostream &operator<<(std::ostream &os, const CodeCompletion::Kind kind);
-std::ostream &operator<<(std::ostream &os, const CodeCompletion::Availability availability);
+CMBIPC_EXPORT std::ostream &operator<<(std::ostream &os, const CodeCompletion::Kind kind);
+CMBIPC_EXPORT std::ostream &operator<<(std::ostream &os, const CodeCompletion::Availability availability);
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/clangdocument.cpp b/src/tools/clangbackend/ipcsource/clangdocument.cpp
index 117a77a848..3cfcfabe09 100644
--- a/src/tools/clangbackend/ipcsource/clangdocument.cpp
+++ b/src/tools/clangbackend/ipcsource/clangdocument.cpp
@@ -423,12 +423,15 @@ bool operator==(const Document &first, const Document &second)
&& first.projectPart().id() == second.projectPart().id();
}
-void PrintTo(const Document &document, ::std::ostream *os)
+std::ostream &operator<<(std::ostream &os, const Document &document)
{
- *os << "Document("
- << document.filePath().constData() << ", "
- << document.projectPart().id().constData() << ", "
- << document.documentRevision() << ")";
+ os << "("
+ << document.filePath() << ", "
+ << document.projectPart().id() << ", "
+ << document.documentRevision()
+ << ")";
+
+ return os;
}
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/clangdocument.h b/src/tools/clangbackend/ipcsource/clangdocument.h
index 138e96a946..15555ace10 100644
--- a/src/tools/clangbackend/ipcsource/clangdocument.h
+++ b/src/tools/clangbackend/ipcsource/clangdocument.h
@@ -133,5 +133,5 @@ private:
};
bool operator==(const Document &first, const Document &second);
-void PrintTo(const Document &document, ::std::ostream *os);
+std::ostream &operator<<(std::ostream &os, const Document &document);
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/clangstring.h b/src/tools/clangbackend/ipcsource/clangstring.h
index 09049153ab..685055cff0 100644
--- a/src/tools/clangbackend/ipcsource/clangstring.h
+++ b/src/tools/clangbackend/ipcsource/clangstring.h
@@ -107,7 +107,6 @@ public:
{
return second == first;
}
-
template<typename Type,
typename = typename std::enable_if<std::is_pointer<Type>::value>::type
>
@@ -124,11 +123,9 @@ public:
return second == first;
}
- friend std::ostream &operator<<(std::ostream &out, const ClangString &string)
+ friend std::ostream &operator<<(std::ostream &os, const ClangString &string)
{
- out << string.cString();
-
- return out;
+ return os << string.cString();
}
private:
diff --git a/src/tools/clangbackend/ipcsource/clangtype.cpp b/src/tools/clangbackend/ipcsource/clangtype.cpp
index 6b14b38dd8..dd0e192f7a 100644
--- a/src/tools/clangbackend/ipcsource/clangtype.cpp
+++ b/src/tools/clangbackend/ipcsource/clangtype.cpp
@@ -144,17 +144,20 @@ bool operator==(Type first, Type second)
return clang_equalTypes(first.cxType, second.cxType);
}
-void PrintTo(CXTypeKind typeKind, ::std::ostream* os)
+std::ostream &operator<<(std::ostream &os, CXTypeKind typeKind)
{
ClangString typeKindSpelling(clang_getTypeKindSpelling(typeKind));
- *os << typeKindSpelling.cString();
+
+ return os << typeKindSpelling.cString();
}
-void PrintTo(const Type &type, ::std::ostream* os)
+std::ostream &operator<<(std::ostream &os, const Type &type)
{
ClangString typeKindSpelling(clang_getTypeKindSpelling(type.kind()));
- *os << typeKindSpelling.cString()
- << ": \"" << type.spelling().cString() << "\"";
+ os << typeKindSpelling
+ << ": \"" << type.spelling() << "\"";
+
+ return os;
}
diff --git a/src/tools/clangbackend/ipcsource/clangtype.h b/src/tools/clangbackend/ipcsource/clangtype.h
index 71ea1506ee..f26fe080f6 100644
--- a/src/tools/clangbackend/ipcsource/clangtype.h
+++ b/src/tools/clangbackend/ipcsource/clangtype.h
@@ -77,6 +77,6 @@ private:
bool operator==(Type first, Type second);
-void PrintTo(CXTypeKind typeKind, ::std::ostream* os);
-void PrintTo(const Type &type, ::std::ostream* os);
+std::ostream &operator<<(std::ostream &os, CXTypeKind typeKind);
+std::ostream &operator<<(std::ostream &os, const Type &type);
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/codecompletionsextractor.cpp b/src/tools/clangbackend/ipcsource/codecompletionsextractor.cpp
index cac1f50e29..1c810e5069 100644
--- a/src/tools/clangbackend/ipcsource/codecompletionsextractor.cpp
+++ b/src/tools/clangbackend/ipcsource/codecompletionsextractor.cpp
@@ -28,10 +28,6 @@
#include "clangstring.h"
#include "codecompletionchunkconverter.h"
-#ifdef CLANGBACKEND_TESTS
-#include <gtest/gtest.h>
-#endif
-
#include <QDebug>
namespace ClangBackEnd {
@@ -344,15 +340,15 @@ const CodeCompletion &CodeCompletionsExtractor::currentCodeCompletion() const
return currentCodeCompletion_;
}
-#ifdef CLANGBACKEND_TESTS
-void PrintTo(const CodeCompletionsExtractor &extractor, std::ostream *os)
+std::ostream &operator<<(std::ostream &os, const CodeCompletionsExtractor &extractor)
{
- *os << "name: " << ::testing::PrintToString(extractor.currentCodeCompletion().text())
- << ", kind: " << ::testing::PrintToString(extractor.currentCodeCompletion().completionKind())
- << ", priority: " << extractor.currentCodeCompletion().priority()
- << ", kind: " << ::testing::PrintToString(extractor.currentCodeCompletion().availability());
+ os << "name: " << extractor.currentCodeCompletion().text()
+ << ", kind: " << extractor.currentCodeCompletion().completionKind()
+ << ", priority: " << extractor.currentCodeCompletion().priority()
+ << ", kind: " << extractor.currentCodeCompletion().availability();
+
+ return os;
}
-#endif
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/codecompletionsextractor.h b/src/tools/clangbackend/ipcsource/codecompletionsextractor.h
index 8a4c7c03ab..57e9bd5afc 100644
--- a/src/tools/clangbackend/ipcsource/codecompletionsextractor.h
+++ b/src/tools/clangbackend/ipcsource/codecompletionsextractor.h
@@ -31,6 +31,8 @@
#include <QVector>
+#include <iosfwd>
+
namespace ClangBackEnd {
class CodeCompletionsExtractor
@@ -78,7 +80,5 @@ private:
uint cxCodeCompleteResultIndex = -1;
};
-#ifdef CLANGBACKEND_TESTS
-void PrintTo(const CodeCompletionsExtractor &extractor, ::std::ostream* os);
-#endif
+std::ostream &operator<<(std::ostream &os, const CodeCompletionsExtractor &extractor);
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/cursor.cpp b/src/tools/clangbackend/ipcsource/cursor.cpp
index c9f8dd5ab8..518fd013d2 100644
--- a/src/tools/clangbackend/ipcsource/cursor.cpp
+++ b/src/tools/clangbackend/ipcsource/cursor.cpp
@@ -403,29 +403,31 @@ bool operator!=(const Cursor &first, const Cursor &second)
return !(first == second);
}
-void PrintTo(CXCursorKind cursorKind, ::std::ostream *os)
+std::ostream &operator<<(std::ostream &os, CXCursorKind cursorKind)
{
ClangString cursorKindSpelling(clang_getCursorKindSpelling(cursorKind));
- *os << cursorKindSpelling.cString();
+ return os << cursorKindSpelling.cString();
}
-void PrintTo(const Cursor &cursor, ::std::ostream*os)
+std::ostream &operator<<(std::ostream &os, const Cursor &cursor)
{
if (cursor.isValid()) {
ClangString cursorKindSpelling(clang_getCursorKindSpelling(cursor.kind()));
- *os << cursorKindSpelling.cString() << " ";
+ os << cursorKindSpelling << " ";
auto identifier = cursor.displayName();
if (identifier.hasContent()) {
- *os << "\""
- << identifier
- << "\": ";
+ os << "\""
+ << identifier
+ << "\": ";
}
- PrintTo(cursor.sourceLocation(), os);
+ os << cursor.sourceLocation();
} else {
- *os << "Invalid cursor!";
+ os << "Invalid cursor!";
}
+
+ return os;
}
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/cursor.h b/src/tools/clangbackend/ipcsource/cursor.h
index 234ad900f9..0187d8448b 100644
--- a/src/tools/clangbackend/ipcsource/cursor.h
+++ b/src/tools/clangbackend/ipcsource/cursor.h
@@ -130,6 +130,7 @@ void Cursor::visit(VisitorCallback visitorCallback) const
bool operator==(const Cursor &first, const Cursor &second);
bool operator!=(const Cursor &first, const Cursor &second);
-void PrintTo(CXCursorKind cursorKind, ::std::ostream *os);
-void PrintTo(const Cursor &cursor, ::std::ostream* os);
+std::ostream &operator<<(std::ostream &os, CXCursorKind cursorKind);
+std::ostream &operator<<(std::ostream &os, const Cursor &cursor);
+
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/sourcelocation.cpp b/src/tools/clangbackend/ipcsource/sourcelocation.cpp
index 5d54600c3c..161ed5b0a5 100644
--- a/src/tools/clangbackend/ipcsource/sourcelocation.cpp
+++ b/src/tools/clangbackend/ipcsource/sourcelocation.cpp
@@ -114,15 +114,17 @@ SourceLocation::operator CXSourceLocation() const
return cxSourceLocation;
}
-void PrintTo(const SourceLocation &sourceLocation, std::ostream *os)
+std::ostream &operator<<(std::ostream &os, const SourceLocation &sourceLocation)
{
auto filePath = sourceLocation.filePath();
if (filePath.hasContent())
- *os << filePath.constData() << ", ";
+ os << filePath << ", ";
- *os << "line: " << sourceLocation.line()
- << ", column: "<< sourceLocation.column()
- << ", offset: "<< sourceLocation.offset();
+ os << "line: " << sourceLocation.line()
+ << ", column: "<< sourceLocation.column()
+ << ", offset: "<< sourceLocation.offset();
+
+ return os;
}
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/sourcelocation.h b/src/tools/clangbackend/ipcsource/sourcelocation.h
index 7379773e50..65c3ec69ad 100644
--- a/src/tools/clangbackend/ipcsource/sourcelocation.h
+++ b/src/tools/clangbackend/ipcsource/sourcelocation.h
@@ -72,6 +72,6 @@ private:
bool operator==(const SourceLocation &first, const SourceLocation &second);
-void PrintTo(const SourceLocation &sourceLocation, ::std::ostream* os);
+std::ostream &operator<<(std::ostream &os, const SourceLocation &sourceLocation);
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/sourcerange.cpp b/src/tools/clangbackend/ipcsource/sourcerange.cpp
index 86029cfd3e..20c6efb5e6 100644
--- a/src/tools/clangbackend/ipcsource/sourcerange.cpp
+++ b/src/tools/clangbackend/ipcsource/sourcerange.cpp
@@ -100,13 +100,14 @@ bool operator==(const SourceRange &first, const SourceRange &second)
return clang_equalRanges(first.cxSourceRange, second.cxSourceRange);
}
-void PrintTo(const SourceRange &sourceRange, ::std::ostream* os)
+std::ostream &operator<<(std::ostream &os, const SourceRange &sourceRange)
{
- *os << "[";
- PrintTo(sourceRange.start(), os);
- *os << ", ";
- PrintTo(sourceRange.end(), os);
- *os << "]";
+ os << "["
+ << sourceRange.start() << ", "
+ << sourceRange.end()
+ << "]";
+
+ return os;
}
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/sourcerange.h b/src/tools/clangbackend/ipcsource/sourcerange.h
index 955896ccfb..b8083e8695 100644
--- a/src/tools/clangbackend/ipcsource/sourcerange.h
+++ b/src/tools/clangbackend/ipcsource/sourcerange.h
@@ -61,5 +61,5 @@ private:
};
bool operator==(const SourceRange &first, const SourceRange &second);
-void PrintTo(const SourceRange &sourceRange, ::std::ostream* os);
+std::ostream &operator<<(std::ostream &os, const SourceRange &sourceRange);
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/unsavedfile.cpp b/src/tools/clangbackend/ipcsource/unsavedfile.cpp
index 8822e2939e..923d4456e8 100644
--- a/src/tools/clangbackend/ipcsource/unsavedfile.cpp
+++ b/src/tools/clangbackend/ipcsource/unsavedfile.cpp
@@ -97,12 +97,14 @@ bool UnsavedFile::replaceAt(uint position, uint length, const Utf8String &replac
return false;
}
-void PrintTo(const UnsavedFile &unsavedFile, std::ostream *os)
+std::ostream &operator<<(std::ostream &os, const UnsavedFile &unsavedFile)
{
- *os << "UnsavedFile("
- << unsavedFile.m_filePath.constData() << ", "
- << unsavedFile.m_fileContent.constData() << ", "
- << unsavedFile.m_fileContent.byteSize() << ")";
+ os << "UnsavedFile("
+ << unsavedFile.m_filePath << ", "
+ << unsavedFile.m_fileContent << ", "
+ << unsavedFile.m_fileContent << ")";
+
+ return os;
}
} // namespace ClangBackEnd
diff --git a/src/tools/clangbackend/ipcsource/unsavedfile.h b/src/tools/clangbackend/ipcsource/unsavedfile.h
index ff1f354c87..3021da89b5 100644
--- a/src/tools/clangbackend/ipcsource/unsavedfile.h
+++ b/src/tools/clangbackend/ipcsource/unsavedfile.h
@@ -34,7 +34,7 @@ using uint = unsigned int;
class UnsavedFile
{
public:
- friend void PrintTo(const UnsavedFile &unsavedFile, std::ostream *os);
+ friend std::ostream &operator<<(std::ostream &os, const UnsavedFile &unsavedFile);
UnsavedFile();
UnsavedFile(const Utf8String &filePath, const Utf8String &fileContent);