C++: Fix function return type printing.

We used to print T * foo(), but our style suggests T *foo().

Change-Id: Ie3b0ce6b620785ec98aeb394f7955ce959440619
Reviewed-on: http://codereview.qt-project.org/4634
Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
This commit is contained in:
Christian Kamm
2011-09-12 08:41:53 +02:00
parent 903c6b60cd
commit 151475a0fe
2 changed files with 16 additions and 1 deletions

View File

@@ -289,6 +289,12 @@ void TypePrettyPrinter::visit(ArrayType *type)
acceptType(type->elementType());
}
static bool endsWithPtrOrRef(const QString &type)
{
return type.endsWith(QLatin1Char('*'))
|| type.endsWith(QLatin1Char('&'));
}
void TypePrettyPrinter::visit(Function *type)
{
if (_needsParens) {
@@ -309,7 +315,8 @@ void TypePrettyPrinter::visit(Function *type)
if (_overview->showReturnTypes()) {
const QString returnType = _overview->prettyType(type->returnType());
if (!returnType.isEmpty()) {
_text.prepend(QLatin1Char(' '));
if (!endsWithPtrOrRef(returnType))
_text.prepend(QLatin1Char(' '));
_text.prepend(returnType);
}
}