C++: fix built-in code model to work with shared_ptr on MSVC 2017

These changes target Find Usages feature to work with shared_ptr.
Improve libs/3rdparty/cplusplus and plugins/cplusplus:
parse __declspec() attribute,
call to variadic function template without specified template arguments,
if constexpr,
c++11 attributes [[value]],
function templates with default parameters,
resolve order for function vs template with default parameter,
template operator->() with default arguments,
template specialization with numeric values,
find best partial specialization,
fix partial specialization for non-first specialized argument

Fixes: QTCREATORBUG-7866
Fixes: QTCREATORBUG-20781
Fixes: QTCREATORBUG-22857
Fixes: QTCREATORBUG-17825
Change-Id: I31a080f7729edfb2ee9650f1aff48daeba5a673b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Nikolai Kosjar <pinaceae.pinus@gmail.com>
This commit is contained in:
Volodymyr Zibarov
2020-05-14 23:07:05 +03:00
parent be97943372
commit 9ee693ee22
43 changed files with 1198 additions and 58 deletions

View File

@@ -863,6 +863,7 @@ bool CodeFormatter::tryDeclaration()
case T_AUTO:
case T___TYPEOF__:
case T___ATTRIBUTE__:
case T___DECLSPEC:
case T_STATIC:
case T_FRIEND:
case T_CONST:
@@ -1590,7 +1591,7 @@ void QtStyleCodeFormatter::adjustIndent(const Tokens &tokens, int lexerState, in
if (m_styleSettings.indentDeclarationsRelativeToAccessSpecifiers
&& topState.type == class_open) {
if (tokenAt(1).is(T_COLON) || tokenAt(2).is(T_COLON)
|| (tokenAt(tokenCount() - 1).is(T_COLON) && tokenAt(1).is(T___ATTRIBUTE__))) {
|| (tokenAt(tokenCount() - 1).is(T_COLON) && (tokenAt(1).is(T___ATTRIBUTE__) || tokenAt(1).is(T___DECLSPEC)))) {
*indentDepth = topState.savedIndentDepth;
if (m_styleSettings.indentAccessSpecifiers)
*indentDepth += m_tabSettings.m_indentSize;

View File

@@ -341,6 +341,7 @@ QString Utils::toString(CPlusPlus::Kind kind)
TOKEN_AND_ALIASES(T___ATTRIBUTE__, T___ATTRIBUTE);
TOKEN(T___THREAD);
TOKEN_AND_ALIASES(T___TYPEOF__, T_TYPEOF/T___TYPEOF);
TOKEN_AND_ALIASES(T___DECLSPEC, T__DECLSPEC);
TOKEN(T_AT_CATCH);
TOKEN(T_AT_CLASS);
TOKEN(T_AT_COMPATIBILITY_ALIAS);

View File

@@ -98,12 +98,13 @@ static unsigned firstTypeSpecifierWithoutFollowingAttribute(
case T_TYPEDEF:
case T_CONSTEXPR:
case T___ATTRIBUTE__:
case T___DECLSPEC:
continue;
default:
// Check if attributes follow
for (unsigned i = index; i <= endToken; ++i) {
const int tokenKind = translationUnit->tokenKind(i);
if (tokenKind == T___ATTRIBUTE__)
if (tokenKind == T___ATTRIBUTE__ || tokenKind == T___DECLSPEC)
return 0;
}
*found = true;