From 4dd4d088c5514030bc1e6b088f582f9fc03c98b5 Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Wed, 19 Dec 2018 20:10:27 +0800 Subject: [PATCH] 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 --- src/libs/cplusplus/TypePrettyPrinter.cpp | 2 +- .../typeprettyprinter/tst_typeprettyprinter.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index 3e073083614..dabbcf00630 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -401,7 +401,7 @@ void TypePrettyPrinter::visit(Function *type) if (_overview->showReturnTypes) { const QString returnType = _overview->prettyType(type->returnType()); if (!returnType.isEmpty()) { - if (!endsWithPtrOrRef(returnType)) + if (!endsWithPtrOrRef(returnType) || !(_overview->starBindFlags & Overview::BindToIdentifier)) _text.prepend(QLatin1Char(' ')); _text.prepend(returnType); } diff --git a/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter.cpp b/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter.cpp index 503eea51bba..04d9fc683d2 100644 --- a/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter.cpp +++ b/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter.cpp @@ -438,16 +438,20 @@ void tst_TypePrettyPrinter::basic_data() addRow(fnTy("foo", voidTy(), ptr(voidTy())), bindToAll, "void foo(void*)", "foo"); // 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", 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(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", 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(templTy(fnTy("foo", voidTy(), voidTy()), true), bindToNothing, "template\nvoid foo()", "foo");