forked from qt-creator/qt-creator
C++: fix code completion for decltyped type
example:
struct Foo { int bar; };
Foo foo() { return Foo; }
typedef decltype(foo()) TypedefedFooWithDecltype;
void fun()
{
decltype(foo()) decltypeFoo;
decltypeFoo.;// code completion should work here
TypedefedFooWithDecltype typedefedFooWithDecltype;
typedefedFooWithDecltype.;// code completion should work here
}
Started-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Task-number: QTCREATORBUG-14483
Change-Id: I296ceed9d896c68cf0651265afb08a1fc42f9a68
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
57e3714db4
commit
de68ac5407
17
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
17
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -1921,9 +1921,22 @@ bool Bind::visit(SimpleDeclarationAST *ast)
|
||||
methodKey = methodKeyForInvokableToken(tokenKind(ast->qt_invokable_token));
|
||||
|
||||
// unsigned qt_invokable_token = ast->qt_invokable_token;
|
||||
unsigned declTypeStartOfExpression = 0;
|
||||
unsigned declTypeEndOfExpression = 0;
|
||||
bool isTypedef = false;
|
||||
FullySpecifiedType type;
|
||||
for (SpecifierListAST *it = ast->decl_specifier_list; it; it = it->next) {
|
||||
type = this->specifier(it->value, type);
|
||||
if (type.isTypedef())
|
||||
isTypedef = true;
|
||||
|
||||
type.setTypedef(isTypedef);
|
||||
if (type.isDecltype()) {
|
||||
if (DecltypeSpecifierAST *decltypeSpec = it->value->asDecltypeSpecifier()) {
|
||||
declTypeStartOfExpression = decltypeSpec->expression->firstToken();
|
||||
declTypeEndOfExpression = decltypeSpec->expression->lastToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Symbol *> **symbolTail = &ast->symbols;
|
||||
@@ -1982,6 +1995,9 @@ bool Bind::visit(SimpleDeclarationAST *ast)
|
||||
unsigned endOfExpression = initializer->lastToken();
|
||||
decl->setInitializer(asStringLiteral(startOfExpression, endOfExpression));
|
||||
}
|
||||
} else if (declTy.isDecltype()) {
|
||||
decl->setInitializer(asStringLiteral(declTypeStartOfExpression,
|
||||
declTypeEndOfExpression));
|
||||
}
|
||||
|
||||
if (_scope->isClass()) {
|
||||
@@ -3028,6 +3044,7 @@ bool Bind::visit(TypeofSpecifierAST *ast)
|
||||
bool Bind::visit(DecltypeSpecifierAST *ast)
|
||||
{
|
||||
_type = this->expression(ast->expression);
|
||||
_type.setDecltype(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,12 @@ bool FullySpecifiedType::isAuto() const
|
||||
void FullySpecifiedType::setAuto(bool isAuto)
|
||||
{ f._isAuto = isAuto; }
|
||||
|
||||
bool FullySpecifiedType::isDecltype() const
|
||||
{ return f._isDecltype; }
|
||||
|
||||
void FullySpecifiedType::setDecltype(bool isDecltype)
|
||||
{ f._isDecltype = isDecltype; }
|
||||
|
||||
bool FullySpecifiedType::isRegister() const
|
||||
{ return f._isRegister; }
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ public:
|
||||
bool isAuto() const;
|
||||
void setAuto(bool isAuto);
|
||||
|
||||
bool isDecltype() const;
|
||||
void setDecltype(bool isDecltype);
|
||||
|
||||
bool isRegister() const;
|
||||
void setRegister(bool isRegister);
|
||||
|
||||
@@ -125,6 +128,7 @@ private:
|
||||
// storage class specifiers
|
||||
unsigned _isFriend: 1;
|
||||
unsigned _isAuto: 1;
|
||||
unsigned _isDecltype: 1;
|
||||
unsigned _isRegister: 1;
|
||||
unsigned _isStatic: 1;
|
||||
unsigned _isExtern: 1;
|
||||
|
||||
Reference in New Issue
Block a user