forked from qt-creator/qt-creator
C++: fix StarBindFlags behavior
Without Overview::BindToIdentifier, a space between return type(endsWithPtrOrRef) and identifier should be added. Change-Id: I3cd2d053bf137b35a58e7422f45cbd5b96eeb151 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -401,7 +401,7 @@ void TypePrettyPrinter::visit(Function *type)
|
|||||||
if (_overview->showReturnTypes) {
|
if (_overview->showReturnTypes) {
|
||||||
const QString returnType = _overview->prettyType(type->returnType());
|
const QString returnType = _overview->prettyType(type->returnType());
|
||||||
if (!returnType.isEmpty()) {
|
if (!returnType.isEmpty()) {
|
||||||
if (!endsWithPtrOrRef(returnType))
|
if (!endsWithPtrOrRef(returnType) || !(_overview->starBindFlags & Overview::BindToIdentifier))
|
||||||
_text.prepend(QLatin1Char(' '));
|
_text.prepend(QLatin1Char(' '));
|
||||||
_text.prepend(returnType);
|
_text.prepend(returnType);
|
||||||
}
|
}
|
||||||
|
@@ -438,16 +438,20 @@ void tst_TypePrettyPrinter::basic_data()
|
|||||||
addRow(fnTy("foo", voidTy(), ptr(voidTy())), bindToAll, "void foo(void*)", "foo");
|
addRow(fnTy("foo", voidTy(), ptr(voidTy())), bindToAll, "void foo(void*)", "foo");
|
||||||
|
|
||||||
// Functions with pointer or reference returns
|
// Functions with pointer or reference returns
|
||||||
addRow(ptr(fnTy("foo", ptr(voidTy()), intTy())), bindToNothing, "void *(*foo)(int)", "foo");
|
addRow(ptr(fnTy("foo", ptr(voidTy()), intTy())), bindToNothing, "void * (*foo)(int)", "foo");
|
||||||
|
addRow(ptr(fnTy("foo", ptr(voidTy()), intTy())), Overview::BindToTypeName, "void* (*foo)(int)", "foo");
|
||||||
addRow(ptr(fnTy("foo", ptr(voidTy()), intTy())), bindToAll, "void*(*foo)(int)", "foo");
|
addRow(ptr(fnTy("foo", ptr(voidTy()), intTy())), bindToAll, "void*(*foo)(int)", "foo");
|
||||||
|
|
||||||
addRow(ptr(fnTy("foo", ref(voidTy()), ptr(voidTy()))), bindToNothing, "void &(*foo)(void *)", "foo");
|
addRow(ptr(fnTy("foo", ref(voidTy()), ptr(voidTy()))), bindToNothing, "void & (*foo)(void *)", "foo");
|
||||||
|
addRow(ptr(fnTy("foo", ref(voidTy()), ptr(voidTy()))), Overview::BindToTypeName, "void& (*foo)(void*)", "foo");
|
||||||
addRow(ptr(fnTy("foo", ref(voidTy()), ptr(voidTy()))), bindToAll, "void&(*foo)(void*)", "foo");
|
addRow(ptr(fnTy("foo", ref(voidTy()), ptr(voidTy()))), bindToAll, "void&(*foo)(void*)", "foo");
|
||||||
|
|
||||||
addRow(fnTy("foo", ptr(voidTy()), intTy()), bindToNothing, "void *foo(int)", "foo");
|
addRow(fnTy("foo", ptr(voidTy()), intTy()), bindToNothing, "void * foo(int)", "foo");
|
||||||
|
addRow(fnTy("foo", ptr(voidTy()), intTy()), Overview::BindToTypeName, "void* foo(int)", "foo");
|
||||||
addRow(fnTy("foo", ptr(voidTy()), intTy()), bindToAll, "void*foo(int)", "foo");
|
addRow(fnTy("foo", ptr(voidTy()), intTy()), bindToAll, "void*foo(int)", "foo");
|
||||||
|
|
||||||
addRow(fnTy("foo", ref(voidTy()), ptr(voidTy())), bindToNothing, "void &foo(void *)", "foo");
|
addRow(fnTy("foo", ref(voidTy()), ptr(voidTy())), bindToNothing, "void & foo(void *)", "foo");
|
||||||
|
addRow(fnTy("foo", ref(voidTy()), ptr(voidTy())), Overview::BindToTypeName, "void& foo(void*)", "foo");
|
||||||
addRow(fnTy("foo", ref(voidTy()), ptr(voidTy())), bindToAll, "void&foo(void*)", "foo");
|
addRow(fnTy("foo", ref(voidTy()), ptr(voidTy())), bindToAll, "void&foo(void*)", "foo");
|
||||||
|
|
||||||
addRow(templTy(fnTy("foo", voidTy(), voidTy()), true), bindToNothing, "template<class T>\nvoid foo()", "foo");
|
addRow(templTy(fnTy("foo", voidTy(), voidTy()), true), bindToNothing, "template<class T>\nvoid foo()", "foo");
|
||||||
|
Reference in New Issue
Block a user