From c79476e72f86e9e7db529962079a351903972789 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 16 Oct 2009 14:39:51 +0200 Subject: [PATCH 01/51] debbugger: fix item counts > 1000 in QVector dumper --- share/qtcreator/gdbmacros/gdbmacros.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index 5ad19cadec9..c3c0033ed81 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -2929,7 +2929,7 @@ static void qDumpQVector(QDumper &d) d.putItemCount("value", n); d.putItem("valueeditable", "false"); - d.putItem("numchild", n); + d.putItem("numchild", nn); if (d.dumpChildren) { QByteArray strippedInnerType = stripPointerType(d.innerType); const char *stripped = innerIsPointerType ? strippedInnerType.data() : 0; From 25ee70bb24bec71f5392a441a923c7b3c1caf4f7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 16 Oct 2009 16:26:28 +0200 Subject: [PATCH 02/51] Debugger: Use the code model to detect unitialized variables. This should save debugger round trips and crashes in the debugging helpers. Add respective option to debugging helper option page, defaulting to true.On this occasion, make CDB detect shadowed variables correctly and display them as "" as does the Gdb engine by reversing the direction in which CdbSymbolGroupContext::populateINameIndexMap works. Rubber-stamped-by: hjk --- src/plugins/debugger/cdb/cdbdumperhelper.cpp | 10 +- src/plugins/debugger/cdb/cdbdumperhelper.h | 2 + .../debugger/cdb/cdbstackframecontext.cpp | 6 +- .../debugger/cdb/cdbstacktracecontext.cpp | 11 +- .../debugger/cdb/cdbsymbolgroupcontext.cpp | 108 ++++++--- .../debugger/cdb/cdbsymbolgroupcontext.h | 11 +- .../debugger/cdb/cdbsymbolgroupcontext_tpl.h | 2 +- src/plugins/debugger/debuggeractions.cpp | 7 + src/plugins/debugger/debuggeractions.h | 2 + src/plugins/debugger/debuggermanager.cpp | 17 ++ src/plugins/debugger/debuggermanager.h | 10 +- src/plugins/debugger/debuggerplugin.cpp | 3 + src/plugins/debugger/dumperoptionpage.ui | 14 +- src/plugins/debugger/gdb/gdbengine.cpp | 212 +++++++++--------- src/plugins/debugger/gdb/gdbengine.h | 6 +- src/plugins/debugger/stackframe.h | 7 + src/plugins/debugger/stackhandler.cpp | 44 +++- src/plugins/debugger/watchhandler.cpp | 20 +- src/plugins/debugger/watchhandler.h | 4 + src/plugins/debugger/watchutils.cpp | 203 +++++++++++++++++ src/plugins/debugger/watchutils.h | 13 ++ src/plugins/debugger/watchwindow.cpp | 9 +- 22 files changed, 557 insertions(+), 164 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbdumperhelper.cpp b/src/plugins/debugger/cdb/cdbdumperhelper.cpp index 77f3f798594..52b4558772b 100644 --- a/src/plugins/debugger/cdb/cdbdumperhelper.cpp +++ b/src/plugins/debugger/cdb/cdbdumperhelper.cpp @@ -341,6 +341,8 @@ void CdbDumperInitThread ::run() CdbDumperHelper::CdbDumperHelper(DebuggerManager *manager, CdbComInterfaces *cif) : m_tryInjectLoad(true), + m_msgDisabled(QLatin1String("Dumpers are disabled")), + m_msgNotInScope(QLatin1String("Data not in scope")), m_state(NotLoaded), m_manager(manager), m_cif(cif), @@ -648,8 +650,12 @@ CdbDumperHelper::DumpResult CdbDumperHelper::dumpTypeI(const WatchData &wd, bool { errorMessage->clear(); // Check failure cache and supported types - if (m_state == Disabled) { - *errorMessage = QLatin1String("Dumpers are disabled"); + if (m_state == Disabled) { + *errorMessage =m_msgDisabled; + return DumpNotHandled; + } + if (wd.error) { + *errorMessage =m_msgNotInScope; return DumpNotHandled; } if (m_failedTypes.contains(wd.type)) { diff --git a/src/plugins/debugger/cdb/cdbdumperhelper.h b/src/plugins/debugger/cdb/cdbdumperhelper.h index 4035d03ee28..be326768df6 100644 --- a/src/plugins/debugger/cdb/cdbdumperhelper.h +++ b/src/plugins/debugger/cdb/cdbdumperhelper.h @@ -134,6 +134,8 @@ private: static bool writeToDebuggee(CIDebugDataSpaces *ds, const QByteArray &buffer, quint64 address, QString *errorMessage); const bool m_tryInjectLoad; + const QString m_msgDisabled; + const QString m_msgNotInScope; State m_state; DebuggerManager *m_manager; CdbComInterfaces *m_cif; diff --git a/src/plugins/debugger/cdb/cdbstackframecontext.cpp b/src/plugins/debugger/cdb/cdbstackframecontext.cpp index d97a968768c..f64f0366a1d 100644 --- a/src/plugins/debugger/cdb/cdbstackframecontext.cpp +++ b/src/plugins/debugger/cdb/cdbstackframecontext.cpp @@ -217,7 +217,7 @@ bool WatchHandleDumperInserter::expandPointerToDumpable(const WatchData &wd, QSt bool handled = false; do { - if (!isPointerType(wd.type)) + if (wd.error || !isPointerType(wd.type)) break; const int classPos = wd.value.indexOf(" class "); if (classPos == -1) @@ -396,9 +396,9 @@ bool CdbStackFrameContext::editorToolTip(const QString &iname, *errorMessage = QString::fromLatin1("%1 not found.").arg(iname); return false; } - const WatchData wd = m_symbolContext->symbolAt(index); // Check dumpers. Should actually be just one item. - if (m_useDumpers && m_dumper->state() != CdbDumperHelper::Disabled) { + const WatchData wd = m_symbolContext->watchDataAt(index); + if (m_useDumpers && !wd.error && m_dumper->state() != CdbDumperHelper::Disabled) { QList result; if (CdbDumperHelper::DumpOk == m_dumper->dumpType(wd, false, &result, errorMessage)) { foreach (const WatchData &dwd, result) { diff --git a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp index 0a338f9fdcc..7a1448d708f 100644 --- a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp +++ b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp @@ -33,8 +33,11 @@ #include "cdbsymbolgroupcontext.h" #include "cdbdebugengine_p.h" #include "cdbdumperhelper.h" +#include "debuggeractions.h" +#include "debuggermanager.h" #include +#include #include namespace Debugger { @@ -160,7 +163,13 @@ CdbStackFrameContext *CdbStackTraceContext::frameContextAt(int index, QString *e *errorMessage = msgFrameContextFailed(index, m_frames.at(index), *errorMessage); return 0; } - CdbSymbolGroupContext *sc = CdbSymbolGroupContext::create(QLatin1String("local"), sg, errorMessage); + // Exclude unitialized variables if desired + QStringList uninitializedVariables; + if (theDebuggerAction(UseCodeModel)->isChecked()) { + const StackFrame &frame = m_frames.at(index); + getUninitializedVariables(DebuggerManager::instance()->cppCodeModelSnapshot(), frame.function, frame.file, frame.line, &uninitializedVariables); + } + CdbSymbolGroupContext *sc = CdbSymbolGroupContext::create(QLatin1String("local"), sg, uninitializedVariables, errorMessage); if (!sc) { *errorMessage = msgFrameContextFailed(index, m_frames.at(index), *errorMessage); return 0; diff --git a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp index f58f1f74527..2efd3672b96 100644 --- a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp +++ b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.cpp @@ -39,6 +39,9 @@ enum { debug = 0 }; enum { debugInternalDumpers = 0 }; +// name separator for shadowed variables +static const char iNameShadowDelimiter = '#'; + static inline QString msgSymbolNotFound(const QString &s) { return QString::fromLatin1("The symbol '%1' could not be found.").arg(s); @@ -83,6 +86,14 @@ QTextStream &operator<<(QTextStream &str, const DEBUG_SYMBOL_PARAMETERS &p) return str; } +static inline QString hexSymbolOffset(CIDebugSymbolGroup *sg, unsigned long index) +{ + ULONG64 rc = 0; + if (FAILED(sg->GetSymbolOffset(index, &rc))) + rc = 0; + return QLatin1String("0x") + QString::number(rc, 16); +} + // A helper function to extract a string value from a member function of // IDebugSymbolGroup2 taking the symbol index and a character buffer. // Pass in the the member function as '&IDebugSymbolGroup2::GetSymbolNameWide' @@ -129,12 +140,15 @@ static inline CdbSymbolGroupContext::SymbolState getSymbolState(const DEBUG_SYMB } CdbSymbolGroupContext::CdbSymbolGroupContext(const QString &prefix, - CIDebugSymbolGroup *symbolGroup) : + CIDebugSymbolGroup *symbolGroup, + const QStringList &uninitializedVariables) : m_prefix(prefix), m_nameDelimiter(QLatin1Char('.')), + m_uninitializedVariables(uninitializedVariables.toSet()), m_symbolGroup(symbolGroup), m_unnamedSymbolNumber(1) { + } CdbSymbolGroupContext::~CdbSymbolGroupContext() @@ -144,9 +158,10 @@ CdbSymbolGroupContext::~CdbSymbolGroupContext() CdbSymbolGroupContext *CdbSymbolGroupContext::create(const QString &prefix, CIDebugSymbolGroup *symbolGroup, + const QStringList &uninitializedVariables, QString *errorMessage) { - CdbSymbolGroupContext *rc = new CdbSymbolGroupContext(prefix, symbolGroup); + CdbSymbolGroupContext *rc = new CdbSymbolGroupContext(prefix, symbolGroup, uninitializedVariables); if (!rc->init(errorMessage)) { delete rc; return 0; @@ -173,28 +188,36 @@ bool CdbSymbolGroupContext::init(QString *errorMessage) *errorMessage = QString::fromLatin1("In %1: %2 (%3 symbols)").arg(QLatin1String(Q_FUNC_INFO), msgComFailed("GetSymbolParameters", hr)).arg(count); return false; } - populateINameIndexMap(m_prefix, DEBUG_ANY_ID, 0, count); + populateINameIndexMap(m_prefix, DEBUG_ANY_ID, count); } if (debug) - qDebug() << Q_FUNC_INFO << '\n'<< toString(); + qDebug() << Q_FUNC_INFO << '\n'<< toString(true); return true; } +/* Make the entries for iname->index mapping. We might encounter + * already expanded subitems when doing it for top-level ('this'-pointers), + * recurse in that case, (skip over expanded children). + * Loop backwards to detect shadowed variables in the order the +/* debugger expects them: +\code +int x; // Occurrence (1), should be reported as "x " +if (true) { + int x = 5; (2) // Occurrence (2), should be reported as "x" +} +\endcode + * The order in the symbol group is (1),(2). Give them an iname of + * #, which will be split apart for display. */ + void CdbSymbolGroupContext::populateINameIndexMap(const QString &prefix, unsigned long parentId, - unsigned long start, unsigned long count) + unsigned long end) { - // Make the entries for iname->index mapping. We might encounter - // already expanded subitems when doing it for top-level, recurse in that case. const QString symbolPrefix = prefix + m_nameDelimiter; if (debug) - qDebug() << Q_FUNC_INFO << '\n'<< symbolPrefix << start << count; - const unsigned long end = m_symbolParameters.size(); - unsigned long seenChildren = 0; - // Skip over expanded children - for (unsigned long i = start; i < end && seenChildren < count; i++) { + qDebug() << Q_FUNC_INFO << '\n'<< symbolPrefix << parentId << end; + for (unsigned long i = end - 1; ; i--) { const DEBUG_SYMBOL_PARAMETERS &p = m_symbolParameters.at(i); if (parentId == p.ParentSymbol) { - seenChildren++; // "__formal" occurs when someone writes "void foo(int /* x */)..." static const QString unnamedFormalParameter = QLatin1String("__formal"); QString symbolName = getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolNameWide, i); @@ -203,11 +226,21 @@ void CdbSymbolGroupContext::populateINameIndexMap(const QString &prefix, unsigne symbolName += QString::number(m_unnamedSymbolNumber++); symbolName += QLatin1Char('>'); } - const QString name = symbolPrefix + symbolName; + // Find a unique name in case the variable is shadowed by + // an existing one + const QString namePrefix = symbolPrefix + symbolName; + QString name = namePrefix; + for (int n = 1; m_inameIndexMap.contains(name); n++) { + name.truncate(namePrefix.size()); + name += QLatin1Char(iNameShadowDelimiter); + name += QString::number(n); + } m_inameIndexMap.insert(name, i); if (getSymbolState(p) == ExpandedSymbol) - populateINameIndexMap(name, i, i + 1, p.SubElements); + populateINameIndexMap(name, i, i + 1 + p.SubElements); } + if (i == 0 || i == parentId) + break; } } @@ -223,7 +256,10 @@ QString CdbSymbolGroupContext::toString(bool verbose) const str << " "; str << getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolNameWide, i); if (p.Flags & DEBUG_SYMBOL_IS_LOCAL) - str << " '" << getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolTypeNameWide, i); + str << " '" << getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolTypeNameWide, i) << '\''; + str << " Address: " << hexSymbolOffset(m_symbolGroup, i); + if (verbose) + str << " '" << getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolValueTextWide, i) << '\''; str << p << '\n'; } if (verbose) { @@ -348,7 +384,7 @@ bool CdbSymbolGroupContext::expandSymbol(const QString &prefix, unsigned long in if (it.value() > index) it.value() += newSymbolCount; // insert the new symbols - populateINameIndexMap(prefix, index, index + 1, newSymbolCount); + populateINameIndexMap(prefix, index, index + 1 + newSymbolCount); if (debug > 1) qDebug() << '<' << Q_FUNC_INFO << '\n' << prefix << index << '\n' << toString(); return true; @@ -365,14 +401,6 @@ QString CdbSymbolGroupContext::symbolINameAt(unsigned long index) const return m_inameIndexMap.key(index); } -static inline QString hexSymbolOffset(CIDebugSymbolGroup *sg, unsigned long index) -{ - ULONG64 rc = 0; - if (FAILED(sg->GetSymbolOffset(index, &rc))) - rc = 0; - return QLatin1String("0x") + QString::number(rc, 16); -} - // check for "0x000", "0x000 class X" static inline bool isNullPointer(const WatchData &wd) { @@ -409,19 +437,35 @@ static inline QString fixValue(const QString &value) return removeInnerTemplateType(value); } -WatchData CdbSymbolGroupContext::symbolAt(unsigned long index) const +WatchData CdbSymbolGroupContext::watchDataAt(unsigned long index) const { WatchData wd; wd.iname = symbolINameAt(index); wd.exp = wd.iname; + // Determine name from iname and format shadowed variables correctly + // as ", see populateINameIndexMap(). const int lastDelimiterPos = wd.iname.lastIndexOf(m_nameDelimiter); + QString name = lastDelimiterPos == -1 ? wd.iname : wd.iname.mid(lastDelimiterPos + 1); + int shadowedNumber = 0; + const int shadowedPos = name.lastIndexOf(QLatin1Char(iNameShadowDelimiter)); + if (shadowedPos != -1) { + shadowedNumber = name.mid(shadowedPos + 1).toInt(); + name.truncate(shadowedPos); + } // For class hierarchies, we get sometimes complicated std::template types here. - // Remove them for display - wd.name = removeInnerTemplateType(lastDelimiterPos == -1 ? wd.iname : wd.iname.mid(lastDelimiterPos + 1)); + // (std::map extends std::tree<>... Remove them for display only. + const QString fullShadowedName = WatchData::shadowedName(name, shadowedNumber); + wd.name = WatchData::shadowedName(removeInnerTemplateType(name), shadowedNumber); wd.addr = hexSymbolOffset(m_symbolGroup, index); - const QString type = getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolTypeNameWide, index); + const QString type = getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolTypeNameWide, index); + wd.setType(type); + // Check for unitialized variables at level 0 only. + const DEBUG_SYMBOL_PARAMETERS &p = m_symbolParameters.at(index); + if (p.ParentSymbol == DEBUG_ANY_ID && m_uninitializedVariables.contains(fullShadowedName)) { + wd.setError(WatchData::msgNotInScope()); + return wd; + } const QString value = getSymbolString(m_symbolGroup, &IDebugSymbolGroup2::GetSymbolValueTextWide, index); - wd.setType(type); wd.setValue(fixValue(value)); wd.setChildrenNeeded(); // compensate side effects of above setters // Figure out children. The SubElement is only a guess unless the symbol, @@ -429,7 +473,7 @@ WatchData CdbSymbolGroupContext::symbolAt(unsigned long index) const // If the symbol has children (expanded or not), we leave the 'Children' flag // in 'needed' state. Suppress 0-pointers right ("0x000 class X") // here as they only lead to children with memory access errors. - const bool hasChildren = m_symbolParameters.at(index).SubElements && !isNullPointer(wd); + const bool hasChildren = p.SubElements && !isNullPointer(wd); wd.setHasChildren(hasChildren); if (debug > 1) qDebug() << Q_FUNC_INFO << index << '\n' << wd.toString(); @@ -438,7 +482,7 @@ WatchData CdbSymbolGroupContext::symbolAt(unsigned long index) const WatchData CdbSymbolGroupContext::dumpSymbolAt(CIDebugDataSpaces *ds, unsigned long index) { - WatchData rc = symbolAt(index); + WatchData rc = watchDataAt(index); dump(ds, &rc); return rc; } diff --git a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.h b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.h index c2770fb2039..2db042423f0 100644 --- a/src/plugins/debugger/cdb/cdbsymbolgroupcontext.h +++ b/src/plugins/debugger/cdb/cdbsymbolgroupcontext.h @@ -69,12 +69,14 @@ class CdbSymbolGroupContext { Q_DISABLE_COPY(CdbSymbolGroupContext); explicit CdbSymbolGroupContext(const QString &prefix, - CIDebugSymbolGroup *symbolGroup); + CIDebugSymbolGroup *symbolGroup, + const QStringList &uninitializedVariables = QStringList()); public: ~CdbSymbolGroupContext(); - static CdbSymbolGroupContext *create(const QString &prefix, + static CdbSymbolGroupContext *create(const QString &prefix, CIDebugSymbolGroup *symbolGroup, + const QStringList &uninitializedVariables, QString *errorMessage); QString prefix() const { return m_prefix; } @@ -118,7 +120,7 @@ public: int dumpedOwner, OutputIterator it, QString *errorMessage); - WatchData symbolAt(unsigned long index) const; + WatchData watchDataAt(unsigned long index) const; // Run the internal dumpers on the symbol WatchData dumpSymbolAt(CIDebugDataSpaces *ds, unsigned long index); @@ -155,7 +157,7 @@ private: unsigned long *parentId, QString *errorMessage); bool expandSymbol(const QString &prefix, unsigned long index, QString *errorMessage); - void populateINameIndexMap(const QString &prefix, unsigned long parentId, unsigned long start, unsigned long count); + void populateINameIndexMap(const QString &prefix, unsigned long parentId, unsigned long end); QString symbolINameAt(unsigned long index) const; int dumpQString(CIDebugDataSpaces *ds, WatchData *wd); @@ -166,6 +168,7 @@ private: const QString m_prefix; const QChar m_nameDelimiter; + const QSet m_uninitializedVariables; CIDebugSymbolGroup *m_symbolGroup; NameIndexMap m_inameIndexMap; diff --git a/src/plugins/debugger/cdb/cdbsymbolgroupcontext_tpl.h b/src/plugins/debugger/cdb/cdbsymbolgroupcontext_tpl.h index 0b143207952..fe33e802b6c 100644 --- a/src/plugins/debugger/cdb/cdbsymbolgroupcontext_tpl.h +++ b/src/plugins/debugger/cdb/cdbsymbolgroupcontext_tpl.h @@ -61,7 +61,7 @@ bool CdbSymbolGroupContext::getDumpChildSymbols(CIDebugDataSpaces *ds, const QSt for (int s = start; s < m_symbolParameters.size(); ++s) { const DEBUG_SYMBOL_PARAMETERS &p = m_symbolParameters.at(s); if (p.ParentSymbol == parentId && isSymbolDisplayable(p)) { - WatchData wd = symbolAt(s); + WatchData wd = watchDataAt(s); // Run internal dumper, mark ownership if (ds) { switch (dump(ds, &wd)) { diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index a2c1da01721..4a0b0f783eb 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -229,6 +229,13 @@ DebuggerSettings *DebuggerSettings::instance() item->setValue(false); instance->insertItem(DebugDebuggingHelpers, item); + item = new SavedAction(instance); + item->setSettingsKey(debugModeGroup, QLatin1String("UseCodeModel")); + item->setText(tr("Use code model")); + item->setCheckable(true); + item->setDefaultValue(false); + item->setValue(false); + instance->insertItem(UseCodeModel, item); item = new SavedAction(instance); item->setText(tr("Recheck debugging helper availability")); diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index ffc334b268f..234cf21731c 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -85,6 +85,8 @@ enum DebuggerActionCode UseCustomDebuggingHelperLocation, CustomDebuggingHelperLocation, DebugDebuggingHelpers, + + UseCodeModel, UseToolTipsInMainEditor, UseToolTipsInLocalsView, diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index d7d9cf31457..c7f541293fc 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -61,6 +61,8 @@ #include #include #include +#include +#include #include #include @@ -303,6 +305,8 @@ struct DebuggerManagerPrivate IDebuggerEngine *m_engine; DebuggerState m_state; + + CPlusPlus::Snapshot m_codeModelSnapshot; }; DebuggerManager *DebuggerManagerPrivate::instance = 0; @@ -623,6 +627,18 @@ WatchHandler *DebuggerManager::watchHandler() const return d->m_watchHandler; } +const CPlusPlus::Snapshot &DebuggerManager::cppCodeModelSnapshot() const +{ + if (d->m_codeModelSnapshot.isEmpty() && theDebuggerAction(UseCodeModel)->isChecked()) + d->m_codeModelSnapshot = CppTools::CppModelManagerInterface::instance()->snapshot(); + return d->m_codeModelSnapshot; +} + +void DebuggerManager::clearCppCodeModelSnapshot() +{ + d->m_codeModelSnapshot.clear(); +} + SourceFilesWindow *DebuggerManager::sourceFileWindow() const { return d->m_sourceFilesWindow; @@ -1026,6 +1042,7 @@ void DebuggerManager::exitDebugger() // in turn will handle the cleanup. if (d->m_engine && state() != DebuggerNotReady) d->m_engine->exitDebugger(); + d->m_codeModelSnapshot.clear(); } DebuggerStartParametersPtr DebuggerManager::startParameters() const diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 76869b379e2..bc82ec187ba 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -59,6 +59,10 @@ namespace TextEditor { class ITextEditor; } +namespace CPlusPlus { + class Snapshot; +} + namespace Debugger { namespace Internal { @@ -180,6 +184,8 @@ public: QString *settingsCategory = 0, QString *settingsPage = 0) const; + const CPlusPlus::Snapshot &cppCodeModelSnapshot() const; + static DebuggerManager *instance(); public slots: @@ -232,6 +238,7 @@ public slots: void setRegisterValue(int nr, const QString &value); void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever + void clearCppCodeModelSnapshot(); public slots: // FIXME void showDebuggerOutput(const QString &msg) @@ -267,7 +274,8 @@ private: Internal::ThreadsHandler *threadsHandler() const; Internal::WatchHandler *watchHandler() const; Internal::SourceFilesWindow *sourceFileWindow() const; - QWidget *threadsWindow() const; + QWidget *threadsWindow() const; + Internal::DebuggerManagerActions debuggerManagerActions() const; void notifyInferiorStopped(); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index acd19909d10..c0d60ba6a75 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -373,6 +373,9 @@ QWidget *DebuggingHelperOptionPage::createPage(QWidget *parent) m_group.insert(theDebuggerAction(CustomDebuggingHelperLocation), m_ui.dumperLocationChooser); + m_group.insert(theDebuggerAction(UseCodeModel), + m_ui.checkBoxUseCodeModel); + #ifdef QT_DEBUG m_group.insert(theDebuggerAction(DebugDebuggingHelpers), m_ui.checkBoxDebugDebuggingHelpers); diff --git a/src/plugins/debugger/dumperoptionpage.ui b/src/plugins/debugger/dumperoptionpage.ui index 1b6bb8ed505..e63355068de 100644 --- a/src/plugins/debugger/dumperoptionpage.ui +++ b/src/plugins/debugger/dumperoptionpage.ui @@ -6,7 +6,7 @@ 0 0 - 403 + 432 434 @@ -83,10 +83,20 @@ - + + + + + Makes use of Qt Creator's code model to find out if a variable has already been assigned a value at the point the debugger interrupts. + + + Use code model + + + diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index acb1d1ac88e..87d6900a301 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -89,10 +89,6 @@ #endif #include -// FIXME: temporary hack to evalaute tbreak based step-over behaviour -static QString lastFile; -static int lastLine; - namespace Debugger { namespace Internal { @@ -1233,9 +1229,9 @@ void GdbEngine::handleStop2(const GdbResponse &response) void GdbEngine::handleStop2(const GdbMi &data) { // Sometimes we get some interesting extra information. Grab it. - GdbMi frame = data.findChild("frame"); - GdbMi shortName = frame.findChild("file"); - GdbMi fullName = frame.findChild("fullname"); + const GdbMi gdbmiFrame = data.findChild("frame"); + GdbMi shortName = gdbmiFrame.findChild("file"); + GdbMi fullName = gdbmiFrame.findChild("fullname"); if (shortName.isValid() && fullName.isValid()) { QString file = QFile::decodeName(shortName.data()); QString full = QFile::decodeName(fullName.data()); @@ -1246,16 +1242,17 @@ void GdbEngine::handleStop2(const GdbMi &data) } // Quick shot: Jump to stack frame #0. - if (frame.isValid()) { - const StackFrame f = parseStackFrame(frame, 0); - gotoLocation(f, true); + StackFrame frame; + if (gdbmiFrame.isValid()) { + frame = parseStackFrame(gdbmiFrame, 0); + gotoLocation(frame, true); } // // Stack // manager()->stackHandler()->setCurrentIndex(0); - updateLocals(); // Quick shot + updateLocals(qVariantFromValue(frame)); // Quick shot reloadStack(false); @@ -2583,11 +2580,6 @@ void GdbEngine::setToolTipExpression(const QPoint &mousePos, // ////////////////////////////////////////////////////////////////////// -//: Variable -static const QString strNotInScope = - QCoreApplication::translate("Debugger::Internal::GdbEngine", ""); - - static void setWatchDataValue(WatchData &data, const GdbMi &mi, int encoding = 0) { @@ -2804,8 +2796,8 @@ void GdbEngine::updateSubItem(const WatchData &data0) qDebug() << "FIXME: GdbEngine::updateSubItem:" << data.toString() << "should not happen"; #else - data.setType(strNotInScope); - data.setValue(strNotInScope); + data.setType(WatchData::msgNotInScope()); + data.setValue(WatchData::msgNotInScope()); data.setHasChildren(false); insertData(data); return; @@ -3139,7 +3131,7 @@ void GdbEngine::handleVarCreate(const GdbResponse &response) } else { data.setError(QString::fromLocal8Bit(response.data.findChild("msg").data())); if (data.isWatcher()) { - data.value = strNotInScope; + data.value = WatchData::msgNotInScope(); data.type = _(" "); data.setAllUnneeded(); data.setHasChildren(false); @@ -3213,7 +3205,7 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResponse &response) GdbMi contents; if (!parseConsoleStream(response, &contents)) { - data.setError(strNotInScope); + data.setError(WatchData::msgNotInScope()); insertData(data); return; } @@ -3306,7 +3298,7 @@ void GdbEngine::handleDebuggingHelperValue3(const GdbResponse &response) // << " STREAM:" << out; if (list.isEmpty()) { //: Value for variable - data.setError(strNotInScope); + data.setError(WatchData::msgNotInScope()); data.setAllUnneeded(); insertData(data); } else if (data.type == __("QString") @@ -3351,19 +3343,19 @@ void GdbEngine::handleDebuggingHelperValue3(const GdbResponse &response) } } else { //: Value for variable - data.setError(strNotInScope); + data.setError(WatchData::msgNotInScope()); data.setAllUnneeded(); insertData(data); } } else { WatchData data = response.cookie.value(); - data.setError(strNotInScope); + data.setError(WatchData::msgNotInScope()); data.setAllUnneeded(); insertData(data); } } -void GdbEngine::updateLocals() +void GdbEngine::updateLocals(const QVariant &cookie) { m_pendingRequests = 0; m_processedNames.clear(); @@ -3393,7 +3385,7 @@ void GdbEngine::updateLocals() postCommand(cmd, WatchUpdate, CB(handleStackListArguments)); // '2' is 'list with type and value' postCommand(_("-stack-list-locals 2"), WatchUpdate, - CB(handleStackListLocals)); // stage 2/2 + CB(handleStackListLocals), cookie); // stage 2/2 } } @@ -3489,91 +3481,102 @@ void GdbEngine::handleStackListLocals(const GdbResponse &response) // There could be shadowed variables QList locals = response.data.findChild("locals").children(); locals += m_currentFunctionArgs; - - setLocals(locals); + QMap seen; + // If desired, retrieve list of uninitialized variables looking at + // the current frame. This is invoked first time after a stop from + // handleStop2, which passes on the frame as cookie. The whole stack + // is not known at this point. + QStringList uninitializedVariables; + if (theDebuggerAction(UseCodeModel)->isChecked()) { + const StackFrame frame = qVariantCanConvert(response.cookie) ? + qVariantValue(response.cookie) : + m_manager->stackHandler()->currentFrame(); + if (frame.isUsable()) + getUninitializedVariables(m_manager->cppCodeModelSnapshot(), + frame.function, frame.file, frame.line, + &uninitializedVariables); + } + QList list; + foreach (const GdbMi &item, locals) + list.push_back(localVariable(item, uninitializedVariables, &seen)); + manager()->watchHandler()->insertBulkData(list); manager()->watchHandler()->updateWatchers(); } -void GdbEngine::setLocals(const QList &locals) +// Parse a local variable from GdbMi +WatchData GdbEngine::localVariable(const GdbMi &item, + const QStringList &uninitializedVariables, + QMap *seen) { - //qDebug() << m_varToType; - QMap seen; - - QList list; - foreach (const GdbMi &item, locals) { - // Local variables of inlined code are reported as - // 26^done,locals={varobj={exp="this",value="",name="var4",exp="this", - // numchild="1",type="const QtSharedPointer::Basic 1) - continue; - QByteArray name = item.findChild("exp").data(); - #else - QByteArray name = item.findChild("name").data(); - #endif - int n = seen.value(name); - if (n) { - seen[name] = n + 1; - WatchData data; - QString nam = _(name); - data.iname = _("local.") + nam + QString::number(n + 1); - //: Variable %1 is the variable name, %2 is a simple count - data.name = tr("%1 ").arg(nam).arg(n); + // Local variables of inlined code are reported as + // 26^done,locals={varobj={exp="this",value="",name="var4",exp="this", + // numchild="1",type="const QtSharedPointer::Basic 1) + continue; + QByteArray name = item.findChild("exp").data(); +#else + QByteArray name = item.findChild("name").data(); +#endif + const QMap::iterator it = seen->find(name); + if (it != seen->end()) { + const int n = it.value(); + ++(it.value()); + WatchData data; + QString nam = _(name); + data.iname = _("local.") + nam + QString::number(n + 1); + //: Variable %1 is the variable name, %2 is a simple count + data.name = WatchData::shadowedName(nam, n); + if (uninitializedVariables.contains(data.name)) { + data.setError(WatchData::msgNotInScope()); + return data; + } + //: Type of local variable or parameter shadowed by another + //: variable of the same name in a nested block. + setWatchDataValue(data, item.findChild("value")); + data.setType(GdbEngine::tr("")); + data.setHasChildren(false); + return data; + } + seen->insert(name, 1); + WatchData data; + QString nam = _(name); + data.iname = _("local.") + nam; + data.name = nam; + data.exp = nam; + data.framekey = m_currentFrame + data.name; + setWatchDataType(data, item.findChild("type")); + if (uninitializedVariables.contains(data.name)) { + data.setError(WatchData::msgNotInScope()); + return data; + } + if (isSynchroneous()) { + setWatchDataValue(data, item.findChild("value"), + item.findChild("valueencoded").data().toInt()); + // We know that the complete list of children is + // somewhere in the response. + data.setChildrenUnneeded(); + } else { + // set value only directly if it is simple enough, otherwise + // pass through the insertData() machinery + if (isIntOrFloatType(data.type) || isPointerType(data.type)) + setWatchDataValue(data, item.findChild("value")); + if (isSymbianIntType(data.type)) { setWatchDataValue(data, item.findChild("value")); - //: Type of local variable or parameter shadowed by another - //variable of the same name in a nested block - data.setType(tr("")); data.setHasChildren(false); - list.append(data); - } else { - seen[name] = 1; - WatchData data; - QString nam = _(name); - data.iname = _("local.") + nam; - data.name = nam; - data.exp = nam; - data.framekey = m_currentFrame + data.name; - setWatchDataType(data, item.findChild("type")); - if (isSynchroneous()) { - setWatchDataValue(data, item.findChild("value"), - item.findChild("valueencoded").data().toInt()); - // We know that the complete list of children is - // somewhere in the response. - data.setChildrenUnneeded(); - } else { - // set value only directly if it is simple enough, otherwise - // pass through the insertData() machinery - if (isIntOrFloatType(data.type) || isPointerType(data.type)) - setWatchDataValue(data, item.findChild("value")); - if (isSymbianIntType(data.type)) { - setWatchDataValue(data, item.findChild("value")); - data.setHasChildren(false); - } - } - - // Let's be a bit more bold: - //if (!hasDebuggingHelperForType(data.type)) { - // QByteArray value = item.findChild("value").data(); - // if (!value.isEmpty() && value != "{...}") - // data.setValue(decodeData(value, 0)); - //} - if (!manager()->watchHandler()->isExpandedIName(data.iname)) - data.setChildrenUnneeded(); - if (isPointerType(data.type) || data.name == __("this")) - data.setHasChildren(true); - if (0 && m_varToType.contains(data.framekey)) { - qDebug() << "RE-USING" << m_varToType.value(data.framekey); - data.setType(m_varToType.value(data.framekey)); - } - list.append(data); } } - manager()->watchHandler()->insertBulkData(list); + + if (!m_manager->watchHandler()->isExpandedIName(data.iname)) + data.setChildrenUnneeded(); + if (isPointerType(data.type) || data.name == __("this")) + data.setHasChildren(true); + return data; } void GdbEngine::insertData(const WatchData &data0) @@ -4089,9 +4092,7 @@ void GdbEngine::handleFetchDisassemblerByAddress0(const GdbResponse &response) void GdbEngine::gotoLocation(const StackFrame &frame, bool setMarker) { - lastFile = frame.file; - lastLine = frame.line; - //qDebug() << "GOTO " << frame.toString() << setMarker; + // qDebug() << "GOTO " << frame << setMarker; m_manager->gotoLocation(frame, setMarker); } @@ -4291,4 +4292,3 @@ IDebuggerEngine *createGdbEngine(DebuggerManager *manager) Q_DECLARE_METATYPE(Debugger::Internal::MemoryAgentCookie); Q_DECLARE_METATYPE(Debugger::Internal::DisassemblerAgentCookie); Q_DECLARE_METATYPE(Debugger::Internal::GdbMi); - diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 99f59fb63d1..08e873b2d4f 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -231,7 +231,7 @@ private: void setTokenBarrier(); void updateAll(); - void updateLocals(); + void updateLocals(const QVariant &cookie = QVariant()); void gdbInputAvailable(int channel, const QString &msg) { m_manager->showDebuggerInput(channel, msg); } @@ -399,7 +399,9 @@ private: const WatchData &parent); void setWatchDataType(WatchData &data, const GdbMi &mi); void setWatchDataDisplayedType(WatchData &data, const GdbMi &mi); - void setLocals(const QList &locals); + inline WatchData localVariable(const GdbMi &item, + const QStringList &uninitializedVariables, + QMap *seen); void connectDebuggingHelperActions(); void disconnectDebuggingHelperActions(); AbstractGdbAdapter *createAdapter(const DebuggerStartParametersPtr &dp); diff --git a/src/plugins/debugger/stackframe.h b/src/plugins/debugger/stackframe.h index 3a0e415e1f2..8e5771f7060 100644 --- a/src/plugins/debugger/stackframe.h +++ b/src/plugins/debugger/stackframe.h @@ -33,12 +33,17 @@ #include #include +QT_BEGIN_NAMESPACE +class QDebug; +QT_END_NAMESPACE + namespace Debugger { namespace Internal { struct StackFrame { StackFrame(); + void clear(); bool isUsable() const; QString toToolTip() const; QString toString() const; @@ -52,6 +57,8 @@ struct StackFrame QString address; }; +QDebug operator<<(QDebug d, const StackFrame &); + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp index 2d9cbea92d7..ec47a02b159 100644 --- a/src/plugins/debugger/stackhandler.cpp +++ b/src/plugins/debugger/stackhandler.cpp @@ -37,12 +37,23 @@ #include #include -using namespace Debugger::Internal; +namespace Debugger { +namespace Internal { StackFrame::StackFrame() : level(0), line(0) {} +void StackFrame::clear() +{ + line = level = 0; + function.clear(); + file.clear(); + from.clear(); + to.clear(); + address.clear(); +} + bool StackFrame::isUsable() const { return !file.isEmpty() && QFileInfo(file).isReadable(); @@ -52,12 +63,12 @@ QString StackFrame::toString() const { QString res; QTextStream str(&res); - str << StackHandler::tr("Address:") << " " << address << " " - << StackHandler::tr("Function:") << " " << function << " " - << StackHandler::tr("File:") << " " << file << " " - << StackHandler::tr("Line:") << " " << line << " " - << StackHandler::tr("From:") << " " << from << " " - << StackHandler::tr("To:") << " " << to; + str << StackHandler::tr("Address:") << ' ' << address << ' ' + << StackHandler::tr("Function:") << ' ' << function << ' ' + << StackHandler::tr("File:") << ' ' << file << ' ' + << StackHandler::tr("Line:") << ' ' << line << ' ' + << StackHandler::tr("From:") << ' ' << from << ' ' + << StackHandler::tr("To:") << ' ' << to; return res; } @@ -76,6 +87,23 @@ QString StackFrame::toToolTip() const return res; } +QDebug operator<<(QDebug d, const StackFrame &f) +{ + QString res; + QTextStream str(&res); + str << "level=" << f.level << " address=" << f.address; + if (!f.function.isEmpty()) + str << ' ' << f.function; + if (!f.file.isEmpty()) + str << ' ' << f.file << ':' << f.line; + if (!f.from.isEmpty()) + str << " from=" << f.from; + if (!f.to.isEmpty()) + str << " to=" << f.to; + d.nospace() << res; + return d; +} + //////////////////////////////////////////////////////////////////////// // // StackHandler @@ -379,3 +407,5 @@ void ThreadsHandler::notifyRunning() it->notifyRunning(); emit dataChanged(index(0, 1), index(m_threads.size()- 1, ColumnCount - 1)); } +} // namespace Internal +} // namespace Debugger diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index a0f524abcab..788c4b54b36 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -105,6 +105,7 @@ WatchData::WatchData() : generation(-1), valueEnabled(true), valueEditable(true), + error(false), source(0), state(InitialState), changed(false) @@ -127,7 +128,8 @@ bool WatchData::isEqual(const WatchData &other) const && framekey == other.framekey && hasChildren == other.hasChildren && valueEnabled == other.valueEnabled - && valueEditable == other.valueEditable; + && valueEditable == other.valueEditable + && error == other.error; } void WatchData::setError(const QString &msg) @@ -137,6 +139,7 @@ void WatchData::setError(const QString &msg) setHasChildren(false); valueEnabled = false; valueEditable = false; + error = true; } void WatchData::setValue(const QString &value0) @@ -232,6 +235,8 @@ QString WatchData::toString() const str << "iname=\"" << iname << doubleQuoteComma; if (!name.isEmpty() && name != iname) str << "name=\"" << name << doubleQuoteComma; + if (error) + str << "error,"; if (!addr.isEmpty()) str << "addr=\"" << addr << doubleQuoteComma; if (!exp.isEmpty()) @@ -310,6 +315,19 @@ QString WatchData::toToolTip() const return res; } +QString WatchData::msgNotInScope() +{ + static const QString rc = QCoreApplication::translate("Debugger::Internal::WatchData", ""); + return rc; +} + +QString WatchData::shadowedName(const QString &name, int seen) +{ + if (seen <= 0) + return name; + return QCoreApplication::translate("Debugger::Internal::WatchData", "%1 ").arg(name).arg(seen); +} + /////////////////////////////////////////////////////////////////////// // // WatchModel diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index dc426f4e22d..155d1de4116 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -117,6 +117,9 @@ public: bool isEqual(const WatchData &other) const; + static QString msgNotInScope(); + static QString shadowedName(const QString &name, int seen); + public: QString iname; // internal name sth like 'local.baz.public.a' QString exp; // the expression @@ -135,6 +138,7 @@ public: int generation; // when updated? bool valueEnabled; // value will be greyed out or not bool valueEditable; // value will be editable + bool error; private: diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 6fe9256b744..e7d52147aa9 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -43,6 +43,9 @@ #include #include +#include +#include +#include #include @@ -51,6 +54,7 @@ #include #include #include +#include #include #include @@ -59,6 +63,78 @@ #include enum { debug = 0 }; + +// Debug helpers for code model. @todo: Move to some CppTools library? +namespace CPlusPlus { + +static void debugCppSymbolRecursion(QTextStream &str, const Overview &o, + const Symbol &s, bool doRecurse = true, + int recursion = 0) +{ + for (int i = 0; i < recursion; i++) + str << " "; + str << "Symbol: " << o.prettyName(s.name()) << " at line " << s.line(); + if (s.isFunction()) + str << " function"; + if (s.isClass()) + str << " class"; + if (s.isDeclaration()) + str << " declaration"; + if (s.isBlock()) + str << " block"; + if (doRecurse && s.isScopedSymbol()) { + const ScopedSymbol *scoped = s.asScopedSymbol(); + const int size = scoped->memberCount(); + str << " scoped symbol of " << size << '\n'; + for (int m = 0; m < size; m++) + debugCppSymbolRecursion(str, o, *scoped->memberAt(m), true, recursion + 1); + } else { + str << '\n'; + } +} + +QDebug operator<<(QDebug d, const Symbol &s) +{ + QString output; + CPlusPlus::Overview o; + QTextStream str(&output); + debugCppSymbolRecursion(str, o, s, true, 0); + d.nospace() << output; + return d; +} + +QDebug operator<<(QDebug d, const Scope &scope) +{ + QString output; + Overview o; + QTextStream str(&output); + const int size = scope.symbolCount(); + str << "Scope of " << size; + if (scope.isNamespaceScope()) + str << " namespace"; + if (scope.isClassScope()) + str << " class"; + if (scope.isEnumScope()) + str << " enum"; + if (scope.isBlockScope()) + str << " block"; + if (scope.isFunctionScope()) + str << " function"; + if (scope.isPrototypeScope()) + str << " prototype"; + if (const Symbol *owner = scope.owner()) { + str << " owner: "; + debugCppSymbolRecursion(str, o, *owner, false, 0); + } else { + str << " 0-owner\n"; + } + for (int s = 0; s < size; s++) + debugCppSymbolRecursion(str, o, *scope.symbolAt(s), true, 2); + d.nospace() << output; + return d; +} +} // namespace CPlusPlus + namespace Debugger { namespace Internal { @@ -217,6 +293,133 @@ QString stripPointerType(QString type) return type; } +/* getUninitializedVariables(): Get variables that are not initialized + * at a certain line of a function from the code model to be able to + * indicate them as not in scope in the locals view. + * Find document + function in the code model, do a double check and + * collect declarative symbols that are in the function past or on + * the current line. blockRecursion() recurses up the scopes + * and collect symbols declared past or on the current line. + * Recursion goes up from the innermost scope, keeping a map + * of occurrences seen, to be able to derive the names of + * shadowed variables as the debugger sees them: +\code +int x; // Occurrence (1), should be reported as "x " +if (true) { + int x = 5; (2) // Occurrence (2), should be reported as "x" +} +\endcode + */ + +typedef QHash SeenHash; + +static void blockRecursion(const CPlusPlus::Overview &overview, + const CPlusPlus::Scope *scope, + unsigned line, + QStringList *uninitializedVariables, + SeenHash *seenHash, + int level = 0) +{ + const int size = scope->symbolCount(); + for (int s = 0; s < size; s++){ + const CPlusPlus::Symbol *symbol = scope->symbolAt(s); + if (symbol->isDeclaration()) { + // Find out about shadowed symbols by bookkeeping + // the already seen occurrences in a hash. + const QString name = overview.prettyName(symbol->name()); + SeenHash::iterator it = seenHash->find(name); + if (it == seenHash->end()) { + it = seenHash->insert(name, 0); + } else { + ++(it.value()); + } + // Is the declaration on or past the current line, that is, + // the variable not initialized. + if (symbol->line() >= line) + uninitializedVariables->push_back(WatchData::shadowedName(name, it.value())); + } + } + // Next block scope. + if (const CPlusPlus::Scope *enclosingScope = scope->enclosingBlockScope()) + blockRecursion(overview, enclosingScope, line, uninitializedVariables, seenHash, level + 1); +} + +// Inline helper with integer error return codes. +static inline +int getUninitializedVariablesI(const CPlusPlus::Snapshot &snapshot, + const QString &functionName, + const QString &file, + int line, + QStringList *uninitializedVariables) +{ + uninitializedVariables->clear(); + // Find document + if (snapshot.empty() || functionName.isEmpty() || file.isEmpty() || line < 1) + return 1; + const CPlusPlus::Snapshot::ConstIterator docIt = snapshot.constFind(file); + if (docIt == snapshot.constEnd()) + return 2; + const CPlusPlus::Document::Ptr doc = docIt.value(); + // Look at symbol at line and find its function. Either it is the + // function itself or some expression/variable. + const CPlusPlus::Symbol *symbolAtLine = doc->findSymbolAt(line, 0); + if (!symbolAtLine) + return 4; + // First figure out the function to do a safety name check. + const CPlusPlus::Function *function = 0; + const bool hitFunction = symbolAtLine->isFunction(); + if (hitFunction) { + function = symbolAtLine->asFunction(); + } else { + if (CPlusPlus::Scope *functionScope = symbolAtLine->enclosingFunctionScope()) + function = functionScope->owner()->asFunction(); + } + if (!function) + return 7; + // Compare function names with a bit off fuzz, + // skipping modules from a CDB symbol "lib!foo" or namespaces + // that the code model does not show at this point + CPlusPlus::Overview overview; + const QString name = overview.prettyName(function->name()); + if (!functionName.endsWith(name)) + return 11; + if (functionName.size() > name.size()) { + const char previousChar = functionName.at(functionName.size() - name.size() - 1).toLatin1(); + if (previousChar != ':' && previousChar != '!' ) + return 11; + } + // Starting from the innermost block scope, collect + // declarations. + const CPlusPlus::Scope *innerMostScope = hitFunction ? + symbolAtLine->asFunction()->members() : + symbolAtLine->enclosingBlockScope(); + if (!innerMostScope) + return 15; + SeenHash seenHash; + blockRecursion(overview, innerMostScope, line, uninitializedVariables, &seenHash); + return 0; +} + +bool getUninitializedVariables(const CPlusPlus::Snapshot &snapshot, + const QString &function, + const QString &file, + int line, + QStringList *uninitializedVariables) +{ + const int rc = getUninitializedVariablesI(snapshot, function, file, line, uninitializedVariables); + if (debug) { + QString msg; + QTextStream str(&msg); + str << "getUninitializedVariables() " << function << ' ' << file << ':' << line + << " returns (int) " << rc << " '" + << uninitializedVariables->join(QString(QLatin1Char(','))) << '\''; + if (rc) + str << " of " << snapshot.keys().size() << " documents"; + qDebug() << msg; + } + return rc == 0; +} + QString gdbQuoteTypes(const QString &type) { // gdb does not understand sizeof(Core::IFile*). diff --git a/src/plugins/debugger/watchutils.h b/src/plugins/debugger/watchutils.h index 9cbb6594813..c7cf4bfdbed 100644 --- a/src/plugins/debugger/watchutils.h +++ b/src/plugins/debugger/watchutils.h @@ -45,6 +45,10 @@ namespace Core { class IEditor; } +namespace CPlusPlus { + class Snapshot; +} + namespace Debugger { namespace Internal { @@ -89,6 +93,15 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos, // Decode string data as returned by the dumper helpers. QString decodeData(const QByteArray &baIn, int encoding); +// Get variables that are not initialized at a certain line +// of a function from the code model. Shadowed variables will +// be reported using the debugger naming conventions '' +bool getUninitializedVariables(const CPlusPlus::Snapshot &snapshot, + const QString &function, + const QString &file, + int line, + QStringList *uninitializedVariables); + /* Attempt to put common code of the dumper handling into a helper * class. * "Custom dumper" is a library compiled against the current diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 5cf8f4ff534..ac4b6a74033 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -253,10 +253,11 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) QAction *actInsertNewWatchItem = menu.addAction(tr("Insert new watch item")); QAction *actSelectWidgetToWatch = menu.addAction(tr("Select widget to watch")); + const bool actionsEnabled = m_manager->debuggerActionsEnabled(); const QString address = model()->data(mi0, AddressRole).toString(); QAction *actWatchKnownMemory = 0; QAction *actWatchUnknownMemory = new QAction(tr("Open memory editor..."), &menu); - actWatchUnknownMemory->setEnabled(m_manager->debuggerActionsEnabled()); + actWatchUnknownMemory->setEnabled(actionsEnabled); if (!address.isEmpty()) actWatchKnownMemory = new QAction(tr("Open memory editor at %1").arg(address), &menu); @@ -276,7 +277,9 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) menu.addAction(theDebuggerAction(RecheckDebuggingHelpers)); menu.addAction(theDebuggerAction(UseDebuggingHelpers)); - + QAction *actClearCodeModelSnapshot = new QAction(tr("Refresh code model snapshot"), &menu); + actClearCodeModelSnapshot->setEnabled(actionsEnabled && theDebuggerAction(UseCodeModel)->isChecked()); + menu.addAction(actClearCodeModelSnapshot); menu.addSeparator(); menu.addAction(theDebuggerAction(UseToolTipsInLocalsView)); @@ -311,6 +314,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) } else if (act == actSelectWidgetToWatch) { grabMouse(Qt::CrossCursor); m_grabbing = true; + } else if (act == actClearCodeModelSnapshot) { + m_manager->clearCppCodeModelSnapshot(); } else { for (int i = 0; i != alternativeFormats.size(); ++i) { if (act == typeFormatActions.at(i)) From 074d477fb0e4a244f6e82b8e13092746ca6d6569 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 16 Oct 2009 17:08:51 +0200 Subject: [PATCH 03/51] Got the gdb engine to compile on Mac. Reviewed by: Friedemann Kleint --- src/plugins/debugger/gdb/gdbengine.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 87d6900a301..a1a40bbe48d 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3497,8 +3497,11 @@ void GdbEngine::handleStackListLocals(const GdbResponse &response) &uninitializedVariables); } QList list; - foreach (const GdbMi &item, locals) - list.push_back(localVariable(item, uninitializedVariables, &seen)); + foreach (const GdbMi &item, locals) { + const WatchData data = localVariable(item, uninitializedVariables, &seen); + if (data.isValid()) + list.push_back(data); + } manager()->watchHandler()->insertBulkData(list); manager()->watchHandler()->updateWatchers(); } @@ -3518,7 +3521,7 @@ WatchData GdbEngine::localVariable(const GdbMi &item, foreach (const GdbMi &child, item.children()) numExps += int(child.name() == "exp"); if (numExps > 1) - continue; + return WatchData(); QByteArray name = item.findChild("exp").data(); #else QByteArray name = item.findChild("name").data(); From f240ceb4e6f395079c153c6352b508f1a961bec9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Oct 2009 10:59:46 +0200 Subject: [PATCH 04/51] CDB: Fix code model scope detection when stopping at function scope. that is, setting a break point at the opening brace or at function. Set StackFrame::from correctly. --- .../debugger/cdb/cdbstacktracecontext.cpp | 5 ++++ src/plugins/debugger/watchutils.cpp | 26 ++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp index 7a1448d708f..90329dfe04f 100644 --- a/src/plugins/debugger/cdb/cdbstacktracecontext.cpp +++ b/src/plugins/debugger/cdb/cdbstacktracecontext.cpp @@ -88,6 +88,7 @@ bool CdbStackTraceContext::init(unsigned long frameCount, QString * /*errorMessa if (debugCDB) qDebug() << Q_FUNC_INFO << frameCount; + const QChar exclamationMark = QLatin1Char('!'); m_frameContexts.resize(frameCount); qFill(m_frameContexts, static_cast(0)); @@ -102,7 +103,11 @@ bool CdbStackTraceContext::init(unsigned long frameCount, QString * /*errorMessa frame.address = QString::fromLatin1("0x%1").arg(instructionOffset, 0, 16); m_cif->debugSymbols->GetNameByOffsetWide(instructionOffset, wszBuf, MAX_PATH, 0, 0); + // Determine function and module, if available frame.function = QString::fromUtf16(reinterpret_cast(wszBuf)); + const int moduleSepPos = frame.function.indexOf(exclamationMark); + if (moduleSepPos != -1) + frame.from = frame.function.mid(0, moduleSepPos); ULONG ulLine; ULONG64 ul64Displacement; diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index e7d52147aa9..55e03207bdb 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -365,16 +365,24 @@ int getUninitializedVariablesI(const CPlusPlus::Snapshot &snapshot, const CPlusPlus::Symbol *symbolAtLine = doc->findSymbolAt(line, 0); if (!symbolAtLine) return 4; - // First figure out the function to do a safety name check. + // First figure out the function to do a safety name check + // and the innermost scope at cursor position const CPlusPlus::Function *function = 0; - const bool hitFunction = symbolAtLine->isFunction(); - if (hitFunction) { + const CPlusPlus::Scope *innerMostScope = 0; + if (symbolAtLine->isFunction()) { function = symbolAtLine->asFunction(); + if (function->memberCount() == 1) // Skip over function block + if (CPlusPlus::Block *block = function->memberAt(0)->asBlock()) + innerMostScope = block->members(); } else { - if (CPlusPlus::Scope *functionScope = symbolAtLine->enclosingFunctionScope()) + if (const CPlusPlus::Scope *functionScope = symbolAtLine->enclosingFunctionScope()) { function = functionScope->owner()->asFunction(); + innerMostScope = symbolAtLine->isBlock() ? + symbolAtLine->asBlock()->members() : + symbolAtLine->enclosingBlockScope(); + } } - if (!function) + if (!function || !innerMostScope) return 7; // Compare function names with a bit off fuzz, // skipping modules from a CDB symbol "lib!foo" or namespaces @@ -388,13 +396,7 @@ int getUninitializedVariablesI(const CPlusPlus::Snapshot &snapshot, if (previousChar != ':' && previousChar != '!' ) return 11; } - // Starting from the innermost block scope, collect - // declarations. - const CPlusPlus::Scope *innerMostScope = hitFunction ? - symbolAtLine->asFunction()->members() : - symbolAtLine->enclosingBlockScope(); - if (!innerMostScope) - return 15; + // Starting from the innermost block scope, collect declarations. SeenHash seenHash; blockRecursion(overview, innerMostScope, line, uninitializedVariables, &seenHash); return 0; From a3c8a39e3fa3b2173806216dc6faf6d10cb26529 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Oct 2009 14:04:11 +0200 Subject: [PATCH 05/51] CDB: Fix attaching to a crashed process. --- src/plugins/debugger/cdb/cdbdebugengine.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp index e9f4967b397..e96c864baa7 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.cpp +++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp @@ -707,10 +707,17 @@ bool CdbDebugEngine::startAttachDebugger(qint64 pid, DebuggerStartMode sm, QStri { // Need to attrach invasively, otherwise, no notification signals // for for CreateProcess/ExitProcess occur. - // As of version 6.11, the initial breakpoint suppression has no effect (see notifyException). - // when attaching to a console process starting up. However, there is no initial breakpoint - // (and no startup trap), when attaching to a running GUI process. - const ULONG flags = DEBUG_ATTACH_INVASIVE_RESUME_PROCESS|DEBUG_ATTACH_INVASIVE_NO_INITIAL_BREAK; + // Initial breakpoint occur: + // 1) Desired: When attaching to a crashed process + // 2) Undesired: When starting up a console process, in conjunction + // with the 32bit Wow-engine + // As of version 6.11, the flag only affects 1). 2) Still needs to be suppressed + // by lookup at the state of the application (startup trap). However, + // there is no startup trap when attaching to a process that has been + // running for a while. (see notifyException). + ULONG flags = DEBUG_ATTACH_INVASIVE_RESUME_PROCESS; + if (manager()->startParameters()->startMode != AttachCrashedExternal) + flags |= DEBUG_ATTACH_INVASIVE_NO_INITIAL_BREAK; const HRESULT hr = m_d->m_cif.debugClient->AttachProcess(NULL, pid, flags); if (debugCDB) qDebug() << "Attaching to " << pid << " using flags" << flags << " returns " << hr << executionStatusString(m_d->m_cif.debugControl); From 077c19a6616b4f828fe497041af010d479c62196 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Mon, 19 Oct 2009 14:49:51 +0200 Subject: [PATCH 06/51] Fix for invalid parsing of "(a)[b]", including test cases. --- src/shared/cplusplus/Parser.cpp | 38 +++-- tests/auto/cplusplus/ast/tst_ast.cpp | 209 ++++++++++++++++++++++++++- 2 files changed, 235 insertions(+), 12 deletions(-) diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 958d740a587..d754b234f43 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -2988,15 +2988,30 @@ bool Parser::parseObjCMessageExpression(ExpressionAST *&node) if (LA() != T_LBRACKET) return false; - ObjCMessageExpressionAST *ast = new (_pool) ObjCMessageExpressionAST; - ast->lbracket_token = consumeToken(); + unsigned start = cursor(); - parseObjCMessageReceiver(ast->receiver_expression); - parseObjCMessageArguments(ast->selector, ast->argument_list); + unsigned lbracket_token = consumeToken(); + ExpressionAST *receiver_expression = 0; + ObjCSelectorAST *selector = 0; + ObjCMessageArgumentListAST *argument_list = 0; - match(T_RBRACKET, &(ast->rbracket_token)); - node = ast; - return true; + if (parseObjCMessageReceiver(receiver_expression) && + parseObjCMessageArguments(selector, argument_list)) { + + ObjCMessageExpressionAST *ast = new (_pool) ObjCMessageExpressionAST; + ast->lbracket_token = lbracket_token; + ast->receiver_expression = receiver_expression; + ast->selector = selector; + ast->argument_list = argument_list; + + match(T_RBRACKET, &(ast->rbracket_token)); + node = ast; + + return true; + } + + rewind(start); + return false; } bool Parser::parseObjCMessageReceiver(ExpressionAST *&node) @@ -3051,15 +3066,20 @@ bool Parser::parseObjCMessageArguments(ObjCSelectorAST *&selNode, ObjCMessageArg selNode = selWithArgs; argNode = argAst; + return true; } else { rewind(start); + unsigned name_token = 0; + if (!parseObjCSelector(name_token)) + return false; ObjCSelectorWithoutArgumentsAST *sel = new (_pool) ObjCSelectorWithoutArgumentsAST; - parseObjCSelector(sel->name_token); + sel->name_token = name_token; selNode = sel; argNode = 0; + return true; } - return true; + return false; } bool Parser::parseObjCSelectorArg(ObjCSelectorArgumentAST *&selNode, ObjCMessageArgumentAST *&argNode) diff --git a/tests/auto/cplusplus/ast/tst_ast.cpp b/tests/auto/cplusplus/ast/tst_ast.cpp index cad9d51cacc..45b6088c9f2 100644 --- a/tests/auto/cplusplus/ast/tst_ast.cpp +++ b/tests/auto/cplusplus/ast/tst_ast.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -15,19 +16,22 @@ class tst_AST: public QObject Control control; public: + TranslationUnit *parse(const QByteArray &source, - TranslationUnit::ParseMode mode) + TranslationUnit::ParseMode mode, + bool blockErrors = false) { StringLiteral *fileId = control.findOrInsertStringLiteral(""); TranslationUnit *unit = new TranslationUnit(&control, fileId); unit->setObjCEnabled(true); unit->setSource(source.constData(), source.length()); + unit->blockErrors(blockErrors); unit->parse(mode); return unit; } - TranslationUnit *parseDeclaration(const QByteArray &source) - { return parse(source, TranslationUnit::ParseDeclaration); } + TranslationUnit *parseDeclaration(const QByteArray &source, bool blockErrors = false) + { return parse(source, TranslationUnit::ParseDeclaration, blockErrors); } TranslationUnit *parseExpression(const QByteArray &source) { return parse(source, TranslationUnit::ParseExpression); } @@ -59,6 +63,12 @@ private slots: void objc_attributes_followed_by_at_keyword(); void objc_protocol_forward_declaration_1(); void objc_protocol_definition_1(); + + // expressions with (square) brackets + void normal_array_access(); + void array_access_with_nested_expression(); + void objc_msg_send_expression(); + void objc_msg_send_expression_without_selector(); }; void tst_AST::gcc_attributes_1() @@ -421,5 +431,198 @@ void tst_AST::objc_protocol_definition_1() AST *ast = unit->ast(); } +void tst_AST::normal_array_access() +{ + QSharedPointer unit(parseDeclaration("\n" + "int f() {\n" + " int a[15];\n" + " int b = 1;\n" + " return a[b];\n" + "}" + )); + AST *ast = unit->ast(); + QVERIFY(ast); + + FunctionDefinitionAST *func = ast->asFunctionDefinition(); + QVERIFY(func); + + StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements; + QVERIFY(bodyStatements && bodyStatements->next && bodyStatements->next->next && bodyStatements->next->next->statement); + ExpressionAST *expr = bodyStatements->next->next->statement->asReturnStatement()->expression; + QVERIFY(expr); + + PostfixExpressionAST *postfixExpr = expr->asPostfixExpression(); + QVERIFY(postfixExpr); + + { + ExpressionAST *lhs = postfixExpr->base_expression; + QVERIFY(lhs); + SimpleNameAST *a = lhs->asSimpleName(); + QVERIFY(a); + QCOMPARE(QLatin1String(unit->identifier(a->identifier_token)->chars()), QLatin1String("a")); + } + + { + QVERIFY(postfixExpr->postfix_expressions && !postfixExpr->postfix_expressions->next); + ArrayAccessAST *rhs = postfixExpr->postfix_expressions->asArrayAccess(); + QVERIFY(rhs && rhs->expression); + SimpleNameAST *b = rhs->expression->asSimpleName(); + QVERIFY(b); + QCOMPARE(QLatin1String(unit->identifier(b->identifier_token)->chars()), QLatin1String("b")); + } +} + +void tst_AST::array_access_with_nested_expression() +{ + QSharedPointer unit(parseDeclaration("\n" + "int f() {\n" + " int a[15];\n" + " int b = 1;\n" + " return (a)[b];\n" + "}" + )); + AST *ast = unit->ast(); + QVERIFY(ast); + + FunctionDefinitionAST *func = ast->asFunctionDefinition(); + QVERIFY(func); + + StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements; + QVERIFY(bodyStatements && bodyStatements->next && bodyStatements->next->next && bodyStatements->next->next->statement); + ExpressionAST *expr = bodyStatements->next->next->statement->asReturnStatement()->expression; + QVERIFY(expr); + + CastExpressionAST *castExpr = expr->asCastExpression(); + QVERIFY(!castExpr); + + PostfixExpressionAST *postfixExpr = expr->asPostfixExpression(); + QVERIFY(postfixExpr); + + { + ExpressionAST *lhs = postfixExpr->base_expression; + QVERIFY(lhs); + NestedExpressionAST *nested_a = lhs->asNestedExpression(); + QVERIFY(nested_a && nested_a->expression); + SimpleNameAST *a = nested_a->expression->asSimpleName(); + QVERIFY(a); + QCOMPARE(QLatin1String(unit->identifier(a->identifier_token)->chars()), QLatin1String("a")); + } + + { + QVERIFY(postfixExpr->postfix_expressions && !postfixExpr->postfix_expressions->next); + ArrayAccessAST *rhs = postfixExpr->postfix_expressions->asArrayAccess(); + QVERIFY(rhs && rhs->expression); + SimpleNameAST *b = rhs->expression->asSimpleName(); + QVERIFY(b); + QCOMPARE(QLatin1String(unit->identifier(b->identifier_token)->chars()), QLatin1String("b")); + } +} + +void tst_AST::objc_msg_send_expression() +{ + QSharedPointer unit(parseDeclaration("\n" + "int f() {\n" + " NSObject *obj = [[[NSObject alloc] init] autorelease];\n" + " return [obj description];\n" + "}" + )); + AST *ast = unit->ast(); + QVERIFY(ast); + + FunctionDefinitionAST *func = ast->asFunctionDefinition(); + QVERIFY(func); + + StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements; + QVERIFY(bodyStatements && bodyStatements->next && !bodyStatements->next->next && bodyStatements->next->statement); + + {// check the NSObject declaration + ExpressionOrDeclarationStatementAST *firstStatement = bodyStatements->statement->asExpressionOrDeclarationStatement(); + QVERIFY(firstStatement && firstStatement->declaration && firstStatement->declaration->asDeclarationStatement()); + DeclarationAST *objDecl = firstStatement->declaration->asDeclarationStatement()->declaration; + QVERIFY(objDecl); + SimpleDeclarationAST *simpleDecl = objDecl->asSimpleDeclaration(); + QVERIFY(simpleDecl); + + {// check the type (NSObject) + QVERIFY(simpleDecl->decl_specifier_seq && !simpleDecl->decl_specifier_seq->next); + NamedTypeSpecifierAST *namedType = simpleDecl->decl_specifier_seq->asNamedTypeSpecifier(); + QVERIFY(namedType && namedType->name); + SimpleNameAST *typeName = namedType->name->asSimpleName(); + QVERIFY(typeName); + QCOMPARE(QLatin1String(unit->identifier(typeName->identifier_token)->chars()), QLatin1String("NSObject")); + } + + {// check the assignment + QVERIFY(simpleDecl->declarators && !simpleDecl->declarators->next); + DeclaratorAST *declarator = simpleDecl->declarators->declarator; + QVERIFY(declarator); + QVERIFY(!declarator->attributes); + + QVERIFY(declarator->ptr_operators && !declarator->ptr_operators->next && declarator->ptr_operators->asPointer() && !declarator->ptr_operators->asPointer()->cv_qualifier_seq); + + QVERIFY(declarator->core_declarator && declarator->core_declarator->asDeclaratorId()); + NameAST *objNameId = declarator->core_declarator->asDeclaratorId()->name; + QVERIFY(objNameId && objNameId->asSimpleName()); + QCOMPARE(QLatin1String(unit->identifier(objNameId->asSimpleName()->identifier_token)->chars()), QLatin1String("obj")); + + QVERIFY(!declarator->postfix_declarators); + QVERIFY(!declarator->post_attributes); + ExpressionAST *initializer = declarator->initializer; + QVERIFY(initializer); + + ObjCMessageExpressionAST *expr1 = initializer->asObjCMessageExpression(); + QVERIFY(expr1 && expr1->receiver_expression && expr1->selector && !expr1->argument_list); + + ObjCMessageExpressionAST *expr2 = expr1->receiver_expression->asObjCMessageExpression(); + QVERIFY(expr2 && expr2->receiver_expression && expr2->selector && !expr2->argument_list); + + ObjCMessageExpressionAST *expr3 = expr2->receiver_expression->asObjCMessageExpression(); + QVERIFY(expr3 && expr3->receiver_expression && expr3->selector && !expr3->argument_list); + } + } + + {// check the return statement + ExpressionAST *expr = bodyStatements->next->statement->asReturnStatement()->expression; + QVERIFY(expr); + + ObjCMessageExpressionAST *msgExpr = expr->asObjCMessageExpression(); + QVERIFY(msgExpr); + + QVERIFY(msgExpr->receiver_expression); + SimpleNameAST *receiver = msgExpr->receiver_expression->asSimpleName(); + QVERIFY(receiver); + QCOMPARE(QLatin1String(unit->identifier(receiver->identifier_token)->chars()), QLatin1String("obj")); + + QVERIFY(msgExpr->argument_list == 0); + + QVERIFY(msgExpr->selector); + ObjCSelectorWithoutArgumentsAST *sel = msgExpr->selector->asObjCSelectorWithoutArguments(); + QVERIFY(sel); + QCOMPARE(QLatin1String(unit->identifier(sel->name_token)->chars()), QLatin1String("description")); + } +} + +void tst_AST::objc_msg_send_expression_without_selector() +{ + // This test is to verify that no ObjCMessageExpressionAST element is created as the expression for the return statement. + QSharedPointer unit(parseDeclaration("\n" + "int f() {\n" + " NSObject *obj = [[[NSObject alloc] init] autorelease];\n" + " return [obj];\n" + "}", + true)); + AST *ast = unit->ast(); + QVERIFY(ast); + + FunctionDefinitionAST *func = ast->asFunctionDefinition(); + QVERIFY(func); + + StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements; + QVERIFY(bodyStatements && bodyStatements->next); + QVERIFY(bodyStatements->next->statement); + QVERIFY(bodyStatements->next->statement->asReturnStatement()); + QVERIFY(!bodyStatements->next->statement->asReturnStatement()->expression); +} + QTEST_APPLESS_MAIN(tst_AST) #include "tst_ast.moc" From 9e10e11c9c77c7eb20c4fdf8e4b8ce285c18d62b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Oct 2009 16:44:07 +0200 Subject: [PATCH 07/51] CDB: Add further checking to avoid invalid set asserts. Clear a failed call. _HAS_ITERATOR_DEBUGGING can unfortunately not be turned off as it is not binary compatible with other code. --- share/qtcreator/gdbmacros/gdbmacros.cpp | 8 + share/qtcreator/gdbmacros/test/main.cpp | 191 ++++++++++++++----- src/plugins/debugger/cdb/cdbdumperhelper.cpp | 8 +- 3 files changed, 157 insertions(+), 50 deletions(-) diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index c3c0033ed81..09051086adf 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -3178,6 +3178,14 @@ static void qDumpStdSetHelper(QDumper &d) const int nn = set.size(); if (nn < 0) return; +#ifdef Q_CC_MSVC + // This set has a head element pointer: + // "{ base class ; HeadType *_MyHead ; unsigned int _MySize }", + // which is valid even if the set is empty. Check that to avoid iterator asserts. + const void *headPtrAddress = addOffset(&set, sizeof(DummyType) - sizeof(unsigned int) - sizeof(void*)); + if (const void *headPtr = deref(headPtrAddress)) + qCheckAccess(headPtr); +#endif Q_TYPENAME DummyType::const_iterator it = set.begin(); const Q_TYPENAME DummyType::const_iterator cend = set.end(); for (int i = 0; i < nn && i < 10 && it != cend; ++i, ++it) diff --git a/share/qtcreator/gdbmacros/test/main.cpp b/share/qtcreator/gdbmacros/test/main.cpp index 28dea56f762..63d47a53df3 100644 --- a/share/qtcreator/gdbmacros/test/main.cpp +++ b/share/qtcreator/gdbmacros/test/main.cpp @@ -48,13 +48,32 @@ // Test uninitialized variables allocing memory bool optTestUninitialized = false; +bool optTestAll = false; +bool optEmptyContainers = false; +unsigned optVerbose = 0; +// Provide address of type of be tested. +// When testing unitialized memory, allocate at random. template inline T* testAddress(T* in) { - return optTestUninitialized ? - (reinterpret_cast(new char[sizeof(T)])) - : in; + unsigned char *mem = 0; + if (optTestUninitialized) { + mem = new unsigned char[sizeof(T)]; + for (int i = 0; i < sizeof(T); i++) { + mem[i] = char(rand() % 255u); + } + } else { + mem = reinterpret_cast(in); + } + if (optVerbose) { + for (int i = 0; i < sizeof(T); i++) { + unsigned int b = mem[i]; + printf("%2d %2x %3d\n", i, b, b); + } + fflush(stdout); + } + return reinterpret_cast(mem); } /* Test program for Dumper development/porting. @@ -175,8 +194,10 @@ static int dumpQMapIntInt() QMap test; QMapNode mapNode; const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode; - test.insert(42, 43); - test.insert(43, 44); + if (!optEmptyContainers) { + test.insert(42, 43); + test.insert(43, 44); + } prepareInBuffer("QMap", "local.qmapintint", "local.qmapintint", "int@int"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(int), sizeof(mapNode), valueOffset); fputs(qDumpOutBuffer, stdout); @@ -189,8 +210,10 @@ static int dumpQMapIntString() QMap test; QMapNode mapNode; const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode; - test.insert(42, QLatin1String("fortytwo")); - test.insert(43, QLatin1String("fortytree")); + if (!optEmptyContainers) { + test.insert(42, QLatin1String("fortytwo")); + test.insert(43, QLatin1String("fortytree")); + } prepareInBuffer("QMap", "local.qmapintqstring", "local.qmapintqstring", "int@QString"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(QString), sizeof(mapNode), valueOffset); fputs(qDumpOutBuffer, stdout); @@ -201,8 +224,10 @@ static int dumpQMapIntString() static int dumpQSetInt() { QSet test; - test.insert(42); - test.insert(43); + if (!optEmptyContainers) { + test.insert(42); + test.insert(43); + } prepareInBuffer("QSet", "local.qsetint", "local.qsetint", "int"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0); fputs(qDumpOutBuffer, stdout); @@ -216,9 +241,11 @@ static int dumpQMapQStringString() QMap test; QMapNode mapNode; const int valueOffset = (char*)&(mapNode.value) - (char*)&mapNode; - test.insert(QLatin1String("42s"), QLatin1String("fortytwo")); - test.insert(QLatin1String("423"), QLatin1String("fortytree")); - prepareInBuffer("QMap", "local.qmapqstringqstring", "local.qmapqstringqstring", "QString@QString"); + if (!optEmptyContainers) { + test.insert(QLatin1String("42s"), QLatin1String("fortytwo")); + test.insert(QLatin1String("423"), QLatin1String("fortytree")); + } + prepareInBuffer("QMap", "local.qmapqstringqstring", "local.qmapqstringqstring", "QString@QString"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), sizeof(QString), sizeof(mapNode), valueOffset); fputs(qDumpOutBuffer, stdout); fputc('\n', stdout); @@ -278,8 +305,10 @@ static int dumpStdWString() static int dumpStdStringList() { std::list test; - test.push_back("item1"); - test.push_back("item2"); + if (!optEmptyContainers) { + test.push_back("item1"); + test.push_back("item2"); + } prepareInBuffer("std::list", "local.stringlist", "local.stringlist", "std::string"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list::allocator_type), 0, 0); fputs(qDumpOutBuffer, stdout); @@ -290,8 +319,10 @@ static int dumpStdStringList() static int dumpStdStringQList() { QList test; - test.push_back("item1"); - test.push_back("item2"); + if (!optEmptyContainers) { + test.push_back("item1"); + test.push_back("item2"); + } prepareInBuffer("QList", "local.stringqlist", "local.stringqlist", "std::string"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), 0, 0, 0); fputs(qDumpOutBuffer, stdout); @@ -302,8 +333,10 @@ static int dumpStdStringQList() static int dumpStdIntList() { std::list test; - test.push_back(1); - test.push_back(2); + if (!optEmptyContainers) { + test.push_back(1); + test.push_back(2); + } prepareInBuffer("std::list", "local.intlist", "local.intlist", "int"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list::allocator_type), 0, 0); fputs(qDumpOutBuffer, stdout); @@ -314,8 +347,10 @@ static int dumpStdIntList() static int dumpStdIntVector() { std::vector test; - test.push_back(1); - test.push_back(2); + if (!optEmptyContainers) { + test.push_back(1); + test.push_back(2); + } prepareInBuffer("std::vector", "local.intvector", "local.intvector", "int"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list::allocator_type), 0, 0); fputs(qDumpOutBuffer, stdout); @@ -326,8 +361,10 @@ static int dumpStdIntVector() static int dumpStdStringVector() { std::vector test; - test.push_back("item1"); - test.push_back("item2"); + if (!optEmptyContainers) { + test.push_back("item1"); + test.push_back("item2"); + } prepareInBuffer("std::vector", "local.stringvector", "local.stringvector", "std::string"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list::allocator_type), 0, 0); fputs(qDumpOutBuffer, stdout); @@ -338,8 +375,10 @@ static int dumpStdStringVector() static int dumpStdWStringVector() { std::vector test; - test.push_back(L"item1"); - test.push_back(L"item2"); + if (!optEmptyContainers) { + test.push_back(L"item1"); + test.push_back(L"item2"); + } prepareInBuffer("std::vector", "local.wstringvector", "local.wstringvector", "std::wstring"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::wstring), sizeof(std::list::allocator_type), 0, 0); fputs(qDumpOutBuffer, stdout); @@ -350,8 +389,10 @@ static int dumpStdWStringVector() static int dumpStdIntSet() { std::set test; - test.insert(1); - test.insert(2); + if (!optEmptyContainers) { + test.insert(1); + test.insert(2); + } prepareInBuffer("std::set", "local.intset", "local.intset", "int"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), sizeof(std::list::allocator_type), 0, 0); fputs(qDumpOutBuffer, stdout); @@ -362,8 +403,10 @@ static int dumpStdIntSet() static int dumpStdStringSet() { std::set test; - test.insert("item1"); - test.insert("item2"); + if (!optEmptyContainers) { + test.insert("item1"); + test.insert("item2"); + } prepareInBuffer("std::set", "local.stringset", "local.stringset", "std::string"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::list::allocator_type), 0, 0); fputs(qDumpOutBuffer, stdout); @@ -374,8 +417,10 @@ static int dumpStdStringSet() static int dumpStdQStringSet() { std::set test; - test.insert(QLatin1String("item1")); - test.insert(QLatin1String("item2")); + if (!optEmptyContainers) { + test.insert(QLatin1String("item1")); + test.insert(QLatin1String("item2")); + } prepareInBuffer("std::set", "local.stringset", "local.stringset", "QString"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(QString), sizeof(std::list::allocator_type), 0, 0); fputs(qDumpOutBuffer, stdout); @@ -385,9 +430,11 @@ static int dumpStdQStringSet() static int dumpStdMapIntString() { - std::map test; + std::map test; std::map::value_type entry(42, std::string("fortytwo")); - test.insert(entry); + if (!optEmptyContainers) { + test.insert(entry); + } const int valueOffset = (char*)&(entry.second) - (char*)&entry; prepareInBuffer("std::map", "local.stdmapintstring", "local.stdmapintstring", "int@std::basic_string,std::allocator >@std::less@std::allocator,std::allocator > > >"); @@ -402,7 +449,9 @@ static int dumpStdMapStringString() typedef std::map TestType; TestType test; const TestType::value_type entry("K", "V"); - test.insert(entry); + if (!optEmptyContainers) { + test.insert(entry); + } const int valueOffset = (char*)&(entry.second) - (char*)&entry; prepareInBuffer("std::map", "local.stdmapstringstring", "local.stdmapstringstring", "std::basic_string,std::allocator >@std::basic_string,std::allocator >@std::less@std::allocator,std::allocator >,std::basic_string,std::allocator > > >"); @@ -502,6 +551,23 @@ static TypeDumpFunctionMap registerTypes() return rc; } +static void usage(const char *b, const TypeDumpFunctionMap &tdm) +{ + printf("Usage: %s [-v][-u][-e] \n", b); + printf("Usage: %s [-v][-u][-e] -a excluded_type1 \n", b); + printf("Options: -u Test uninitialized memory\n"); + printf(" -e Empty containers\n"); + printf(" -v Verbose\n"); + printf(" -a Test all available types\n"); + printf("Supported types: "); + const TypeDumpFunctionMap::const_iterator cend = tdm.constEnd(); + for (TypeDumpFunctionMap::const_iterator it = tdm.constBegin(); it != cend; ++it) { + fputs(qPrintable(it.key()), stdout); + fputc(' ', stdout); + } + fputc('\n', stdout); +} + int main(int argc, char *argv[]) { printf("\nQt Creator Debugging Helper testing tool\n\n"); @@ -515,30 +581,57 @@ int main(int argc, char *argv[]) const TypeDumpFunctionMap::const_iterator cend = tdm.constEnd(); if (argc < 2) { - printf("Usage: %s [-a]| \n", argv[0]); - printf("Supported types: "); - for (TypeDumpFunctionMap::const_iterator it = tdm.constBegin(); it != cend; ++it) { - fputs(qPrintable(it.key()), stdout); - fputc(' ', stdout); - } - fputc('\n', stdout); + usage(argv[0], tdm); return 0; } - + // Parse args + QStringList tests; + for (int a = 1; a < argc; a++) { + const char *arg = argv[a]; + if (arg[0] == '-') { + switch (arg[1]) { + case 'a': + optTestAll = true; + break; + case 'u': + optTestUninitialized = true; + break; + case 'v': + optVerbose++; + break; + case 'e': + optEmptyContainers = true; + break; + default: + fprintf(stderr, "Invalid option %s\n", arg); + usage(argv[0], tdm); + return -1; + } + } else { + tests.push_back(QLatin1String(arg)); + } + } + // Go int rc = 0; - if (argc == 2 && !qstrcmp(argv[1], "-a")) { + if (optTestAll) { for (TypeDumpFunctionMap::const_iterator it = tdm.constBegin(); it != cend; ++it) { - printf("\nTesting: %s\n", qPrintable(it.key())); - rc += (*it.value())(); + const QString test = it.key(); + if (tests.contains(test)) { + printf("\nSkipping: %s\n", qPrintable(test)); + } else { + printf("\nTesting: %s\n", qPrintable(test)); + rc += (*it.value())(); + if (optTestUninitialized) + printf("Survived: %s\n", qPrintable(test)); + } } } else { - for (int i = 1; i < argc; i++) { - const char *arg = argv[i]; - printf("\nTesting: %s\n", arg); - const TypeDumpFunctionMap::const_iterator it = tdm.constFind(QLatin1String(arg)); + foreach(const QString &test, tests) { + printf("\nTesting: %s\n", qPrintable(test)); + const TypeDumpFunctionMap::const_iterator it = tdm.constFind(test); if (it == cend) { rc = -1; - fprintf(stderr, "\nUnhandled type: %s\n", argv[i]); + fprintf(stderr, "\nUnhandled type: %s\n", qPrintable(test)); } else { rc = (*it.value())(); } diff --git a/src/plugins/debugger/cdb/cdbdumperhelper.cpp b/src/plugins/debugger/cdb/cdbdumperhelper.cpp index 52b4558772b..2269aab42cd 100644 --- a/src/plugins/debugger/cdb/cdbdumperhelper.cpp +++ b/src/plugins/debugger/cdb/cdbdumperhelper.cpp @@ -563,8 +563,14 @@ CdbDumperHelper::CallResult if (!writeToDebuggee(m_cif->debugDataSpaces, inBuffer, m_inBufferAddress, errorMessage)) return CallFailed; } - if (!CdbDebugEnginePrivate::executeDebuggerCommand(m_cif->debugControl, callCmd, errorMessage)) + if (!CdbDebugEnginePrivate::executeDebuggerCommand(m_cif->debugControl, callCmd, errorMessage)) { + // Clear the outstanding call in case we triggered a debug library assert with a message box + QString clearError; + if (!CdbDebugEnginePrivate::executeDebuggerCommand(m_cif->debugControl, QLatin1String(".call /c"), &clearError)) { + *errorMessage += QString::fromLatin1("/Unable to clear call %1").arg(clearError); + } return CallSyntaxError; + } // Set up call and a temporary breakpoint after it. // Try to skip debuggee crash exceptions and dumper exceptions // by using 'gN' (go not handled -> pass handling to dumper __try/__catch block) From aa89317731a861e8d156d407ddc1f3d411c1af1f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 19 Oct 2009 16:46:59 +0200 Subject: [PATCH 08/51] Fix compiler warnings in dumper tests. --- share/qtcreator/gdbmacros/test/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/gdbmacros/test/main.cpp b/share/qtcreator/gdbmacros/test/main.cpp index 63d47a53df3..60e0989294b 100644 --- a/share/qtcreator/gdbmacros/test/main.cpp +++ b/share/qtcreator/gdbmacros/test/main.cpp @@ -60,14 +60,14 @@ template unsigned char *mem = 0; if (optTestUninitialized) { mem = new unsigned char[sizeof(T)]; - for (int i = 0; i < sizeof(T); i++) { + for (unsigned int i = 0; i < sizeof(T); i++) { mem[i] = char(rand() % 255u); } } else { mem = reinterpret_cast(in); } if (optVerbose) { - for (int i = 0; i < sizeof(T); i++) { + for (unsigned int i = 0; i < sizeof(T); i++) { unsigned int b = mem[i]; printf("%2d %2x %3d\n", i, b, b); } From fe2c9cc16dc35c0f55bea45046d64d0170a0bbc0 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 19 Oct 2009 17:47:49 +0200 Subject: [PATCH 09/51] Improved parsing of ambiguous statements. Done with Erik Verbruggen --- src/shared/cplusplus/Parser.cpp | 105 ++++++++++++++++++++++++--- src/shared/cplusplus/Parser.h | 3 + tests/auto/cplusplus/ast/tst_ast.cpp | 76 +++++++++++++++++-- 3 files changed, 165 insertions(+), 19 deletions(-) diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index d754b234f43..e60751305a9 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -56,7 +56,7 @@ #include #include #include -#include + CPLUSPLUS_BEGIN_NAMESPACE Parser::Parser(TranslationUnit *unit) @@ -2041,10 +2041,68 @@ bool Parser::maybeSimpleExpression(SimpleDeclarationAST *simpleDecl) const { if (! simpleDecl->declarators) { SpecifierAST *spec = simpleDecl->decl_specifier_seq; - if (spec && ! spec->next && spec->asNamedTypeSpecifier()) { + + if (spec && ! spec->next && spec->asNamedTypeSpecifier()) + return true; + } + + return false; +} + +bool Parser::isPointerDeclaration(DeclarationStatementAST *ast) const +{ + if (! ast) + return false; + + if (SimpleDeclarationAST *declaration = ast->declaration->asSimpleDeclaration()) { + if (SpecifierAST *spec = declaration->decl_specifier_seq) { + if (spec->asNamedTypeSpecifier() && ! spec->next) { + if (DeclaratorListAST *declarators = declaration->declarators) { + if (DeclaratorAST *declarator = declarators->declarator) { + if (declarator->ptr_operators && declarator->equals_token && declarator->initializer) { + return true; + } + } + } + } + } + } + + return false; +} + +bool Parser::maybeAmbiguousStatement(DeclarationStatementAST *ast) const +{ + if (! ast) + return false; + + if (SimpleDeclarationAST *declaration = ast->declaration->asSimpleDeclaration()) { + if (SpecifierAST *spec = declaration->decl_specifier_seq) { + if (spec->asNamedTypeSpecifier() && ! spec->next) { + if (DeclaratorListAST *declarators = declaration->declarators) { + if (DeclaratorAST *declarator = declarators->declarator) { + if (declarator->core_declarator && + declarator->core_declarator->asNestedDeclarator()) { + // recognized name(id-expression) + return true; + } + } + } + } + + } else if (DeclaratorListAST *declarators = declaration->declarators) { + // no decl_specifiers... + if (DeclaratorAST *declarator = declarators->declarator) { + if (declarator->postfix_declarators && declarator->postfix_declarators->asFunctionDeclarator() + && ! declarator->initializer) { + return false; + } + } + return true; } } + return false; } @@ -2055,31 +2113,35 @@ bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node) unsigned start = cursor(); bool blocked = blockErrors(true); + if (parseDeclarationStatement(node)) { DeclarationStatementAST *stmt = static_cast(node); - SimpleDeclarationAST *simpleDecl = 0; - if (stmt->declaration) - simpleDecl = stmt->declaration->asSimpleDeclaration(); - if (simpleDecl && simpleDecl->decl_specifier_seq && - ! maybeFunctionCall(simpleDecl) && ! maybeSimpleExpression(simpleDecl)) { + if (isPointerDeclaration(stmt)) { + blockErrors(blocked); + return true; + } + + if (! maybeAmbiguousStatement(stmt)) { unsigned end_of_declaration_statement = cursor(); rewind(start); + StatementAST *expression = 0; - if (! parseExpressionStatement(expression) || cursor() != end_of_declaration_statement) { - rewind(end_of_declaration_statement); - } else { - ExpressionOrDeclarationStatementAST *ast = - new (_pool) ExpressionOrDeclarationStatementAST; + if (parseExpressionStatement(expression) && cursor() == end_of_declaration_statement) { + // it's an ambiguous expression-or-declaration statement. + ExpressionOrDeclarationStatementAST *ast = new (_pool) ExpressionOrDeclarationStatementAST; ast->declaration = node; ast->expression = expression; node = ast; } + + rewind(end_of_declaration_statement); blockErrors(blocked); return true; } } + // it's not a declaration statement. blockErrors(blocked); rewind(start); return parseExpressionStatement(node); @@ -2653,6 +2715,12 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node, return false; } + // if there is no valid declarator + // and it doesn't look like a fwd or a class declaration + // then it's not a declarations + if (! declarator && ! maybeForwardOrClassDeclaration(decl_specifier_seq)) + return false; + DeclaratorAST *firstDeclarator = declarator; if (declarator) { @@ -2709,6 +2777,19 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node, return false; } +bool Parser::maybeForwardOrClassDeclaration(SpecifierAST *decl_specifier_seq) const +{ + // look at the decl_specifier for possible fwd or class declarations. + if (SpecifierAST *spec = decl_specifier_seq) { + if (! spec->next && (spec->asElaboratedTypeSpecifier() || + spec->asEnumSpecifier() || + spec->asClassSpecifier())) + return true; + } + + return false; +} + bool Parser::parseFunctionBody(StatementAST *&node) { if (_translationUnit->skipFunctionBody()) { diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h index 2f274e93ab5..1dd204d1541 100644 --- a/src/shared/cplusplus/Parser.h +++ b/src/shared/cplusplus/Parser.h @@ -264,8 +264,11 @@ public: void match(int kind, unsigned *token); + bool maybeAmbiguousStatement(DeclarationStatementAST *ast) const; bool maybeFunctionCall(SimpleDeclarationAST *simpleDecl) const; bool maybeSimpleExpression(SimpleDeclarationAST *simpleDecl) const; + bool maybeForwardOrClassDeclaration(SpecifierAST *decl_specifier_seq) const; + bool isPointerDeclaration(DeclarationStatementAST *ast) const; private: bool switchTemplateArguments(bool templateArguments); diff --git a/tests/auto/cplusplus/ast/tst_ast.cpp b/tests/auto/cplusplus/ast/tst_ast.cpp index 45b6088c9f2..25871aea129 100644 --- a/tests/auto/cplusplus/ast/tst_ast.cpp +++ b/tests/auto/cplusplus/ast/tst_ast.cpp @@ -58,6 +58,12 @@ private slots: void while_condition_statement(); void for_statement(); void cpp_initializer_or_function_declaration(); + void simple_declaration_1(); + void function_call_1(); + void function_call_2(); + void function_call_3(); + void nested_deref_expression(); + void assignment_1(); // objc++ void objc_attributes_followed_by_at_keyword(); @@ -78,6 +84,19 @@ void tst_AST::gcc_attributes_1() )); } +void tst_AST::simple_declaration_1() +{ + QSharedPointer unit(parseStatement("\n" +"a * b = 10;" + )); + + AST *ast = unit->ast(); + QVERIFY(ast); + + DeclarationStatementAST *declStmt = ast->asDeclarationStatement(); + QVERIFY(declStmt); +} + void tst_AST::simple_name() { QSharedPointer unit(parseExpression("a")); @@ -161,7 +180,7 @@ void tst_AST::new_expression_2() void tst_AST::condition_1() { QSharedPointer unit(parseExpression("\n" -"(x < 0 && y > (int) a" +"(x < 0 && y > (int) a)" )); AST *ast = unit->ast(); @@ -178,6 +197,46 @@ void tst_AST::init_1() QVERIFY(ast != 0); } +void tst_AST::function_call_1() +{ + QSharedPointer unit(parseStatement("retranslateUi(blah);")); + AST *ast = unit->ast(); + QVERIFY(ast != 0); + QVERIFY(ast->asExpressionStatement()); +} + +void tst_AST::function_call_2() +{ + QSharedPointer unit(parseStatement("retranslateUi(10);")); + AST *ast = unit->ast(); + QVERIFY(ast != 0); + QVERIFY(ast->asExpressionStatement()); +} + +void tst_AST::function_call_3() +{ + QSharedPointer unit(parseStatement("(*blah) = 10;")); + AST *ast = unit->ast(); + QVERIFY(ast != 0); + QVERIFY(ast->asExpressionStatement()); +} + +void tst_AST::nested_deref_expression() +{ + QSharedPointer unit(parseStatement("(*blah);")); + AST *ast = unit->ast(); + QVERIFY(ast != 0); + QVERIFY(ast->asExpressionStatement()); +} + +void tst_AST::assignment_1() +{ + QSharedPointer unit(parseStatement("a(x) = 3;")); + AST *ast = unit->ast(); + QVERIFY(ast != 0); + QVERIFY(ast->asExpressionStatement()); +} + void tst_AST::if_statement() { QSharedPointer unit(parseStatement("if (a) b;")); @@ -195,7 +254,7 @@ void tst_AST::if_statement() QCOMPARE(stmt->else_token, 0U); QVERIFY(stmt->else_statement == 0); - // check the `then' statement + // check the `then' statement1 ExpressionStatementAST *then_stmt = stmt->statement->asExpressionStatement(); QVERIFY(then_stmt != 0); QVERIFY(then_stmt->expression != 0); @@ -435,7 +494,7 @@ void tst_AST::normal_array_access() { QSharedPointer unit(parseDeclaration("\n" "int f() {\n" - " int a[15];\n" + " int a[10];\n" " int b = 1;\n" " return a[b];\n" "}" @@ -447,7 +506,10 @@ void tst_AST::normal_array_access() QVERIFY(func); StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements; - QVERIFY(bodyStatements && bodyStatements->next && bodyStatements->next->next && bodyStatements->next->next->statement); + QVERIFY(bodyStatements); + QVERIFY(bodyStatements->next); + QVERIFY(bodyStatements->next->next); + QVERIFY(bodyStatements->next->next->statement); ExpressionAST *expr = bodyStatements->next->next->statement->asReturnStatement()->expression; QVERIFY(expr); @@ -536,9 +598,9 @@ void tst_AST::objc_msg_send_expression() QVERIFY(bodyStatements && bodyStatements->next && !bodyStatements->next->next && bodyStatements->next->statement); {// check the NSObject declaration - ExpressionOrDeclarationStatementAST *firstStatement = bodyStatements->statement->asExpressionOrDeclarationStatement(); - QVERIFY(firstStatement && firstStatement->declaration && firstStatement->declaration->asDeclarationStatement()); - DeclarationAST *objDecl = firstStatement->declaration->asDeclarationStatement()->declaration; + DeclarationStatementAST *firstStatement = bodyStatements->statement->asDeclarationStatement(); + QVERIFY(firstStatement); + DeclarationAST *objDecl = firstStatement->declaration; QVERIFY(objDecl); SimpleDeclarationAST *simpleDecl = objDecl->asSimpleDeclaration(); QVERIFY(simpleDecl); From 0a7d402d855cf4d9ce775d3c130ae938470be1cd Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 19 Oct 2009 18:49:31 +0200 Subject: [PATCH 10/51] Trk: Ensure proper connecting and disconnecting. --- src/shared/trk/launcher.cpp | 61 ++++++++++++++++++++++++++++--------- src/shared/trk/launcher.h | 4 +++ 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/shared/trk/launcher.cpp b/src/shared/trk/launcher.cpp index 5bd9ff5da17..78f7df6f177 100644 --- a/src/shared/trk/launcher.cpp +++ b/src/shared/trk/launcher.cpp @@ -64,10 +64,12 @@ struct LauncherPrivate { QString m_installFileName; int m_verbose; Launcher::Actions m_startupActions; + bool m_connected; }; LauncherPrivate::LauncherPrivate() : - m_verbose(0) + m_verbose(0), + m_connected(false) { } @@ -148,18 +150,27 @@ bool Launcher::startServer(QString *errorMessage) if (!d->m_device.open(d->m_trkServerName, errorMessage)) return false; d->m_device.sendTrkInitialPing(); - d->m_device.sendTrkMessage(TrkConnect); // Connect d->m_device.sendTrkMessage(TrkSupported, TrkCallback(this, &Launcher::handleSupportMask)); d->m_device.sendTrkMessage(TrkCpuType, TrkCallback(this, &Launcher::handleCpuType)); d->m_device.sendTrkMessage(TrkVersions, TrkCallback(this, &Launcher::handleTrkVersion)); + if (d->m_startupActions != ActionPingOnly) + d->m_device.sendTrkMessage(TrkConnect, TrkCallback(this, &Launcher::handleConnect)); + return true; +} +void Launcher::handleConnect(const TrkResult &result) +{ + if (result.errorCode()) { + emit canNotConnect(result.errorString()); + return; + } + d->m_connected = true; if (d->m_startupActions & ActionCopy) copyFileToRemote(); else if (d->m_startupActions & ActionInstall) installRemotePackageSilently(); else if (d->m_startupActions & ActionRun) startInferiorIfNeeded(); - return true; } void Launcher::setVerbose(int v) @@ -176,11 +187,24 @@ void Launcher::logMessage(const QString &msg) void Launcher::terminate() { - //TODO handle case where application has not been started - QByteArray ba; - appendShort(&ba, 0x0000, TargetByteOrder); - appendInt(&ba, d->m_session.pid, TargetByteOrder); - d->m_device.sendTrkMessage(TrkDeleteItem, TrkCallback(this, &Launcher::handleWaitForFinished), ba); + if (d->m_session.pid) { + QByteArray ba; + appendShort(&ba, 0x0000, TargetByteOrder); + appendInt(&ba, d->m_session.pid, TargetByteOrder); + d->m_device.sendTrkMessage(TrkDeleteItem, TrkCallback(this, &Launcher::handleRemoteProcessKilled), ba); + } else if (d->m_connected) { + if (d->m_copyState.copyFileHandle) + closeRemoteFile(true); + disconnectTrk(); + } else { + emit finished(); + } +} + +void Launcher::handleRemoteProcessKilled(const TrkResult &result) +{ + Q_UNUSED(result) + disconnectTrk(); } void Launcher::handleResult(const TrkResult &result) @@ -267,7 +291,7 @@ void Launcher::handleResult(const TrkResult &result) if (itemType == 0 // process && result.data.size() >= 10 && d->m_session.pid == extractInt(result.data.data() + 6)) { - d->m_device.sendTrkMessage(TrkDisconnect, TrkCallback(this, &Launcher::handleWaitForFinished)); + disconnectTrk(); } break; } @@ -321,7 +345,7 @@ void Launcher::handleFileCreation(const TrkResult &result) { if (result.errorCode() || result.data.size() < 6) { emit canNotCreateFile(d->m_copyState.destinationFileName, result.errorString()); - emit finished(); + disconnectTrk(); return; } const char *data = result.data.data(); @@ -339,7 +363,7 @@ void Launcher::handleCopy(const TrkResult &result) if (result.errorCode() || result.data.size() < 4) { closeRemoteFile(true); emit canNotWriteFile(d->m_copyState.destinationFileName, result.errorString()); - emit finished(); + disconnectTrk(); } else { continueCopying(extractShort(result.data.data() + 2)); } @@ -374,6 +398,8 @@ void Launcher::closeRemoteFile(bool failed) failed ? TrkCallback() : TrkCallback(this, &Launcher::handleFileCopied), ba); d->m_copyState.data.reset(); + d->m_copyState.copyFileHandle = 0; + d->m_copyState.position = 0; } void Launcher::handleFileCopied(const TrkResult &result) @@ -385,7 +411,7 @@ void Launcher::handleFileCopied(const TrkResult &result) else if (d->m_startupActions & ActionRun) startInferiorIfNeeded(); else - emit finished(); + disconnectTrk(); } void Launcher::handleCpuType(const TrkResult &result) @@ -410,7 +436,7 @@ void Launcher::handleCreateProcess(const TrkResult &result) { if (result.errorCode()) { emit canNotRun(result.errorString()); - emit finished(); + disconnectTrk(); return; } // 40 00 00] @@ -511,6 +537,11 @@ void Launcher::cleanUp() // Error: 0x00 } +void Launcher::disconnectTrk() +{ + d->m_device.sendTrkMessage(TrkDisconnect, TrkCallback(this, &Launcher::handleWaitForFinished)); +} + void Launcher::copyFileToRemote() { emit copyingStarted(); @@ -533,11 +564,11 @@ void Launcher::handleInstallPackageFinished(const TrkResult &result) { if (result.errorCode()) { emit canNotInstall(d->m_installFileName, result.errorString()); - emit finished(); + disconnectTrk(); } else if (d->m_startupActions & ActionRun) { startInferiorIfNeeded(); } else { - emit finished(); + disconnectTrk(); } } diff --git a/src/shared/trk/launcher.h b/src/shared/trk/launcher.h index aafb6e48967..a216b79fcb3 100644 --- a/src/shared/trk/launcher.h +++ b/src/shared/trk/launcher.h @@ -69,6 +69,7 @@ public: signals: void copyingStarted(); + void canNotConnect(const QString &errorMessage); void canNotCreateFile(const QString &filename, const QString &errorMessage); void canNotWriteFile(const QString &filename, const QString &errorMessage); void canNotCloseFile(const QString &filename, const QString &errorMessage); @@ -90,7 +91,10 @@ private slots: private: // kill process and breakpoints void cleanUp(); + void disconnectTrk(); + void handleRemoteProcessKilled(const TrkResult &result); + void handleConnect(const TrkResult &result); void handleFileCreation(const TrkResult &result); void handleCopy(const TrkResult &result); void continueCopying(uint lastCopiedBlockSize = 0); From 13675cf6ed022db43f961473f78a97325014fea2 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 20 Oct 2009 11:21:25 +0200 Subject: [PATCH 11/51] Cleanup the C++ front-end. Removed CPLUSPLUS_BEGIN/END_NAMESPACE & co and made it possible to compile the parser with CPLUSPLUS_WITHOUT_QT. --- src/shared/cplusplus/AST.cpp | 4 ++-- src/shared/cplusplus/AST.h | 8 +++---- src/shared/cplusplus/ASTClone.cpp | 4 ++-- src/shared/cplusplus/ASTVisit.cpp | 4 ++-- src/shared/cplusplus/ASTVisitor.cpp | 4 ++-- src/shared/cplusplus/ASTVisitor.h | 8 +++---- src/shared/cplusplus/ASTfwd.h | 8 +++---- src/shared/cplusplus/Array.h | 8 +++---- .../cplusplus/CPlusPlusForwardDeclarations.h | 24 ++++--------------- src/shared/cplusplus/CheckDeclaration.cpp | 22 ++++++++--------- src/shared/cplusplus/CheckDeclaration.h | 8 +++---- src/shared/cplusplus/CheckDeclarator.cpp | 4 ++-- src/shared/cplusplus/CheckDeclarator.h | 8 +++---- src/shared/cplusplus/CheckExpression.cpp | 8 ++----- src/shared/cplusplus/CheckExpression.h | 8 +++---- src/shared/cplusplus/CheckName.cpp | 4 ++-- src/shared/cplusplus/CheckName.h | 8 +++---- src/shared/cplusplus/CheckSpecifier.cpp | 4 ++-- src/shared/cplusplus/CheckSpecifier.h | 8 +++---- src/shared/cplusplus/CheckStatement.cpp | 4 ++-- src/shared/cplusplus/CheckStatement.h | 8 +++---- src/shared/cplusplus/Control.cpp | 4 ++-- src/shared/cplusplus/Control.h | 8 +++---- src/shared/cplusplus/CoreTypes.cpp | 4 ++-- src/shared/cplusplus/CoreTypes.h | 8 +++---- src/shared/cplusplus/DiagnosticClient.cpp | 4 ++-- src/shared/cplusplus/DiagnosticClient.h | 8 +++---- src/shared/cplusplus/FullySpecifiedType.cpp | 4 ++-- src/shared/cplusplus/FullySpecifiedType.h | 8 +++---- src/shared/cplusplus/Keywords.cpp | 4 ++-- src/shared/cplusplus/Lexer.cpp | 4 ++-- src/shared/cplusplus/Lexer.h | 8 +++---- src/shared/cplusplus/LiteralTable.h | 8 +++---- src/shared/cplusplus/Literals.cpp | 4 ++-- src/shared/cplusplus/Literals.h | 8 +++---- src/shared/cplusplus/MemoryPool.cpp | 4 ++-- src/shared/cplusplus/MemoryPool.h | 8 +++---- src/shared/cplusplus/Name.cpp | 4 ++-- src/shared/cplusplus/Name.h | 8 +++---- src/shared/cplusplus/NameVisitor.cpp | 4 ++-- src/shared/cplusplus/NameVisitor.h | 8 +++---- src/shared/cplusplus/Names.cpp | 4 ++-- src/shared/cplusplus/Names.h | 8 +++---- src/shared/cplusplus/ObjectiveCAtKeywords.cpp | 4 ++-- .../cplusplus/ObjectiveCTypeQualifiers.cpp | 6 ++--- .../cplusplus/ObjectiveCTypeQualifiers.h | 8 +++---- src/shared/cplusplus/Parser.cpp | 4 ++-- src/shared/cplusplus/Parser.h | 8 +++---- src/shared/cplusplus/Scope.cpp | 4 ++-- src/shared/cplusplus/Scope.h | 8 +++---- src/shared/cplusplus/Semantic.cpp | 4 ++-- src/shared/cplusplus/Semantic.h | 8 +++---- src/shared/cplusplus/SemanticCheck.cpp | 4 ++-- src/shared/cplusplus/SemanticCheck.h | 8 +++---- src/shared/cplusplus/Symbol.cpp | 4 ++-- src/shared/cplusplus/Symbol.h | 8 +++---- src/shared/cplusplus/SymbolVisitor.cpp | 2 +- src/shared/cplusplus/SymbolVisitor.h | 8 +++---- src/shared/cplusplus/Symbols.cpp | 4 ++-- src/shared/cplusplus/Symbols.h | 8 +++---- src/shared/cplusplus/Token.cpp | 4 ++-- src/shared/cplusplus/Token.h | 8 +++---- src/shared/cplusplus/TranslationUnit.cpp | 4 ++-- src/shared/cplusplus/TranslationUnit.h | 8 +++---- src/shared/cplusplus/Type.cpp | 4 ++-- src/shared/cplusplus/Type.h | 8 +++---- src/shared/cplusplus/TypeVisitor.cpp | 4 ++-- src/shared/cplusplus/TypeVisitor.h | 8 +++---- tests/auto/cplusplus/ast/tst_ast.cpp | 2 +- tests/auto/cplusplus/lookup/tst_lookup.cpp | 2 +- .../auto/cplusplus/semantic/tst_semantic.cpp | 2 +- 71 files changed, 215 insertions(+), 237 deletions(-) diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp index 21e8a1504c0..babf8380c5b 100644 --- a/src/shared/cplusplus/AST.cpp +++ b/src/shared/cplusplus/AST.cpp @@ -54,7 +54,7 @@ #include #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; AST::AST() { } @@ -2493,4 +2493,4 @@ unsigned ObjCSynchronizedStatementAST::lastToken() const return synchronized_token + 1; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index 4af1971e2ee..05a78b08322 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -53,8 +53,8 @@ #include "ASTfwd.h" #include "MemoryPool.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { template class List: public Managed @@ -3168,7 +3168,7 @@ protected: virtual void accept0(ASTVisitor *visitor); }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_AST_H diff --git a/src/shared/cplusplus/ASTClone.cpp b/src/shared/cplusplus/ASTClone.cpp index e30fb2b43d1..444097abfce 100644 --- a/src/shared/cplusplus/ASTClone.cpp +++ b/src/shared/cplusplus/ASTClone.cpp @@ -30,7 +30,7 @@ #include "AST.h" #include "ASTVisitor.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; SimpleSpecifierAST *SimpleSpecifierAST::clone(MemoryPool *pool) const { @@ -1516,4 +1516,4 @@ ObjCSynchronizedStatementAST *ObjCSynchronizedStatementAST::clone(MemoryPool *po } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp index d5862271dcc..7cd20753999 100644 --- a/src/shared/cplusplus/ASTVisit.cpp +++ b/src/shared/cplusplus/ASTVisit.cpp @@ -30,7 +30,7 @@ #include "AST.h" #include "ASTVisitor.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; void SimpleSpecifierAST::accept0(ASTVisitor *visitor) { @@ -1465,4 +1465,4 @@ void ObjCSynchronizedStatementAST::accept0(ASTVisitor *visitor) visitor->endVisit(this); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/ASTVisitor.cpp b/src/shared/cplusplus/ASTVisitor.cpp index 20c261318c0..6f331515a08 100644 --- a/src/shared/cplusplus/ASTVisitor.cpp +++ b/src/shared/cplusplus/ASTVisitor.cpp @@ -51,7 +51,7 @@ #include "TranslationUnit.h" #include "Control.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; ASTVisitor::ASTVisitor(Control *control) : _control(control) @@ -111,4 +111,4 @@ void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned void ASTVisitor::getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const { getPosition(tokenAt(index).end(), line, column); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/ASTVisitor.h b/src/shared/cplusplus/ASTVisitor.h index 5c2c85bfc62..7356e0f9056 100644 --- a/src/shared/cplusplus/ASTVisitor.h +++ b/src/shared/cplusplus/ASTVisitor.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "ASTfwd.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT ASTVisitor { @@ -371,7 +371,7 @@ private: Control *_control; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_ASTVISITOR_H diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h index 5ac42923c63..f97bae2a84c 100644 --- a/src/shared/cplusplus/ASTfwd.h +++ b/src/shared/cplusplus/ASTfwd.h @@ -51,8 +51,8 @@ #include -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class AST; class ASTVisitor; @@ -203,7 +203,7 @@ class ObjCDynamicPropertiesDeclarationAST; class ObjCFastEnumerationAST; class ObjCSynchronizedStatementAST; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_ASTFWD_H diff --git a/src/shared/cplusplus/Array.h b/src/shared/cplusplus/Array.h index 34d2048eee4..d749cbec81d 100644 --- a/src/shared/cplusplus/Array.h +++ b/src/shared/cplusplus/Array.h @@ -53,8 +53,8 @@ #include #include -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { template class Array @@ -125,7 +125,7 @@ private: int _count; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_ARRAY_H diff --git a/src/shared/cplusplus/CPlusPlusForwardDeclarations.h b/src/shared/cplusplus/CPlusPlusForwardDeclarations.h index b060f11dfa5..9e570d2c1af 100644 --- a/src/shared/cplusplus/CPlusPlusForwardDeclarations.h +++ b/src/shared/cplusplus/CPlusPlusForwardDeclarations.h @@ -49,34 +49,19 @@ #ifndef CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H #define CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H -#ifndef CPLUSPLUS_WITH_NO_QT +#ifndef CPLUSPLUS_WITHOUT_QT # include -# define CPLUSPLUS_BEGIN_HEADER -# define CPLUSPLUS_END_HEADER + # if defined(CPLUSPLUS_BUILD_LIB) # define CPLUSPLUS_EXPORT Q_DECL_EXPORT # else # define CPLUSPLUS_EXPORT Q_DECL_IMPORT # endif -# define CPLUSPLUS_WITH_NAMESPACE #else -# define CPLUSPLUS_BEGIN_HEADER -# define CPLUSPLUS_END_HEADER # define CPLUSPLUS_EXPORT #endif -#ifdef CPLUSPLUS_WITH_NAMESPACE -# define CPLUSPLUS_BEGIN_NAMESPACE namespace CPlusPlus { -# define CPLUSPLUS_END_NAMESPACE } // end of namespace CPlusPLus -# define CPLUSPLUS_USE_NAMESPACE using namespace CPlusPlus; -#else -# define CPLUSPLUS_BEGIN_NAMESPACE -# define CPLUSPLUS_END_NAMESPACE -# define CPLUSPLUS_USE_NAMESPACE ; -#endif - -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE +namespace CPlusPlus { class TranslationUnit; class Semantic; @@ -144,7 +129,6 @@ class ObjCProtocol; class ObjCForwardProtocolDeclaration; class ObjCMethod; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus #endif // CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index b7143797ad8..5a0142f384b 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -57,9 +57,8 @@ #include "Control.h" #include "Literals.h" #include -#include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; CheckDeclaration::CheckDeclaration(Semantic *semantic) : SemanticCheck(semantic), @@ -228,7 +227,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) if (it->declarator && it->declarator->initializer) { FullySpecifiedType initTy = semantic()->check(it->declarator->initializer, _scope); - Q_UNUSED(initTy) } *decl_it = new (translationUnit()->memoryPool()) List(); @@ -703,25 +701,25 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast) continue; const char *attrName = spell(attrAst->attribute_identifier_token); - if (!qstrcmp("getter", attrName)) { + if (!strcmp("getter", attrName)) { if (checkPropertyAttribute(attrAst, propAttrs, Getter)) { // TODO: find method declaration for getter } - } else if (!qstrcmp("setter", attrName)) { + } else if (!strcmp("setter", attrName)) { if (checkPropertyAttribute(attrAst, propAttrs, Setter)) { // TODO: find method declaration for setter } - } else if (!qstrcmp("readwrite", attrName)) { + } else if (!strcmp("readwrite", attrName)) { checkPropertyAttribute(attrAst, propAttrs, ReadWrite); - } else if (!qstrcmp("readonly", attrName)) { + } else if (!strcmp("readonly", attrName)) { checkPropertyAttribute(attrAst, propAttrs, ReadOnly); - } else if (!qstrcmp("assign", attrName)) { + } else if (!strcmp("assign", attrName)) { checkPropertyAttribute(attrAst, propAttrs, Assign); - } else if (!qstrcmp("retain", attrName)) { + } else if (!strcmp("retain", attrName)) { checkPropertyAttribute(attrAst, propAttrs, Retain); - } else if (!qstrcmp("copy", attrName)) { + } else if (!strcmp("copy", attrName)) { checkPropertyAttribute(attrAst, propAttrs, Copy); - } else if (!qstrcmp("nonatomic", attrName)) { + } else if (!strcmp("nonatomic", attrName)) { checkPropertyAttribute(attrAst, propAttrs, NonAtomic); } } @@ -745,4 +743,4 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast) return false; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/CheckDeclaration.h b/src/shared/cplusplus/CheckDeclaration.h index fcb773dd0ed..0e11a5398b4 100644 --- a/src/shared/cplusplus/CheckDeclaration.h +++ b/src/shared/cplusplus/CheckDeclaration.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "SemanticCheck.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT CheckDeclaration: public SemanticCheck { @@ -111,7 +111,7 @@ private: bool _checkAnonymousArguments: 1; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_CHECKDECLARATION_H diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp index 5867d6180aa..b44c90f955c 100644 --- a/src/shared/cplusplus/CheckDeclarator.cpp +++ b/src/shared/cplusplus/CheckDeclarator.cpp @@ -55,7 +55,7 @@ #include "CoreTypes.h" #include "Symbols.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; CheckDeclarator::CheckDeclarator(Semantic *semantic) : SemanticCheck(semantic), @@ -300,4 +300,4 @@ void CheckDeclarator::applyCvQualifiers(SpecifierAST *cv) } } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/CheckDeclarator.h b/src/shared/cplusplus/CheckDeclarator.h index 2f4ba6ba915..b676abfacd8 100644 --- a/src/shared/cplusplus/CheckDeclarator.h +++ b/src/shared/cplusplus/CheckDeclarator.h @@ -53,8 +53,8 @@ #include "SemanticCheck.h" #include "FullySpecifiedType.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT CheckDeclarator: public SemanticCheck { @@ -106,7 +106,7 @@ private: FullySpecifiedType _fullySpecifiedType; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_CHECKDECLARATOR_H diff --git a/src/shared/cplusplus/CheckExpression.cpp b/src/shared/cplusplus/CheckExpression.cpp index 805975b6250..02263d6b828 100644 --- a/src/shared/cplusplus/CheckExpression.cpp +++ b/src/shared/cplusplus/CheckExpression.cpp @@ -56,7 +56,7 @@ #include "Symbols.h" #include "Control.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; CheckExpression::CheckExpression(Semantic *semantic) : SemanticCheck(semantic), @@ -207,7 +207,6 @@ bool CheckExpression::visit(NewExpressionAST *ast) if (ast->new_placement) { for (ExpressionListAST *it = ast->new_placement->expression_list; it; it = it->next) { FullySpecifiedType exprTy = semantic()->check(it->expression, _scope); - Q_UNUSED(exprTy) } } @@ -215,18 +214,15 @@ bool CheckExpression::visit(NewExpressionAST *ast) if (ast->new_type_id) { FullySpecifiedType ty = semantic()->check(ast->new_type_id->type_specifier, _scope); - Q_UNUSED(ty) for (NewArrayDeclaratorAST *it = ast->new_type_id->new_array_declarators; it; it = it->next) { FullySpecifiedType exprTy = semantic()->check(it->expression, _scope); - Q_UNUSED(exprTy) } } // ### process new-initializer if (ast->new_initializer) { FullySpecifiedType exprTy = semantic()->check(ast->new_initializer->expression, _scope); - Q_UNUSED(exprTy) } return false; @@ -397,4 +393,4 @@ bool CheckExpression::visit(ObjCSelectorExpressionAST *ast) return false; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/CheckExpression.h b/src/shared/cplusplus/CheckExpression.h index 40cfc09f67e..a61371db43f 100644 --- a/src/shared/cplusplus/CheckExpression.h +++ b/src/shared/cplusplus/CheckExpression.h @@ -53,8 +53,8 @@ #include "SemanticCheck.h" #include "FullySpecifiedType.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT CheckExpression: public SemanticCheck { @@ -122,7 +122,7 @@ private: bool _checkOldStyleCasts: 1; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_CHECKEXPRESSION_H diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp index 4a3e884a472..19e2eedf98c 100644 --- a/src/shared/cplusplus/CheckName.cpp +++ b/src/shared/cplusplus/CheckName.cpp @@ -58,7 +58,7 @@ #include "Scope.h" #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; CheckName::CheckName(Semantic *semantic) : SemanticCheck(semantic), @@ -425,4 +425,4 @@ bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast) return false; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/CheckName.h b/src/shared/cplusplus/CheckName.h index d6fb271d48f..ec2b97beea0 100644 --- a/src/shared/cplusplus/CheckName.h +++ b/src/shared/cplusplus/CheckName.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "SemanticCheck.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT CheckName: public SemanticCheck { @@ -89,7 +89,7 @@ private: Scope *_scope; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_CHECKNAME_H diff --git a/src/shared/cplusplus/CheckSpecifier.cpp b/src/shared/cplusplus/CheckSpecifier.cpp index d4de2c55176..6baef4682ed 100644 --- a/src/shared/cplusplus/CheckSpecifier.cpp +++ b/src/shared/cplusplus/CheckSpecifier.cpp @@ -58,7 +58,7 @@ #include "Control.h" #include "Scope.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; CheckSpecifier::CheckSpecifier(Semantic *semantic) : SemanticCheck(semantic), @@ -420,4 +420,4 @@ bool CheckSpecifier::visit(ObjCTypeNameAST * /*ast*/) return true; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/CheckSpecifier.h b/src/shared/cplusplus/CheckSpecifier.h index 050981b3922..9f06a437714 100644 --- a/src/shared/cplusplus/CheckSpecifier.h +++ b/src/shared/cplusplus/CheckSpecifier.h @@ -53,8 +53,8 @@ #include "SemanticCheck.h" #include "FullySpecifiedType.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT CheckSpecifier: public SemanticCheck { @@ -88,7 +88,7 @@ private: Scope *_scope; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_CHECKSPECIFIER_H diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp index 086457f1c48..79a4e2e33d7 100644 --- a/src/shared/cplusplus/CheckStatement.cpp +++ b/src/shared/cplusplus/CheckStatement.cpp @@ -55,7 +55,7 @@ #include "Control.h" #include "Symbols.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; CheckStatement::CheckStatement(Semantic *semantic) : SemanticCheck(semantic), @@ -307,4 +307,4 @@ bool CheckStatement::visit(WhileStatementAST *ast) return false; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/CheckStatement.h b/src/shared/cplusplus/CheckStatement.h index 087b06928d1..6bd0c868ab9 100644 --- a/src/shared/cplusplus/CheckStatement.h +++ b/src/shared/cplusplus/CheckStatement.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "SemanticCheck.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT CheckStatement: public SemanticCheck { @@ -94,7 +94,7 @@ private: Scope *_scope; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_CHECKSTATEMENT_H diff --git a/src/shared/cplusplus/Control.cpp b/src/shared/cplusplus/Control.cpp index 30c5552bbe8..908bded1340 100644 --- a/src/shared/cplusplus/Control.cpp +++ b/src/shared/cplusplus/Control.cpp @@ -57,7 +57,7 @@ #include // ### replace me with LiteralTable #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; template @@ -766,4 +766,4 @@ ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsig ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name) { return d->newObjCMethod(sourceLocation, name); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Control.h b/src/shared/cplusplus/Control.h index 9a41629feaa..615eab38f89 100644 --- a/src/shared/cplusplus/Control.h +++ b/src/shared/cplusplus/Control.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Control { @@ -199,7 +199,7 @@ private: Data *d; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_CONTROL_H diff --git a/src/shared/cplusplus/CoreTypes.cpp b/src/shared/cplusplus/CoreTypes.cpp index 07a67829083..141ce3dc87b 100644 --- a/src/shared/cplusplus/CoreTypes.cpp +++ b/src/shared/cplusplus/CoreTypes.cpp @@ -51,7 +51,7 @@ #include "Names.h" #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; bool VoidType::isEqualTo(const Type *other) const @@ -230,4 +230,4 @@ bool NamedType::isEqualTo(const Type *other) const void NamedType::accept0(TypeVisitor *visitor) { visitor->visit(this); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/CoreTypes.h b/src/shared/cplusplus/CoreTypes.h index 64e96c174ba..67d8a795157 100644 --- a/src/shared/cplusplus/CoreTypes.h +++ b/src/shared/cplusplus/CoreTypes.h @@ -54,8 +54,8 @@ #include "FullySpecifiedType.h" #include -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT UndefinedType : public Type { @@ -272,7 +272,7 @@ private: Name *_name; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_CORETYPES_H diff --git a/src/shared/cplusplus/DiagnosticClient.cpp b/src/shared/cplusplus/DiagnosticClient.cpp index 8c5d52d91f3..ed5573d6320 100644 --- a/src/shared/cplusplus/DiagnosticClient.cpp +++ b/src/shared/cplusplus/DiagnosticClient.cpp @@ -48,7 +48,7 @@ #include "DiagnosticClient.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; DiagnosticClient::DiagnosticClient() { } @@ -56,4 +56,4 @@ DiagnosticClient::DiagnosticClient() DiagnosticClient::~DiagnosticClient() { } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/DiagnosticClient.h b/src/shared/cplusplus/DiagnosticClient.h index d9f9ff53f49..ff83a4c6f9a 100644 --- a/src/shared/cplusplus/DiagnosticClient.h +++ b/src/shared/cplusplus/DiagnosticClient.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "stdarg.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT DiagnosticClient { @@ -76,7 +76,7 @@ public: const char *format, va_list ap) = 0; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_DIAGNOSTICCLIENT_H diff --git a/src/shared/cplusplus/FullySpecifiedType.cpp b/src/shared/cplusplus/FullySpecifiedType.cpp index 58711ac8a96..578c6c9b7d6 100644 --- a/src/shared/cplusplus/FullySpecifiedType.cpp +++ b/src/shared/cplusplus/FullySpecifiedType.cpp @@ -50,7 +50,7 @@ #include "Type.h" #include "CoreTypes.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; FullySpecifiedType::FullySpecifiedType(Type *type) : _type(type), _flags(0) @@ -209,4 +209,4 @@ FullySpecifiedType FullySpecifiedType::simplified() const return *this; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/FullySpecifiedType.h b/src/shared/cplusplus/FullySpecifiedType.h index b9a1c3fa397..6c9f83d9145 100644 --- a/src/shared/cplusplus/FullySpecifiedType.h +++ b/src/shared/cplusplus/FullySpecifiedType.h @@ -51,8 +51,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT FullySpecifiedType { @@ -151,7 +151,7 @@ private: }; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_FULLYSPECIFIEDTYPE_H diff --git a/src/shared/cplusplus/Keywords.cpp b/src/shared/cplusplus/Keywords.cpp index f620bb745c1..48af1244736 100644 --- a/src/shared/cplusplus/Keywords.cpp +++ b/src/shared/cplusplus/Keywords.cpp @@ -49,7 +49,7 @@ #include "Lexer.h" #include "Token.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; static inline int classify2(const char *s, bool) { if (s[0] == 'd') { @@ -1400,4 +1400,4 @@ int Lexer::classifyOperator(const char *s, int n) { } // switch } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Lexer.cpp b/src/shared/cplusplus/Lexer.cpp index 79c9bf4af1c..a0cc9495d83 100644 --- a/src/shared/cplusplus/Lexer.cpp +++ b/src/shared/cplusplus/Lexer.cpp @@ -55,7 +55,7 @@ using namespace std; -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; Lexer::Lexer(TranslationUnit *unit) : _translationUnit(unit), @@ -720,4 +720,4 @@ void Lexer::scan_helper(Token *tok) } // switch } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Lexer.h b/src/shared/cplusplus/Lexer.h index 4f2e9e38628..2af593604d5 100644 --- a/src/shared/cplusplus/Lexer.h +++ b/src/shared/cplusplus/Lexer.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "Token.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Lexer { @@ -152,7 +152,7 @@ private: unsigned _currentLine; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_LEXER_H diff --git a/src/shared/cplusplus/LiteralTable.h b/src/shared/cplusplus/LiteralTable.h index 64fd2e1dac5..29de643002d 100644 --- a/src/shared/cplusplus/LiteralTable.h +++ b/src/shared/cplusplus/LiteralTable.h @@ -53,8 +53,8 @@ #include #include -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { template class LiteralTable @@ -185,7 +185,7 @@ protected: int _allocatedBuckets; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_LITERALTABLE_H diff --git a/src/shared/cplusplus/Literals.cpp b/src/shared/cplusplus/Literals.cpp index 5175979dfb0..40042eb66e4 100644 --- a/src/shared/cplusplus/Literals.cpp +++ b/src/shared/cplusplus/Literals.cpp @@ -53,7 +53,7 @@ using namespace std; -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; //////////////////////////////////////////////////////////////////////////////// Literal::Literal(const char *chars, unsigned size) @@ -227,4 +227,4 @@ bool Identifier::isEqualTo(const Identifier *other) const return ! strcmp(chars(), other->chars()); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Literals.h b/src/shared/cplusplus/Literals.h index a7cefc76ec6..2a11cdada73 100644 --- a/src/shared/cplusplus/Literals.h +++ b/src/shared/cplusplus/Literals.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "Token.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Literal { @@ -135,7 +135,7 @@ public: bool isEqualTo(const Identifier *other) const; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_LITERALS_H diff --git a/src/shared/cplusplus/MemoryPool.cpp b/src/shared/cplusplus/MemoryPool.cpp index 90cf4999931..2002a654350 100644 --- a/src/shared/cplusplus/MemoryPool.cpp +++ b/src/shared/cplusplus/MemoryPool.cpp @@ -51,7 +51,7 @@ #include #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; using namespace std; @@ -125,4 +125,4 @@ void Managed::operator delete(void *) void Managed::operator delete(void *, MemoryPool *) { } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/MemoryPool.h b/src/shared/cplusplus/MemoryPool.h index ef802eb359f..e0f1ff87017 100644 --- a/src/shared/cplusplus/MemoryPool.h +++ b/src/shared/cplusplus/MemoryPool.h @@ -53,8 +53,8 @@ #include #include -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT MemoryPool { @@ -110,7 +110,7 @@ public: void operator delete(void *, MemoryPool *); }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_MEMORYPOOL_H diff --git a/src/shared/cplusplus/Name.cpp b/src/shared/cplusplus/Name.cpp index bde12732a5a..6354382551d 100644 --- a/src/shared/cplusplus/Name.cpp +++ b/src/shared/cplusplus/Name.cpp @@ -50,7 +50,7 @@ #include "Names.h" #include "NameVisitor.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; Name::Name() { } @@ -93,4 +93,4 @@ void Name::accept(Name *name, NameVisitor *visitor) name->accept(visitor); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Name.h b/src/shared/cplusplus/Name.h index 1324a08feb9..45dfef86e65 100644 --- a/src/shared/cplusplus/Name.h +++ b/src/shared/cplusplus/Name.h @@ -51,8 +51,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Name { @@ -98,7 +98,7 @@ protected: virtual void accept0(NameVisitor *visitor) = 0; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_NAME_H diff --git a/src/shared/cplusplus/NameVisitor.cpp b/src/shared/cplusplus/NameVisitor.cpp index 85ae4206ae5..29630661d78 100644 --- a/src/shared/cplusplus/NameVisitor.cpp +++ b/src/shared/cplusplus/NameVisitor.cpp @@ -49,7 +49,7 @@ #include "NameVisitor.h" #include "Names.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; NameVisitor::NameVisitor() { } @@ -60,4 +60,4 @@ NameVisitor::~NameVisitor() void NameVisitor::accept(Name *name) { Name::accept(name, this); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/NameVisitor.h b/src/shared/cplusplus/NameVisitor.h index 19c2e0efb3f..f8889b7d7f6 100644 --- a/src/shared/cplusplus/NameVisitor.h +++ b/src/shared/cplusplus/NameVisitor.h @@ -51,8 +51,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT NameVisitor { @@ -77,7 +77,7 @@ public: virtual void visit(SelectorNameId *) {} }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_NAMEVISITOR_H diff --git a/src/shared/cplusplus/Names.cpp b/src/shared/cplusplus/Names.cpp index 0adfaab053d..9e60804e77b 100644 --- a/src/shared/cplusplus/Names.cpp +++ b/src/shared/cplusplus/Names.cpp @@ -52,7 +52,7 @@ #include #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; QualifiedNameId::QualifiedNameId(Name *const names[], unsigned nameCount, @@ -326,4 +326,4 @@ bool SelectorNameId::isEqualTo(const Name *other) const return true; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Names.h b/src/shared/cplusplus/Names.h index fa5dd6791f9..e5fef0cbec2 100644 --- a/src/shared/cplusplus/Names.h +++ b/src/shared/cplusplus/Names.h @@ -53,8 +53,8 @@ #include "Name.h" #include "FullySpecifiedType.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT QualifiedNameId: public Name { @@ -304,7 +304,7 @@ private: bool _hasArguments; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_NAMES_H diff --git a/src/shared/cplusplus/ObjectiveCAtKeywords.cpp b/src/shared/cplusplus/ObjectiveCAtKeywords.cpp index 3f8fc7c396f..cd42d045dd1 100644 --- a/src/shared/cplusplus/ObjectiveCAtKeywords.cpp +++ b/src/shared/cplusplus/ObjectiveCAtKeywords.cpp @@ -1,7 +1,7 @@ #include "Lexer.h" #include "Token.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; static inline int classify3(const char *s) { if (s[0] == 'e') { @@ -461,4 +461,4 @@ int Lexer::classifyObjCAtKeyword(const char *s, int n) { } // switch } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/ObjectiveCTypeQualifiers.cpp b/src/shared/cplusplus/ObjectiveCTypeQualifiers.cpp index d12d7c322c1..988076f3a7c 100644 --- a/src/shared/cplusplus/ObjectiveCTypeQualifiers.cpp +++ b/src/shared/cplusplus/ObjectiveCTypeQualifiers.cpp @@ -29,7 +29,7 @@ #include "ObjectiveCTypeQualifiers.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; static inline int classify2(const char *s) { if (s[0] == 'i') { @@ -234,7 +234,7 @@ static inline int classify9(const char *s) { return Token_identifier; } -int classifyObjectiveCTypeQualifiers(const char *s, int n) { +int CPlusPlus::classifyObjectiveCTypeQualifiers(const char *s, int n) { switch (n) { case 2: return classify2(s); case 3: return classify3(s); @@ -247,4 +247,4 @@ int classifyObjectiveCTypeQualifiers(const char *s, int n) { } // switch } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/ObjectiveCTypeQualifiers.h b/src/shared/cplusplus/ObjectiveCTypeQualifiers.h index 0f9cdfd6774..d0db4274616 100644 --- a/src/shared/cplusplus/ObjectiveCTypeQualifiers.h +++ b/src/shared/cplusplus/ObjectiveCTypeQualifiers.h @@ -31,8 +31,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { enum { Token_in, @@ -54,7 +54,7 @@ enum { CPLUSPLUS_EXPORT int classifyObjectiveCTypeQualifiers(const char *s, int n); -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_OBJC_TYPEQUALIFIERS_H diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index e60751305a9..a8e04e5ad1f 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -57,7 +57,7 @@ #include #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; Parser::Parser(TranslationUnit *unit) : _translationUnit(unit), @@ -4857,4 +4857,4 @@ bool Parser::parseObjCContextKeyword(int kind, unsigned &in_token) } } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h index 1dd204d1541..753f6f44b2e 100644 --- a/src/shared/cplusplus/Parser.h +++ b/src/shared/cplusplus/Parser.h @@ -54,8 +54,8 @@ #include "Token.h" #include "TranslationUnit.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Parser { @@ -305,7 +305,7 @@ private: void operator =(const Parser& source); }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_PARSER_H diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp index fcb5a68027c..16026f8060a 100644 --- a/src/shared/cplusplus/Scope.cpp +++ b/src/shared/cplusplus/Scope.cpp @@ -57,7 +57,7 @@ using namespace std; -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; Scope::Scope(ScopedSymbol *owner) : _owner(owner), @@ -312,4 +312,4 @@ Scope::iterator Scope::firstSymbol() const Scope::iterator Scope::lastSymbol() const { return _symbols + _symbolCount + 1; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Scope.h b/src/shared/cplusplus/Scope.h index 1abc41530df..c05a718ff37 100644 --- a/src/shared/cplusplus/Scope.h +++ b/src/shared/cplusplus/Scope.h @@ -51,8 +51,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Scope { @@ -153,7 +153,7 @@ private: int _hashSize; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_SCOPE_H diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp index c2ea233d697..e3b4b0b7ca4 100644 --- a/src/shared/cplusplus/Semantic.cpp +++ b/src/shared/cplusplus/Semantic.cpp @@ -59,7 +59,7 @@ #include "CheckExpression.h" #include "CheckName.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; class Semantic::Data { @@ -252,4 +252,4 @@ int Semantic::visibilityForClassKey(int tokenKind) const } } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Semantic.h b/src/shared/cplusplus/Semantic.h index 8a0df9a111f..b07883e8473 100644 --- a/src/shared/cplusplus/Semantic.h +++ b/src/shared/cplusplus/Semantic.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "ASTfwd.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Semantic { @@ -114,7 +114,7 @@ private: Data *d; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_SEMANTIC_H diff --git a/src/shared/cplusplus/SemanticCheck.cpp b/src/shared/cplusplus/SemanticCheck.cpp index 92fdbf83897..1feffd93aa5 100644 --- a/src/shared/cplusplus/SemanticCheck.cpp +++ b/src/shared/cplusplus/SemanticCheck.cpp @@ -49,7 +49,7 @@ #include "SemanticCheck.h" #include "Semantic.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; SemanticCheck::SemanticCheck(Semantic *semantic) : ASTVisitor(semantic->control()), @@ -65,4 +65,4 @@ Semantic *SemanticCheck::semantic() const Control *SemanticCheck::control() const { return _semantic->control(); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/SemanticCheck.h b/src/shared/cplusplus/SemanticCheck.h index 219a216e6ed..64523d903ce 100644 --- a/src/shared/cplusplus/SemanticCheck.h +++ b/src/shared/cplusplus/SemanticCheck.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include "ASTVisitor.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT SemanticCheck: public ASTVisitor { @@ -68,7 +68,7 @@ private: Semantic *_semantic; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_SEMANTICCHECK_H diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp index dc80add92b2..c04df48bafe 100644 --- a/src/shared/cplusplus/Symbol.cpp +++ b/src/shared/cplusplus/Symbol.cpp @@ -59,7 +59,7 @@ #include #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; class Symbol::HashCode: protected NameVisitor { @@ -476,4 +476,4 @@ bool Symbol::isObjCForwardProtocolDeclaration() const bool Symbol::isObjCMethod() const { return asObjCMethod() != 0; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h index 0857673d3f4..93d730b0cfb 100644 --- a/src/shared/cplusplus/Symbol.h +++ b/src/shared/cplusplus/Symbol.h @@ -51,8 +51,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Symbol { @@ -331,7 +331,7 @@ private: friend class Scope; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_SYMBOL_H diff --git a/src/shared/cplusplus/SymbolVisitor.cpp b/src/shared/cplusplus/SymbolVisitor.cpp index 09556c07738..de2a5f7eaf3 100644 --- a/src/shared/cplusplus/SymbolVisitor.cpp +++ b/src/shared/cplusplus/SymbolVisitor.cpp @@ -49,7 +49,7 @@ #include "SymbolVisitor.h" #include "Symbol.h" -CPLUSPLUS_USE_NAMESPACE +using namespace CPlusPlus; SymbolVisitor::SymbolVisitor() { } diff --git a/src/shared/cplusplus/SymbolVisitor.h b/src/shared/cplusplus/SymbolVisitor.h index 8708ab03212..4bfa3794308 100644 --- a/src/shared/cplusplus/SymbolVisitor.h +++ b/src/shared/cplusplus/SymbolVisitor.h @@ -51,8 +51,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT SymbolVisitor { @@ -90,7 +90,7 @@ public: virtual bool visit(ObjCMethod *) { return true; } }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // SYMBOLVISITOR_H diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp index d5fa07a99b9..aa15735410f 100644 --- a/src/shared/cplusplus/Symbols.cpp +++ b/src/shared/cplusplus/Symbols.cpp @@ -53,7 +53,7 @@ #include "Scope.h" #include -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; TemplateParameters::TemplateParameters(Scope *scope) : _previous(0), _scope(scope) @@ -819,4 +819,4 @@ void ObjCMethod::visitSymbol0(SymbolVisitor *visitor) } } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Symbols.h b/src/shared/cplusplus/Symbols.h index 10eb0366bff..acd13085f5b 100644 --- a/src/shared/cplusplus/Symbols.h +++ b/src/shared/cplusplus/Symbols.h @@ -55,8 +55,8 @@ #include "FullySpecifiedType.h" #include "Array.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class TemplateParameters { @@ -729,7 +729,7 @@ private: Scope *_arguments; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_SYMBOLS_H diff --git a/src/shared/cplusplus/Token.cpp b/src/shared/cplusplus/Token.cpp index 547849b1ccb..48bf61354f0 100644 --- a/src/shared/cplusplus/Token.cpp +++ b/src/shared/cplusplus/Token.cpp @@ -49,7 +49,7 @@ #include "Token.h" #include "Literals.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; static const char *token_names[] = { (""), (""), @@ -133,4 +133,4 @@ const char *Token::spell() const } // switch } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Token.h b/src/shared/cplusplus/Token.h index 00d42b7f89c..8bafc446875 100644 --- a/src/shared/cplusplus/Token.h +++ b/src/shared/cplusplus/Token.h @@ -52,8 +52,8 @@ #include "CPlusPlusForwardDeclarations.h" #include -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { enum Kind { T_EOF_SYMBOL = 0, @@ -336,7 +336,7 @@ public: }; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_TOKEN_H diff --git a/src/shared/cplusplus/TranslationUnit.cpp b/src/shared/cplusplus/TranslationUnit.cpp index b661bf26a04..0cecccf3199 100644 --- a/src/shared/cplusplus/TranslationUnit.cpp +++ b/src/shared/cplusplus/TranslationUnit.cpp @@ -61,7 +61,7 @@ using namespace std; -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; TranslationUnit::TranslationUnit(Control *control, StringLiteral *fileId) : _control(control), @@ -517,4 +517,4 @@ void TranslationUnit::release() _tokens = 0; } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/TranslationUnit.h b/src/shared/cplusplus/TranslationUnit.h index 608d510f70b..cc26f44be41 100644 --- a/src/shared/cplusplus/TranslationUnit.h +++ b/src/shared/cplusplus/TranslationUnit.h @@ -56,8 +56,8 @@ #include // for FILE* #include // ### remove me -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT TranslationUnit { @@ -204,7 +204,7 @@ private: }; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_TRANSLATIONUNIT_H diff --git a/src/shared/cplusplus/Type.cpp b/src/shared/cplusplus/Type.cpp index 99cef5fab4c..56a521cd85a 100644 --- a/src/shared/cplusplus/Type.cpp +++ b/src/shared/cplusplus/Type.cpp @@ -51,7 +51,7 @@ #include "CoreTypes.h" #include "Symbols.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; Type::Type() { } @@ -131,4 +131,4 @@ void Type::accept(Type *type, TypeVisitor *visitor) type->accept(visitor); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/Type.h b/src/shared/cplusplus/Type.h index a3c5fb0c006..82dfa1f63a2 100644 --- a/src/shared/cplusplus/Type.h +++ b/src/shared/cplusplus/Type.h @@ -51,8 +51,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT Type { @@ -130,7 +130,7 @@ protected: virtual void accept0(TypeVisitor *visitor) = 0; }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_TYPE_H diff --git a/src/shared/cplusplus/TypeVisitor.cpp b/src/shared/cplusplus/TypeVisitor.cpp index 1f1b7eff163..4c795c96e0b 100644 --- a/src/shared/cplusplus/TypeVisitor.cpp +++ b/src/shared/cplusplus/TypeVisitor.cpp @@ -49,7 +49,7 @@ #include "TypeVisitor.h" #include "Type.h" -CPLUSPLUS_BEGIN_NAMESPACE +using namespace CPlusPlus; TypeVisitor::TypeVisitor() { } @@ -60,4 +60,4 @@ TypeVisitor::~TypeVisitor() void TypeVisitor::accept(Type *type) { Type::accept(type, this); } -CPLUSPLUS_END_NAMESPACE + diff --git a/src/shared/cplusplus/TypeVisitor.h b/src/shared/cplusplus/TypeVisitor.h index 50337ae93f3..5d0ef4cd542 100644 --- a/src/shared/cplusplus/TypeVisitor.h +++ b/src/shared/cplusplus/TypeVisitor.h @@ -51,8 +51,8 @@ #include "CPlusPlusForwardDeclarations.h" -CPLUSPLUS_BEGIN_HEADER -CPLUSPLUS_BEGIN_NAMESPACE + +namespace CPlusPlus { class CPLUSPLUS_EXPORT TypeVisitor { @@ -88,7 +88,7 @@ public: virtual void visit(ObjCForwardProtocolDeclaration*) {} }; -CPLUSPLUS_END_NAMESPACE -CPLUSPLUS_END_HEADER +} // end of namespace CPlusPlus + #endif // CPLUSPLUS_TYPEVISITOR_H diff --git a/tests/auto/cplusplus/ast/tst_ast.cpp b/tests/auto/cplusplus/ast/tst_ast.cpp index 25871aea129..52dcc0a0f11 100644 --- a/tests/auto/cplusplus/ast/tst_ast.cpp +++ b/tests/auto/cplusplus/ast/tst_ast.cpp @@ -7,7 +7,7 @@ #include #include -CPLUSPLUS_USE_NAMESPACE +using namespace CPlusPlus; class tst_AST: public QObject { diff --git a/tests/auto/cplusplus/lookup/tst_lookup.cpp b/tests/auto/cplusplus/lookup/tst_lookup.cpp index f3e6a570d5a..8b64c58395d 100644 --- a/tests/auto/cplusplus/lookup/tst_lookup.cpp +++ b/tests/auto/cplusplus/lookup/tst_lookup.cpp @@ -10,7 +10,7 @@ #include #include -CPLUSPLUS_USE_NAMESPACE +using namespace CPlusPlus; template