forked from qt-creator/qt-creator
C++: Print numeric template arguments in NamePrettyPrinter
Improve type printed for template specializations with numeric
or bool values.
Code example:
template<bool B, class T> struct enable_if{};
template<class T> struct enable_if<true, T>{ typedef T type; };
In outline: "enable_if<_Tp1, T> <T>" becomes "enable_if<true, T> <T>"
TemplateArgument class holds pointer to numeric literal owned
by CppDocument, so remove Control::squeeze() to not release
numericLiterals in CppDocument::releaseSourceAndAST()
This based on TemplateArgument class introduced in commit
9ee693ee22
Change-Id: Ib787a5e402c3e8d8467b520347a26afa6087d4bd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
5
src/libs/3rdparty/cplusplus/Control.cpp
vendored
5
src/libs/3rdparty/cplusplus/Control.cpp
vendored
@@ -821,11 +821,6 @@ bool Control::hasSymbol(Symbol *symbol) const
|
|||||||
return std::find(d->symbols.begin(), d->symbols.end(), symbol) != d->symbols.end();
|
return std::find(d->symbols.begin(), d->symbols.end(), symbol) != d->symbols.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::squeeze()
|
|
||||||
{
|
|
||||||
d->numericLiterals.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
TopLevelDeclarationProcessor *Control::topLevelDeclarationProcessor() const
|
TopLevelDeclarationProcessor *Control::topLevelDeclarationProcessor() const
|
||||||
{
|
{
|
||||||
return d->processor;
|
return d->processor;
|
||||||
|
|||||||
2
src/libs/3rdparty/cplusplus/Control.h
vendored
2
src/libs/3rdparty/cplusplus/Control.h
vendored
@@ -217,8 +217,6 @@ public:
|
|||||||
bool hasSymbol(Symbol *symbol) const;
|
bool hasSymbol(Symbol *symbol) const;
|
||||||
void addSymbol(Symbol *symbol);
|
void addSymbol(Symbol *symbol);
|
||||||
|
|
||||||
void squeeze();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Data;
|
class Data;
|
||||||
friend class Data;
|
friend class Data;
|
||||||
|
|||||||
@@ -711,8 +711,6 @@ void Document::releaseSourceAndAST()
|
|||||||
if (!_keepSourceAndASTCount.deref()) {
|
if (!_keepSourceAndASTCount.deref()) {
|
||||||
_source.clear();
|
_source.clear();
|
||||||
_translationUnit->release();
|
_translationUnit->release();
|
||||||
if (_control)
|
|
||||||
_control->squeeze();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,13 @@ void NamePrettyPrinter::visit(const TemplateNameId *name)
|
|||||||
if (index != 0)
|
if (index != 0)
|
||||||
_name += QLatin1String(", ");
|
_name += QLatin1String(", ");
|
||||||
|
|
||||||
FullySpecifiedType argTy = name->templateArgumentAt(index).type();
|
TemplateArgument templArg = name->templateArgumentAt(index);
|
||||||
QString arg = overview()->prettyType(argTy);
|
QString arg;
|
||||||
|
if (templArg.type().isValid())
|
||||||
|
arg = overview()->prettyType(templArg.type());
|
||||||
|
else if (const NumericLiteral *num = templArg.numericLiteral())
|
||||||
|
arg = QString::fromLatin1(num->chars(), num->size());
|
||||||
|
|
||||||
if (arg.isEmpty())
|
if (arg.isEmpty())
|
||||||
_name += QString::fromLatin1("_Tp%1").arg(index + 1);
|
_name += QString::fromLatin1("_Tp%1").arg(index + 1);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user