[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevelop/4.5] languages/cpp/cppduchain: Fix usage of PushValue for recursion counters in TemplateDe
From:       Milian Wolff <mail () milianw ! de>
Date:       2013-07-31 21:56:09
Message-ID: E1V4eNN-0002cc-Qy () scm ! kde ! org
[Download RAW message or body]

Git commit 886ad1d967bf52a5b4caab79b3409650e205b398 by Milian Wolff.
Committed on 31/07/2013 at 21:53.
Pushed by mwolff into branch '4.5'.

Fix usage of PushValue for recursion counters in TemplateDeclaration.

PushValue takes a new value, not a delta value. Thus something like
the following does not do what you think it does:

    PushValue increase(myCounter, +1);

This always sets the value to 1 and resets the old value at exit.
To push a delta value, you need to be more verbose:

    PushValue increase(myCounter, myCounter + 1);

This was while reviewing new code in review request 111796. Shows
how much good a code review can do! I checked all other uses of
PushValue and they seem to work as intended.

M  +2    -3    languages/cpp/cppduchain/templatedeclaration.cpp

http://commits.kde.org/kdevelop/886ad1d967bf52a5b4caab79b3409650e205b398

diff --git a/languages/cpp/cppduchain/templatedeclaration.cpp \
b/languages/cpp/cppduchain/templatedeclaration.cpp index 9d8ba4c..321a2dc 100644
--- a/languages/cpp/cppduchain/templatedeclaration.cpp
+++ b/languages/cpp/cppduchain/templatedeclaration.cpp
@@ -219,7 +219,7 @@ struct DelayedTypeResolver : public KDevelop::TypeExchanger
   virtual AbstractType::Ptr exchange( const AbstractType::Ptr& type )
   {
     ThreadLocalData& data = threadDataLocal();
-    PushValue<uint> inc(data.delayedDepth, +1);
+    PushValue<uint> inc(data.delayedDepth, data.delayedDepth + 1);
     if( data.delayedDepth > 30 ) {
       kDebug(9007) << "Too much depth in DelayedTypeResolver::exchange, while exchanging" << (type ? \
type->toString() : QString("(null)"));  return type;
@@ -273,7 +273,6 @@ struct DelayedTypeResolver : public KDevelop::TypeExchanger
         if( aType )
           aType->exchangeTypes(this);
 
-        
         return typeCopy;
       }
     }
@@ -633,7 +632,7 @@ CppDUContext<KDevelop::DUContext>* instantiateDeclarationAndContext( KDevelop::D
         ///an AliasDeclaration represents a C++ "using bla::bla;" declaration.
         if(AliasDeclaration* alias = dynamic_cast<AliasDeclaration*>(instantiatedDeclaration)) {
           ThreadLocalData& data = threadDataLocal();
-          PushValue<uint> safety(data.aliasDepth, +1);
+          PushValue<uint> safety(data.aliasDepth, data.delayedDepth + 1);
           if(data.aliasDepth > 30) {
             kWarning() << "depth-limit reached while resolving alias-declaration" << \
alias->identifier().toString() << "within" << parentContext->scopeIdentifier(true).toString();  }else {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic