aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpptools/cppcodeformatter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/cpptools/cppcodeformatter.cpp')
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index 170bf4c61c..d98b0022ec 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -199,6 +199,11 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
turnInto(substatement_open);
}
break;
+ case T_ARROW: // Trailing return type?
+ if (m_currentState.at(m_currentState.size() - 2).type == declaration_start) {
+ leave();
+ break;
+ }
default: tryExpression(); break;
} break;
@@ -783,7 +788,7 @@ bool CodeFormatter::tryExpression(bool alsoExpression)
newState = stream_op;
for (int i = m_currentState.size() - 1; i >= 0; --i) {
const int type = m_currentState.at(i).type;
- if (type == arglist_open) { // likely a left-shift instead
+ if (type == arglist_open || type == braceinit_open) { // likely a left-shift instead
newState = -1;
break;
}
@@ -863,6 +868,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:
@@ -1521,6 +1527,7 @@ void QtStyleCodeFormatter::adjustIndent(const Tokens &tokens, int lexerState, in
&& topState.type != block_open
&& topState.type != substatement_open
&& topState.type != brace_list_open
+ && topState.type != arglist_open
&& !topWasMaybeElse) {
*indentDepth = topState.savedIndentDepth;
*paddingDepth = 0;
@@ -1589,7 +1596,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;