diff --git a/kdevelop-4.7.1-fix-temporary-abuse-2.patch b/kdevelop-4.7.1-fix-temporary-abuse-2.patch index ae7ad7f..21647f6 100644 --- a/kdevelop-4.7.1-fix-temporary-abuse-2.patch +++ b/kdevelop-4.7.1-fix-temporary-abuse-2.patch @@ -1,22 +1,8 @@ -From: Milian Wolff -Date: Thu, 02 Jul 2015 22:17:50 +0000 -Subject: Remove ConvenientIterator::ref usage from oldcpp codebase. -X-Git-Url: http://quickgit.kde.org/?p=kdevelop.git&a=commitdiff&h=2f057e2190112e5e838ad7a04eb04a6fde6f2cde ---- -Remove ConvenientIterator::ref usage from oldcpp codebase. - -This requires some changes, as we cannot take the ptr address of -the macro anymore. Instead, we use them as value classes everywhere. -This may potentially degrade performance, but I don't have the time -to measure it right now with a release build and compare the impact. - -REVIEW: 124237 ---- - - +diff --git a/languages/cpp/cppduchain/cppduchain.cpp b/languages/cpp/cppduchain/cppduchain.cpp +index 7fd51fb..874cefd 100644 --- a/languages/cpp/cppduchain/cppduchain.cpp +++ b/languages/cpp/cppduchain/cppduchain.cpp -@@ -426,17 +426,17 @@ +@@ -426,17 +426,17 @@ QString preprocess( const QString& text, Cpp::EnvironmentFile* file, int line, Q DUChainReadLocker lock(DUChain::lock()); //Copy in all macros from the file for( Cpp::ReferenceCountedMacroSet::Iterator it( file->definedMacros().iterator() ); it; ++it ) { @@ -40,10 +26,11 @@ REVIEW: 124237 } } } - +diff --git a/languages/cpp/cppduchain/cpppreprocessenvironment.cpp b/languages/cpp/cppduchain/cpppreprocessenvironment.cpp +index bb5f72e..774ca2e 100644 --- a/languages/cpp/cppduchain/cpppreprocessenvironment.cpp +++ b/languages/cpp/cppduchain/cpppreprocessenvironment.cpp -@@ -47,9 +47,9 @@ +@@ -47,9 +47,9 @@ void CppPreprocessEnvironment::finishEnvironment(bool leaveEnvironmentFile) { void CppPreprocessEnvironment::removeMacro(const KDevelop::IndexedString& macroName) { m_macroNameSet.remove(macroName); @@ -56,7 +43,7 @@ REVIEW: 124237 rpp::Environment::setMacro(m); } -@@ -57,20 +57,20 @@ +@@ -57,20 +57,20 @@ void CppPreprocessEnvironment::removeString(const KDevelop::IndexedString& str) m_strings.erase(str.index()); } @@ -82,7 +69,7 @@ REVIEW: 124237 return ret; } -@@ -98,12 +98,13 @@ +@@ -98,12 +98,13 @@ void CppPreprocessEnvironment::swapMacros( rpp::Environment* parentEnvironment ) * */ void CppPreprocessEnvironment::merge( const Cpp::ReferenceCountedMacroSet& macros ) { for( Cpp::ReferenceCountedMacroSet::Iterator it(macros.iterator()); it; ++it ) { @@ -100,7 +87,7 @@ REVIEW: 124237 } } -@@ -114,7 +115,7 @@ +@@ -114,7 +115,7 @@ void CppPreprocessEnvironment::merge( const Cpp::EnvironmentFile* file, bool mer m_environmentFile->merge(*file); for( Cpp::ReferenceCountedMacroSet::Iterator it(addedMacros.iterator()); it; ++it ) @@ -109,7 +96,7 @@ REVIEW: 124237 for( Cpp::ReferenceCountedStringSet::Iterator it = file->definedMacroNames().iterator(); it; ++it ) { m_macroNameSet.insert(*it); -@@ -122,47 +123,47 @@ +@@ -122,47 +123,47 @@ void CppPreprocessEnvironment::merge( const Cpp::EnvironmentFile* file, bool mer //We don't have to care about efficiency too much here, unDefinedMacros should be a rather small set for( Cpp::ReferenceCountedStringSet::Iterator it = file->unDefinedMacroNames().iterator(); it; ++it ) { @@ -179,10 +166,11 @@ REVIEW: 124237 rpp::Environment::setMacro(macro); } - +diff --git a/languages/cpp/cppduchain/cpppreprocessenvironment.h b/languages/cpp/cppduchain/cpppreprocessenvironment.h +index 21fe915..14e0c01 100644 --- a/languages/cpp/cppduchain/cpppreprocessenvironment.h +++ b/languages/cpp/cppduchain/cpppreprocessenvironment.h -@@ -37,7 +37,7 @@ +@@ -37,7 +37,7 @@ public: ///@param leaveEnvironmentFile Whether the environment-file should be left untouched void finishEnvironment(bool leaveEnvironmentFile = false); @@ -191,7 +179,7 @@ REVIEW: 124237 void setEnvironmentFile( const KSharedPtr& environmentFile ); KSharedPtr environmentFile() const; -@@ -53,7 +53,7 @@ +@@ -53,7 +53,7 @@ public: ///@param mergeEnvironments Whether the environment-files should also be merged using Cpp::EnvironmentFile::merge void merge( const Cpp::EnvironmentFile* file, bool mergeEnvironments = false ); @@ -200,7 +188,7 @@ REVIEW: 124237 virtual int type() const; -@@ -83,6 +83,8 @@ +@@ -83,6 +83,8 @@ public: static void setRecordOnlyImportantString(bool); private: @@ -209,10 +197,11 @@ REVIEW: 124237 uint m_identityOffsetRestriction; bool m_identityOffsetRestrictionEnabled; bool m_finished; - +diff --git a/languages/cpp/cppduchain/environmentmanager.cpp b/languages/cpp/cppduchain/environmentmanager.cpp +index f881420..51f51a4 100644 --- a/languages/cpp/cppduchain/environmentmanager.cpp +++ b/languages/cpp/cppduchain/environmentmanager.cpp -@@ -170,7 +170,7 @@ +@@ -170,7 +170,7 @@ QString print(const Cpp::ReferenceCountedMacroSet& set) { ret += ", "; first = false; @@ -221,19 +210,15 @@ REVIEW: 124237 ++it; } return ret; -@@ -232,15 +232,14 @@ - const ReferenceCountedStringSet& conflicts = strings() - d_func()->m_usedMacroNames; - - for( ReferenceCountedStringSet::Iterator it(conflicts.iterator()); it; ++it ) { -- if (!environmentMacroNames.contains(it.ref())) { -+ if (!environmentMacroNames.contains(*it)) { +@@ -235,12 +235,12 @@ bool EnvironmentFile::matchEnvironment(const ParsingEnvironment* _environment) c + if (!environmentMacroNames.contains( *it )) { continue; } - rpp::pp_macro* m = cppEnvironment->retrieveStoredMacro( *it ); - if(m && !m->isUndef()) { -- + const rpp::pp_macro& m = cppEnvironment->retrieveStoredMacro( *it ); + if(m.isValid() && !m.isUndef()) { + #ifdef DEBUG_LEXERCACHE if(debugging()) { - kDebug(9007) << "The environment contains a macro that can affect the cached file, but that should not exist:" << m->name.str(); @@ -241,7 +226,7 @@ REVIEW: 124237 } #endif return false; -@@ -254,19 +253,20 @@ +@@ -254,19 +254,20 @@ bool EnvironmentFile::matchEnvironment(const ParsingEnvironment* _environment) c ifDebug( kDebug(9007) << "Count of used macros that need to be verified:" << d_func()->m_usedMacros.set().count() ); for ( ReferenceCountedMacroSet::Iterator it( d_func()->m_usedMacros.iterator() ); it; ++it ) { @@ -269,7 +254,7 @@ REVIEW: 124237 } } -@@ -329,22 +329,24 @@ +@@ -329,22 +330,24 @@ int EnvironmentFile::contentStartLine() const { return d_func()->m_contentStartLine; } @@ -300,7 +285,7 @@ REVIEW: 124237 } if(macro.isUndef()) { -@@ -520,7 +522,7 @@ +@@ -520,7 +523,7 @@ void EnvironmentFile::merge( const EnvironmentFile& file ) { Q_ASSERT(backup.set().setIndex() == file.d_func()->m_usedMacros.set().setIndex()); for(ReferenceCountedMacroSet::Iterator it( file.d_func()->m_usedMacros.iterator() ); it; ++it) { @@ -309,7 +294,7 @@ REVIEW: 124237 if( !definedMacroNamesSet.contains(macro.name.index()) && !unDefinedMacroNamesSet.contains(macro.name.index()) ) addUsedMacros.insert(it.index()); } -@@ -563,8 +565,7 @@ +@@ -563,8 +566,7 @@ void EnvironmentFile::merge( const EnvironmentFile& file ) { if(!affectedMacros.isEmpty()) { //We have to iterate through all potentially removed macros for( ReferenceCountedMacroSet::Iterator it( potentiallyRemoveMacros.iterator() ); it; ++it ) { @@ -319,18 +304,19 @@ REVIEW: 124237 removeDefinedMacros.insert(it.index()); } } - +diff --git a/languages/cpp/cppduchain/environmentmanager.h b/languages/cpp/cppduchain/environmentmanager.h +index 0ed17ca..213eb6c 100644 --- a/languages/cpp/cppduchain/environmentmanager.h +++ b/languages/cpp/cppduchain/environmentmanager.h -@@ -102,7 +102,6 @@ - +@@ -103,7 +103,6 @@ The good things: namespace rpp { -- class pp_macro; class pp_macro; +- class pp_macro; class Environment; } -@@ -217,7 +216,7 @@ + +@@ -217,7 +216,7 @@ class KDEVCPPDUCHAIN_EXPORT EnvironmentFile : public KDevelop::ParsingEnvironmen void addStrings( const std::set& strings ); ///If there previously was a macro defined of the same name, it must be given through previousOfSameName, else it can be zero. @@ -339,10 +325,11 @@ REVIEW: 124237 ///the given macro will only make it into usedMacros() if it was not defined in this file void usingMacro( const rpp::pp_macro& macro ); - +diff --git a/languages/cpp/cppduchain/tests/testenvironment.cpp b/languages/cpp/cppduchain/tests/testenvironment.cpp +index 00d0a34..5f0c410 100644 --- a/languages/cpp/cppduchain/tests/testenvironment.cpp +++ b/languages/cpp/cppduchain/tests/testenvironment.cpp -@@ -57,16 +57,16 @@ +@@ -57,16 +57,16 @@ void TestEnvironment::benchMerge() rpp::pp_macro m1(IndexedString(QString("my1Macro%1").arg(i))); rpp::pp_macro m2(IndexedString(QString("my2Macro%1").arg(i))); // define the two in the files @@ -365,10 +352,11 @@ REVIEW: 124237 } const IndexedString file(QLatin1String("f3")); QBENCHMARK { - +diff --git a/languages/cpp/cpplanguagesupport.cpp b/languages/cpp/cpplanguagesupport.cpp +index afa2dc8..c308148 100644 --- a/languages/cpp/cpplanguagesupport.cpp +++ b/languages/cpp/cpplanguagesupport.cpp -@@ -721,12 +721,12 @@ +@@ -722,12 +722,12 @@ QPair CppLanguageSupport::importedContextForPo return qMakePair(TopDUContextPointer(), SimpleRange::invalid()); } @@ -383,7 +371,7 @@ REVIEW: 124237 IndexedString word(found.first.first); SimpleRange wordRange(found.first.second); -@@ -735,38 +735,40 @@ +@@ -736,38 +736,40 @@ QPair CppLanguageSupport::usedMacroForPositio DUChainReadLocker lock(DUChain::lock(), 100); if(!lock.locked()) { kDebug(9007) << "Failed to lock the du-chain in time"; @@ -432,7 +420,7 @@ REVIEW: 124237 } SimpleRange CppLanguageSupport::specialLanguageObjectRange(const KUrl& url, const SimpleCursor& position) { -@@ -787,12 +787,12 @@ +@@ -788,12 +790,12 @@ QPair CppLanguageSupport::specialLanguageObjectJum return qMakePair(KUrl(import.first->url().str()), SimpleCursor(0,0)); } @@ -447,7 +435,7 @@ REVIEW: 124237 } QWidget* CppLanguageSupport::specialLanguageObjectNavigationWidget(const KUrl& url, const SimpleCursor& position) { -@@ -813,7 +813,7 @@ +@@ -814,7 +816,7 @@ QWidget* CppLanguageSupport::specialLanguageObjectNavigationWidget(const KUrl& u } } @@ -456,16 +444,7 @@ REVIEW: 124237 if(!m.first.isValid()) return 0; -@@ -824,7 +824,7 @@ - QString preprocessedBody; - //Check whether tail contains arguments - QString tail = found.second.trimmed(); ///@todo make this better. -- if(m.second->function_like) { -+ if(m.second.function_like) { - if(tail.endsWith('\\')) - tail.truncate(tail.length() - 1); - //properly support macro expansions when arguments contain newlines -@@ -861,7 +861,7 @@ +@@ -862,12 +864,12 @@ QWidget* CppLanguageSupport::specialLanguageObjectNavigationWidget(const KUrl& u preprocessedBody = i->formatSourceWithStyle(style, preprocessedBody, KUrl(), mime); } @@ -473,10 +452,28 @@ REVIEW: 124237 + return new Cpp::NavigationWidget(m.second, preprocessedBody); } - UIBlockTester::UIBlockTesterThread::UIBlockTesterThread( UIBlockTester& parent ) : QThread(), m_parent( parent ), m_stop(false) { +-bool CppLanguageSupport::isFunctionLike(const rpp::pp_macro* pm, const KUrl& url) ++bool CppLanguageSupport::isFunctionLike(const rpp::pp_macro& pm, const KUrl& url) + { +- if(pm->function_like) ++ if(pm.function_like) + return true; + + DUChainReadLocker lock(DUChain::lock(), 100); +@@ -883,7 +885,7 @@ bool CppLanguageSupport::isFunctionLike(const rpp::pp_macro* pm, const KUrl& url + Cpp::EnvironmentFilePointer p(dynamic_cast(ctx->parsingEnvironmentFile().data())); + + Q_ASSERT(p); +- QByteArray strdef = stringFromContents((uint*)pm->definition(), pm->definitionSize()).trimmed(); ++ QByteArray strdef = stringFromContents((uint*)pm.definition(), pm.definitionSize()).trimmed(); + + Cpp::ReferenceCountedMacroSet::Iterator it = p->usedMacros().iterator(); + +diff --git a/languages/cpp/cpplanguagesupport.h b/languages/cpp/cpplanguagesupport.h +index 92cbd7c..43d1571 100644 --- a/languages/cpp/cpplanguagesupport.h +++ b/languages/cpp/cpplanguagesupport.h -@@ -150,7 +150,7 @@ +@@ -150,7 +150,7 @@ private: QPair importedContextForPosition(const KUrl& url, const KDevelop::SimpleCursor& position); @@ -485,9 +482,20 @@ REVIEW: 124237 virtual KDevelop::SimpleRange specialLanguageObjectRange(const KUrl& url, const KDevelop::SimpleCursor& position); +@@ -158,7 +158,7 @@ private: + + virtual QWidget* specialLanguageObjectNavigationWidget(const KUrl& url, const KDevelop::SimpleCursor& position); + +- bool isFunctionLike(const rpp::pp_macro* pm, const KUrl& url); ++ bool isFunctionLike(const rpp::pp_macro& pm, const KUrl& url); + + static CppLanguageSupport* m_self; + +diff --git a/languages/cpp/cppparsejob.cpp b/languages/cpp/cppparsejob.cpp +index 380722f..381eb43 100644 --- a/languages/cpp/cppparsejob.cpp +++ b/languages/cpp/cppparsejob.cpp -@@ -229,8 +229,8 @@ +@@ -229,8 +229,8 @@ void CPPParseJob::mergeDefines(CppPreprocessEnvironment& env) const for(QHash::const_iterator it = defines.constBegin(); it != defines.constEnd(); ++it) { @@ -498,10 +506,11 @@ REVIEW: 124237 //Call rpp::Environment::setMacro directly, so we don't add the macro to the environment-file. //It should be only part of the environment. - +diff --git a/languages/cpp/parser/rpp/pp-engine.cpp b/languages/cpp/parser/rpp/pp-engine.cpp +index d0e9b73..93caed1 100644 --- a/languages/cpp/parser/rpp/pp-engine.cpp +++ b/languages/cpp/parser/rpp/pp-engine.cpp -@@ -310,16 +310,16 @@ +@@ -310,16 +310,16 @@ void pp::createProblem(Stream& input, const QString& description) { void pp::handle_define (Stream& input) { @@ -523,7 +532,7 @@ REVIEW: 124237 skip_blanks (++input, devnull()); // skip '(' uint formal = skip_identifier(input); -@@ -327,15 +327,15 @@ +@@ -327,15 +327,15 @@ void pp::handle_define (Stream& input) skip_blanks(input, devnull()); if (input == '.') { @@ -542,7 +551,7 @@ REVIEW: 124237 while (!input.atEnd() && input == ',') -@@ -347,7 +347,7 @@ +@@ -347,7 +347,7 @@ void pp::handle_define (Stream& input) skip_blanks (input, devnull()); if (input == '.') { @@ -551,7 +560,7 @@ REVIEW: 124237 do { ++input; -@@ -355,8 +355,8 @@ +@@ -355,8 +355,8 @@ void pp::handle_define (Stream& input) } while (input == '.'); } @@ -562,7 +571,7 @@ REVIEW: 124237 } RETURN_ON_FAIL(input == ')'); -@@ -381,7 +381,7 @@ +@@ -381,7 +381,7 @@ void pp::handle_define (Stream& input) if (!input.atEnd() && input == '\n') { skip_blanks(++input, devnull()); @@ -571,7 +580,7 @@ REVIEW: 124237 continue; } else { -@@ -394,24 +394,24 @@ +@@ -394,24 +394,24 @@ void pp::handle_define (Stream& input) do { if (input == '\\' && input.peekNextCharacter() == '"') { // skip escaped close quote @@ -600,7 +609,7 @@ REVIEW: 124237 ++input; } -@@ -505,8 +505,8 @@ +@@ -505,8 +505,8 @@ Value pp::eval_primary(Stream& input) } { @@ -611,19 +620,19 @@ REVIEW: 124237 } token = next_token(input); // skip '(' -@@ -1009,9 +1009,9 @@ +@@ -1009,9 +1009,9 @@ void pp::handle_ifdef (bool check_undefined, Stream& input) if (test_if_level()) { - pp_macro* macro = m_environment->retrieveMacro(macro_name, true); + const pp_macro& macro = m_environment->retrieveMacro(macro_name, true); bool value = false; -- if( macro && macro->defined ) -+ if( macro.isValid() && macro.defined ) +- if( macro && macro->defined && !(macro->file == currentFileName() && macro->sourceLine > input.originalInputPosition().line)) ++ if( macro.isValid() && macro.defined && !(macro.file == currentFileName() && macro.sourceLine > input.originalInputPosition().line)) value = true; if (check_undefined) -@@ -1030,12 +1030,12 @@ +@@ -1030,12 +1030,12 @@ void pp::handle_undef(Stream& input) KDevelop::IndexedString macro_name = KDevelop::IndexedString::fromIndex(skip_identifier(input)); RETURN_ON_FAIL(!macro_name.isEmpty()); @@ -631,21 +640,21 @@ REVIEW: 124237 - macro->file = currentFileName(); - macro->name = macro_name; - macro->sourceLine = input.originalInputPosition().line; -- -- macro->defined = false; + pp_macro macro; + macro.file = currentFileName(); + macro.name = macro_name; + macro.sourceLine = input.originalInputPosition().line; -+ + +- macro->defined = false; + macro.defined = false; m_environment->setMacro(macro); } - +diff --git a/languages/cpp/parser/rpp/pp-environment.cpp b/languages/cpp/parser/rpp/pp-environment.cpp +index 4d84eb5..b11fd73 100644 --- a/languages/cpp/parser/rpp/pp-environment.cpp +++ b/languages/cpp/parser/rpp/pp-environment.cpp -@@ -40,8 +40,6 @@ +@@ -40,8 +40,6 @@ Environment::Environment() Environment::~Environment() { delete m_locationTable; @@ -654,7 +663,7 @@ REVIEW: 124237 } LocationTable* Environment::locationTable() const -@@ -58,8 +56,6 @@ +@@ -58,8 +56,6 @@ LocationTable* Environment::takeLocationTable() void Environment::swapMacros( Environment* parentEnvironment ) { qSwap(m_environment, parentEnvironment->m_environment); @@ -663,7 +672,7 @@ REVIEW: 124237 } void Environment::clearMacro(const KDevelop::IndexedString& name) -@@ -67,34 +63,31 @@ +@@ -67,34 +63,31 @@ void Environment::clearMacro(const KDevelop::IndexedString& name) m_environment.remove(name); } @@ -706,7 +715,8 @@ REVIEW: 124237 { return m_environment.values(); } - +diff --git a/languages/cpp/parser/rpp/pp-environment.h b/languages/cpp/parser/rpp/pp-environment.h +index 328dc70..33cea66 100644 --- a/languages/cpp/parser/rpp/pp-environment.h +++ b/languages/cpp/parser/rpp/pp-environment.h @@ -27,7 +27,7 @@ @@ -718,7 +728,7 @@ REVIEW: 124237 namespace KDevelop { class IndexedString; -@@ -35,13 +35,12 @@ +@@ -35,13 +35,12 @@ namespace KDevelop { namespace rpp { @@ -733,7 +743,7 @@ REVIEW: 124237 Environment(); virtual ~Environment(); -@@ -50,19 +49,19 @@ +@@ -50,19 +49,19 @@ public: //The macro will be owned by the environment object //Note: Undef-macros are allowed too @@ -758,7 +768,7 @@ REVIEW: 124237 //Swap the macros with the given environment, includign ownership virtual void swapMacros( Environment* parentEnvironment ); -@@ -76,7 +75,6 @@ +@@ -76,7 +75,6 @@ public: private: EnvironmentMap m_environment; @@ -766,10 +776,11 @@ REVIEW: 124237 LocationTable* m_locationTable; }; - +diff --git a/languages/cpp/parser/rpp/pp-macro-expander.cpp b/languages/cpp/parser/rpp/pp-macro-expander.cpp +index a1cce4e..6460a79 100644 --- a/languages/cpp/parser/rpp/pp-macro-expander.cpp +++ b/languages/cpp/parser/rpp/pp-macro-expander.cpp -@@ -79,7 +79,7 @@ +@@ -79,7 +79,7 @@ void trim(QVector& array) { using namespace rpp; @@ -778,7 +789,7 @@ REVIEW: 124237 : depth(0) , expandingMacro(__expandingMacro) , actuals(__actuals) -@@ -91,10 +91,8 @@ +@@ -91,10 +91,8 @@ pp_actual pp_macro_expander::resolve_formal(const IndexedString& name, Stream& i if (!m_frame) return pp_actual(); @@ -791,7 +802,7 @@ REVIEW: 124237 if(name.isEmpty()) { KDevelop::ProblemPointer problem(new KDevelop::Problem); -@@ -122,7 +120,7 @@ +@@ -122,7 +120,7 @@ pp_actual pp_macro_expander::resolve_formal(const IndexedString& name, Stream& i return pp_actual(); } @@ -799,8 +810,8 @@ REVIEW: 124237 +#define RETURN_IF_INPUT_BROKEN if(input.atEnd()) { kDebug() << "too early end while expanding" << macro.name.str(); return; } - pp_macro_expander::pp_macro_expander(pp* engine, pp_frame* frame, bool inHeaderSection) -@@ -168,18 +166,20 @@ + pp_macro_expander::pp_macro_expander(pp* engine, pp_frame* frame, bool inHeaderSection, bool has_if) +@@ -170,18 +168,20 @@ struct EnableMacroExpansion { //A helper class that temporary hides a macro in the environment class MacroHider { public: @@ -813,10 +824,9 @@ REVIEW: 124237 + m_hideMacro.name = macro.name; m_hideMacro.hidden = true; - environment->insertMacro(&m_hideMacro); -- } -- ~MacroHider() { + environment->insertMacro(m_hideMacro); -+ } + } +- ~MacroHider() { + ~MacroHider() + { m_environment->insertMacro(m_macro); @@ -828,19 +838,30 @@ REVIEW: 124237 Environment* m_environment; }; -@@ -361,8 +361,8 @@ - // TODO handle inbuilt "defined" etc functions +@@ -368,18 +368,18 @@ void pp_macro_expander::operator()(Stream& input, Stream& output, bool substitut + continue; + } + if(m_has_if && m_has_defined){ +- pp_macro* macro = m_engine->environment()->retrieveMacro(name, true); ++ const pp_macro& macro = m_engine->environment()->retrieveMacro(name, false); + unsigned int value = 0; +- if(macro && macro->defined) ++ if( macro.isValid() && macro.defined ) + value = 1; + output.appendString(inputPosition, convertFromByteArray(QByteArray::number(value))); + m_has_defined = false; + continue; + } - pp_macro* macro = m_engine->environment()->retrieveMacro(name, false); -- -- if (!macro || !macro->defined || macro->hidden || macro->function_like || m_engine->hideNextMacro()) + const pp_macro& macro = m_engine->environment()->retrieveMacro(name, false); -+ + +- if (!macro || !macro->defined || macro->hidden || macro->function_like || m_engine->hideNextMacro()) + if (!macro.isValid() || !macro.defined || macro.hidden || macro.function_like || m_engine->hideNextMacro()) { - static const IndexedString definedIndex = IndexedString("defined"); - m_engine->setHideNextMacro(name == definedIndex); -@@ -402,13 +402,13 @@ + static const IndexedString lineIndex = IndexedString("__LINE__"); + static const IndexedString fileIndex = IndexedString("__FILE__"); +@@ -416,13 +416,13 @@ void pp_macro_expander::operator()(Stream& input, Stream& output, bool substitut EnableMacroExpansion enable(output, input.inputPosition()); //Configure the output-stream so it marks all stored input-positions as transformed through a macro @@ -856,7 +877,7 @@ REVIEW: 124237 ms.setOriginalInputPosition(input.originalInputPosition()); PreprocessedContents expanded; { -@@ -437,8 +437,8 @@ +@@ -451,8 +451,8 @@ void pp_macro_expander::operator()(Stream& input, Stream& output, bool substitut previous = IndexedString::fromIndex(output.peekLastOutput(stepsBack)); ++stepsBack; } @@ -867,7 +888,7 @@ REVIEW: 124237 output << input; ++input; continue; -@@ -462,12 +462,12 @@ +@@ -476,12 +476,12 @@ void pp_macro_expander::operator()(Stream& input, Stream& output, bool substitut ++input; } @@ -882,7 +903,7 @@ REVIEW: 124237 while (!input.atEnd() && input == ',') { -@@ -484,11 +484,11 @@ +@@ -498,11 +498,11 @@ void pp_macro_expander::operator()(Stream& input, Stream& output, bool substitut ++input; } @@ -896,7 +917,7 @@ REVIEW: 124237 } if( input != ')' ) { -@@ -526,7 +526,7 @@ +@@ -540,7 +540,7 @@ void pp_macro_expander::operator()(Stream& input, Stream& output, bool substitut if(frame.depth >= maxMacroExpansionDepth) { @@ -905,7 +926,7 @@ REVIEW: 124237 RETURN_IF_INPUT_BROKEN output << input; -@@ -538,7 +538,7 @@ +@@ -552,7 +552,7 @@ void pp_macro_expander::operator()(Stream& input, Stream& output, bool substitut MacroHider hideMacro(macro, m_engine->environment()); ///@todo UGLY conversion @@ -914,7 +935,7 @@ REVIEW: 124237 PreprocessedContents expansion_text; rpp::LocationTable table; -@@ -559,14 +559,14 @@ +@@ -573,14 +573,14 @@ void pp_macro_expander::operator()(Stream& input, Stream& output, bool substitut } } @@ -931,7 +952,7 @@ REVIEW: 124237 } trim(actualText); -@@ -589,7 +589,7 @@ +@@ -603,7 +603,7 @@ void pp_macro_expander::skip_actual_parameter(Stream& input, rpp::pp_macro& macr actuals.append(newActual); } @@ -940,7 +961,7 @@ REVIEW: 124237 { int first; -@@ -597,9 +597,9 @@ +@@ -611,9 +611,9 @@ void pp_macro_expander::skip_argument_variadics (const QList& __actua first = input.offset(); skip_argument(input, output); @@ -952,11 +973,11 @@ REVIEW: 124237 - && (__actuals.size() + 1) == (int)__macro->formalsSize()); + && (__actuals.size() + 1) == (int)__macro.formalsSize()); } - - +diff --git a/languages/cpp/parser/rpp/pp-macro-expander.h b/languages/cpp/parser/rpp/pp-macro-expander.h +index b16b0c2..b981b12 100644 --- a/languages/cpp/parser/rpp/pp-macro-expander.h +++ b/languages/cpp/parser/rpp/pp-macro-expander.h -@@ -64,10 +64,10 @@ +@@ -64,10 +64,10 @@ public: class pp_frame { public: @@ -969,7 +990,7 @@ REVIEW: 124237 QList actuals; }; -@@ -83,7 +83,7 @@ +@@ -83,7 +83,7 @@ public: /// If substitute == true, perform only macro parameter substitution and # token processing void operator()(Stream& input, Stream& output, bool substitute = false, LocationTable* table = 0); @@ -978,7 +999,7 @@ REVIEW: 124237 Stream& input, Stream& output); bool in_header_section() const { -@@ -101,7 +101,7 @@ +@@ -101,7 +101,7 @@ public: private: /// Read actual parameter of @ref macro value from @ref input and append it to @ref actuals /// @ref expander is a reusable macro expander @@ -987,10 +1008,11 @@ REVIEW: 124237 pp* m_engine; pp_frame* m_frame; - +diff --git a/languages/cpp/parser/rpp/pp-macro.cpp b/languages/cpp/parser/rpp/pp-macro.cpp +index 6209c83..27c8e85 100644 --- a/languages/cpp/parser/rpp/pp-macro.cpp +++ b/languages/cpp/parser/rpp/pp-macro.cpp -@@ -53,6 +53,16 @@ +@@ -53,6 +53,16 @@ bool pp_macro::operator==(const pp_macro& rhs) const { listsEqual(rhs); } @@ -1007,7 +1029,7 @@ REVIEW: 124237 void pp_macro::invalidateHash() { m_valueHashValid = false; } -@@ -88,18 +98,28 @@ +@@ -88,18 +98,28 @@ pp_macro::pp_macro(const pp_macro& rhs, bool dynamic) : copyListsFrom(rhs); } @@ -1022,8 +1044,7 @@ REVIEW: 124237 - , m_valueHashValid(false) - , m_valueHash(0) +pp_macro& pp_macro::operator=(const pp_macro& rhs) - { -- initializeAppendedLists(); ++{ + name = rhs.name; + file = rhs.file; + sourceLine = rhs.sourceLine; @@ -1043,14 +1064,16 @@ REVIEW: 124237 + +pp_macro::pp_macro(const char* nm) + : pp_macro(IndexedString(nm)) -+{ + { +- initializeAppendedLists(); } QString pp_macro::toString() const { - +diff --git a/languages/cpp/parser/rpp/pp-macro.h b/languages/cpp/parser/rpp/pp-macro.h +index 9998dc9..c1f8aa2 100644 --- a/languages/cpp/parser/rpp/pp-macro.h +++ b/languages/cpp/parser/rpp/pp-macro.h -@@ -44,10 +44,12 @@ +@@ -44,10 +44,12 @@ public: ///@todo enable structure packing pp_macro(const KDevelop::IndexedString& name = KDevelop::IndexedString()); @@ -1065,7 +1088,7 @@ REVIEW: 124237 uint classSize() const { return sizeof(pp_macro); } -@@ -78,6 +80,8 @@ +@@ -78,6 +80,8 @@ public: mutable HashType m_valueHash; //Hash that represents the values of all macros bool operator==(const pp_macro& rhs) const; @@ -1074,7 +1097,7 @@ REVIEW: 124237 bool isUndef() const { return !defined; -@@ -171,8 +175,7 @@ +@@ -171,8 +175,7 @@ public: return !appendedListsDynamic(); } @@ -1084,4 +1107,3 @@ REVIEW: 124237 void computeHash() const; }; -