From b316939dfff4cda2adc52c7bb40f44e3b8276c80 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Tue, 3 Mar 2009 16:46:21 +0100
Subject: [PATCH] Introduced expandObjectLikeMacro().

---
 src/libs/cplusplus/pp-engine.cpp | 31 +++++++++++++++++++------------
 src/libs/cplusplus/pp-engine.h   |  3 +++
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index 08b286a2bc1..83b0d4191c8 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -748,18 +748,8 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
 
                 else {
                     if (! m->isFunctionLike()) {
-
-                        if (client)
-                            client->startExpandingMacro(identifierToken->offset,
-                                                        *m, spell);
-
-                        m->setHidden(true);
-                        const QByteArray tmp = expand(m->definition());
-                        m->setHidden(false);
-
-                        if (client)
-                            client->stopExpandingMacro(_dot->offset, *m);
-
+                        QByteArray tmp;
+                        expandObjectLikeMacro(identifierToken, spell, m, &tmp);
 
                         if (_dot->isNot(T_LPAREN)) {
                             _result->append(tmp);
@@ -827,6 +817,23 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
     _result = previousResult;
 }
 
+void Preprocessor::expandObjectLikeMacro(TokenIterator identifierToken,
+                                         const QByteArray &spell,
+                                         Macro *m,
+                                         QByteArray *result)
+{
+    if (client)
+        client->startExpandingMacro(identifierToken->offset,
+                                    *m, spell);
+
+    m->setHidden(true);
+    expand(m->definition(), result);
+    m->setHidden(false);
+
+    if (client)
+        client->stopExpandingMacro(_dot->offset, *m);
+}
+
 void Preprocessor::expandFunctionLikeMacro(TokenIterator identifierToken, Macro *m)
 {
     const char *beginOfText = startOfToken(*identifierToken);
diff --git a/src/libs/cplusplus/pp-engine.h b/src/libs/cplusplus/pp-engine.h
index 49f33218655..9fc2d49a276 100644
--- a/src/libs/cplusplus/pp-engine.h
+++ b/src/libs/cplusplus/pp-engine.h
@@ -104,6 +104,9 @@ private:
     QByteArray expand(const QByteArray &source);
     void expand(const QByteArray &source, QByteArray *result);
     void expand(const char *first, const char *last, QByteArray *result);
+    void expandObjectLikeMacro(TokenIterator identifierToken,
+                               const QByteArray &spell,
+                               Macro *m, QByteArray *result);
     void expandFunctionLikeMacro(TokenIterator identifierToken, Macro *m);
 
     void resetIfLevel();
-- 
GitLab