[PATCH] properly track static-like attribute after anonymous namespace in C++

Anthony Foiani <[email protected]> Sat, 9 Mar 2013 03:13:35 -0700
Newsgroups gmane.text.doxygen.devel
Message-ID <CAOhNY-9QqG8XQnTUotM-oEdqOvG_zQ2srW+CsRX41UW82vTO_g@mail.gmail.com>
Greetings!

I was having issues with various functions not getting documented.  After a
few hours of debugging, it seems that C++ anonymous namespaces "leak" their
static-like cloaking onto the first function after the close of anonymous
namespace.

I'm not sure this is a 100% correct fix, but it works for my code base.

Thanks,
Tony

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev

_______________________________________________
Doxygen-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/doxygen-develop
reset-static-after-anon-ns.patch (application/octet-stream, 1.1 KB)
diff --git a/src/scanner.l b/src/scanner.l
index 15e5f86..f28a2a1 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -6276,6 +6276,8 @@ static void parseCompounds(Entry *rt)
       initEntry();
       gstat = FALSE;
       int ni=ce->name.findRev("::"); if (ni==-1) ni=0; else ni+=2;
+      bool popAnonNamespace = FALSE;
+      bool oldIsStatic = gstat;
       // set default protection based on the compound type
       if( ce->section==Entry::CLASS_SEC ) // class
       {
@@ -6313,6 +6315,7 @@ static void parseCompounds(Entry *rt)
 	if (ce->section == Entry::NAMESPACE_SEC ) // unnamed namespace
 	{
           current->stat = gstat = TRUE;
+          popAnonNamespace = TRUE;
 	}
 	current->protection = protection = ce->protection;
       }
@@ -6334,6 +6337,12 @@ static void parseCompounds(Entry *rt)
       //forceEndGroup();
 
       groupLeaveCompound(yyFileName,yyLineNr,ce->name);
+
+      if (popAnonNamespace)
+      {
+        //dbg(("scan: pc: popping anon namespace\n"));
+        gstat = oldIsStatic;
+      }
       
       delete current; current=0;
       ce->program.resize(0);