From 87fba6606f052a10b2fe3d7e304858560c291d7f Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Tue, 26 Nov 2013 16:23:56 +0100 Subject: TypePrettyPrinter; Add space to default parameter formatting Task-number: QTCREATORBUG-10230 Change-Id: Ib93b9438a20f66cd3c9acc0ff074c78fff430337 Reviewed-by: Nikolai Kosjar --- src/libs/cplusplus/TypePrettyPrinter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libs/cplusplus') diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index 6ec363ba92..364edb66af 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -436,7 +436,7 @@ void TypePrettyPrinter::visit(Function *type) if (_overview->showDefaultArguments) { if (const StringLiteral *initializer = arg->initializer()) { - _text += QLatin1String(" ="); + _text += QLatin1String(" = "); _text += QString::fromUtf8(initializer->chars(), initializer->size()); } } -- cgit v1.2.1 From 1d834c1126dde58dd71e595b3f5e135cc0ca4dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sch=C3=A4fer?= Date: Tue, 26 Nov 2013 21:56:30 +0100 Subject: Preprocessor Enginge: fix bug in pp-engine.cpp Preprocessor variables __LINE__,__FILE__,__TIME__,__DATE__ where destroying the following systems when affected variables were standing within the same line with those variables: * highlighting * refactoring * local renaming Task-number: QTCREATORBUG-8036 Change-Id: I1a4b919d15812872ca5a8e63b1031ec1ab144c22 Reviewed-by: Nikolai Kosjar --- src/libs/cplusplus/pp-engine.cpp | 44 +--------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) (limited to 'src/libs/cplusplus') diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 05a7a083d3..48736f805e 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -906,49 +906,7 @@ bool Preprocessor::handleIdentifier(PPToken *tk) { ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true); - static const QByteArray ppLine("__LINE__"); - static const QByteArray ppFile("__FILE__"); - static const QByteArray ppDate("__DATE__"); - static const QByteArray ppTime("__TIME__"); - - ByteArrayRef macroNameRef = tk->asByteArrayRef(); - - if (macroNameRef.size() == 8 - && macroNameRef[0] == '_' - && macroNameRef[1] == '_') { - PPToken newTk; - if (macroNameRef == ppLine) { - QByteArray txt = QByteArray::number(tk->lineno); - newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); - } else if (macroNameRef == ppFile) { - QByteArray txt; - txt.append('"'); - txt.append(m_env->currentFileUtf8); - txt.append('"'); - newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); - } else if (macroNameRef == ppDate) { - QByteArray txt; - txt.append('"'); - txt.append(QDate::currentDate().toString().toUtf8()); - txt.append('"'); - newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); - } else if (macroNameRef == ppTime) { - QByteArray txt; - txt.append('"'); - txt.append(QTime::currentTime().toString().toUtf8()); - txt.append('"'); - newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); - } - - if (newTk.hasSource()) { - newTk.f.newline = tk->newline(); - newTk.f.whitespace = tk->whitespace(); - *tk = newTk; - return false; - } - } - - Macro *macro = m_env->resolve(macroNameRef); + Macro *macro = m_env->resolve(tk->asByteArrayRef()); if (!macro || (tk->expanded() && m_state.m_tokenBuffer -- cgit v1.2.1 From 4edfe87b58ca8e5f92b6a10dcf98e3d240f38245 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 29 Nov 2013 10:53:45 +0100 Subject: Revert "Preprocessor Enginge: fix bug in pp-engine.cpp" Breaks highlighting for macros using the predefined macros. This reverts commit 1d834c1126dde58dd71e595b3f5e135cc0ca4dbd. Change-Id: Ic13c407e293a806a63ff30153864530df6a32e47 Reviewed-by: hjk Reviewed-by: Erik Verbruggen --- src/libs/cplusplus/pp-engine.cpp | 44 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/libs/cplusplus') diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 48736f805e..05a7a083d3 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -906,7 +906,49 @@ bool Preprocessor::handleIdentifier(PPToken *tk) { ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true); - Macro *macro = m_env->resolve(tk->asByteArrayRef()); + static const QByteArray ppLine("__LINE__"); + static const QByteArray ppFile("__FILE__"); + static const QByteArray ppDate("__DATE__"); + static const QByteArray ppTime("__TIME__"); + + ByteArrayRef macroNameRef = tk->asByteArrayRef(); + + if (macroNameRef.size() == 8 + && macroNameRef[0] == '_' + && macroNameRef[1] == '_') { + PPToken newTk; + if (macroNameRef == ppLine) { + QByteArray txt = QByteArray::number(tk->lineno); + newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); + } else if (macroNameRef == ppFile) { + QByteArray txt; + txt.append('"'); + txt.append(m_env->currentFileUtf8); + txt.append('"'); + newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); + } else if (macroNameRef == ppDate) { + QByteArray txt; + txt.append('"'); + txt.append(QDate::currentDate().toString().toUtf8()); + txt.append('"'); + newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); + } else if (macroNameRef == ppTime) { + QByteArray txt; + txt.append('"'); + txt.append(QTime::currentTime().toString().toUtf8()); + txt.append('"'); + newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); + } + + if (newTk.hasSource()) { + newTk.f.newline = tk->newline(); + newTk.f.whitespace = tk->whitespace(); + *tk = newTk; + return false; + } + } + + Macro *macro = m_env->resolve(macroNameRef); if (!macro || (tk->expanded() && m_state.m_tokenBuffer -- cgit v1.2.1 From 4c2daa90ce558c3b4287edc97127471486a411d9 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 29 Nov 2013 11:25:47 +0100 Subject: C++: Fix highlighting for lines with predefined macros This adds definitions for the macros __FILE__, __LINE__, __DATE__ and __TIME__ on demand. As a side effect, this also introduces highlighting for the uses of these macros. Task-number: QTCREATORBUG-8036 Change-Id: Ib7546c7d45d2eecbc50c7883fc684e3497154405 Reviewed-by: Erik Verbruggen Reviewed-by: Eike Ziller Reviewed-by: hjk --- src/libs/cplusplus/Macro.h | 7 +++++++ src/libs/cplusplus/pp-engine.cpp | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/libs/cplusplus') diff --git a/src/libs/cplusplus/Macro.h b/src/libs/cplusplus/Macro.h index a3d83b1f00..1c340dba65 100644 --- a/src/libs/cplusplus/Macro.h +++ b/src/libs/cplusplus/Macro.h @@ -137,6 +137,12 @@ public: void setVariadic(bool isVariadic) { f._variadic = isVariadic; } + bool isPredefined() const + { return f._predefined; } + + void setPredefined(bool isPredefined) + { f._predefined = isPredefined; } + QString toString() const; QString toStringWithLineBreaks() const; @@ -151,6 +157,7 @@ private: unsigned _hidden: 1; unsigned _functionLike: 1; unsigned _variadic: 1; + unsigned _predefined: 1; }; QByteArray _name; diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 05a7a083d3..4bbb229734 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -917,23 +917,21 @@ bool Preprocessor::handleIdentifier(PPToken *tk) && macroNameRef[0] == '_' && macroNameRef[1] == '_') { PPToken newTk; + QByteArray txt; if (macroNameRef == ppLine) { - QByteArray txt = QByteArray::number(tk->lineno); + txt = QByteArray::number(tk->lineno); newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); } else if (macroNameRef == ppFile) { - QByteArray txt; txt.append('"'); txt.append(m_env->currentFileUtf8); txt.append('"'); newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); } else if (macroNameRef == ppDate) { - QByteArray txt; txt.append('"'); txt.append(QDate::currentDate().toString().toUtf8()); txt.append('"'); newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); } else if (macroNameRef == ppTime) { - QByteArray txt; txt.append('"'); txt.append(QTime::currentTime().toString().toUtf8()); txt.append('"'); @@ -941,10 +939,14 @@ bool Preprocessor::handleIdentifier(PPToken *tk) } if (newTk.hasSource()) { - newTk.f.newline = tk->newline(); - newTk.f.whitespace = tk->whitespace(); - *tk = newTk; - return false; + Macro macro; + macro.setName(macroNameRef.toByteArray()); + macro.setFileName(m_env->currentFile); + macro.setPredefined(true); + macro.setDefinition(txt, QVector() << newTk); + m_env->bind(macro); + if (m_client) + m_client->macroAdded(macro); } } -- cgit v1.2.1 From 9a9ec06d48a07cb119b489e5281d8b2de766719c Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 29 Nov 2013 14:40:32 +0100 Subject: CPlusPlus: Remove unneeded declarations Change-Id: I5bf4febd1ec3b77e05f883015a99ed019ddfb55c Reviewed-by: Nikolai Kosjar --- src/libs/cplusplus/MatchingText.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/libs/cplusplus') diff --git a/src/libs/cplusplus/MatchingText.h b/src/libs/cplusplus/MatchingText.h index 5b12d5cc78..32db6df60a 100644 --- a/src/libs/cplusplus/MatchingText.h +++ b/src/libs/cplusplus/MatchingText.h @@ -36,9 +36,6 @@ QT_FORWARD_DECLARE_CLASS(QChar) namespace CPlusPlus { -class BackwardsScanner; -class TokenCache; - class CPLUSPLUS_EXPORT MatchingText { public: -- cgit v1.2.1 From 796fcaf1d288267e93baba3d01927957c684758f Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 2 Dec 2013 15:47:36 +0100 Subject: Revert "C++: Fix highlighting for lines with predefined macros" This takes too much memory. For qtcreator.pro the numbers are as follows: Patch applied: ~ 1600MB (RES) Patch reverted: ~ 510MB (RES) This reverts commit 4c2daa90ce558c3b4287edc97127471486a411d9. Task-number: QTCREATORBUG-10973 Change-Id: I843bd7c1ea4a26a1ec55ddc14c2a34a98d040922 Reviewed-by: hjk Reviewed-by: Robert Loehning Reviewed-by: Eike Ziller Reviewed-by: Orgad Shaneh Reviewed-by: Erik Verbruggen --- src/libs/cplusplus/Macro.h | 7 ------- src/libs/cplusplus/pp-engine.cpp | 18 ++++++++---------- 2 files changed, 8 insertions(+), 17 deletions(-) (limited to 'src/libs/cplusplus') diff --git a/src/libs/cplusplus/Macro.h b/src/libs/cplusplus/Macro.h index 1c340dba65..a3d83b1f00 100644 --- a/src/libs/cplusplus/Macro.h +++ b/src/libs/cplusplus/Macro.h @@ -137,12 +137,6 @@ public: void setVariadic(bool isVariadic) { f._variadic = isVariadic; } - bool isPredefined() const - { return f._predefined; } - - void setPredefined(bool isPredefined) - { f._predefined = isPredefined; } - QString toString() const; QString toStringWithLineBreaks() const; @@ -157,7 +151,6 @@ private: unsigned _hidden: 1; unsigned _functionLike: 1; unsigned _variadic: 1; - unsigned _predefined: 1; }; QByteArray _name; diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 4bbb229734..05a7a083d3 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -917,21 +917,23 @@ bool Preprocessor::handleIdentifier(PPToken *tk) && macroNameRef[0] == '_' && macroNameRef[1] == '_') { PPToken newTk; - QByteArray txt; if (macroNameRef == ppLine) { - txt = QByteArray::number(tk->lineno); + QByteArray txt = QByteArray::number(tk->lineno); newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); } else if (macroNameRef == ppFile) { + QByteArray txt; txt.append('"'); txt.append(m_env->currentFileUtf8); txt.append('"'); newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); } else if (macroNameRef == ppDate) { + QByteArray txt; txt.append('"'); txt.append(QDate::currentDate().toString().toUtf8()); txt.append('"'); newTk = generateToken(T_STRING_LITERAL, txt.constData(), txt.size(), tk->lineno, false); } else if (macroNameRef == ppTime) { + QByteArray txt; txt.append('"'); txt.append(QTime::currentTime().toString().toUtf8()); txt.append('"'); @@ -939,14 +941,10 @@ bool Preprocessor::handleIdentifier(PPToken *tk) } if (newTk.hasSource()) { - Macro macro; - macro.setName(macroNameRef.toByteArray()); - macro.setFileName(m_env->currentFile); - macro.setPredefined(true); - macro.setDefinition(txt, QVector() << newTk); - m_env->bind(macro); - if (m_client) - m_client->macroAdded(macro); + newTk.f.newline = tk->newline(); + newTk.f.whitespace = tk->whitespace(); + *tk = newTk; + return false; } } -- cgit v1.2.1