[PATCH] [1/2] prototype mistaken as class constructor: recognize pointers

Dave Dodge <[email protected]>
Newsgroups gmane.text.doxygen.devel
Message-ID <20051219230310.GE23243@basmati>
Symptom: Some function prototypes end up being treated as constructor calls.

Example:

  /** \brief something */
  typedef struct { int x; } t;
  extern t foo(struct t *);        // declaration

  /** \brief something */
  t foo(struct t * x)              // definition

Doxygen thinks that the declaration is actually a variable being
created with a call to a constructor for type t.  It ends up putting
it in the "Variables" section.

This patch adds a check of the arguments being passed to the function
that might be a constructor.  If any argument ends in an asterisk, it
must be a bare pointer type with no parameter name and therefore this
must be a function prototype instead of a constructor call.

Index: doxygen-1.4.5/src/doxygen.cpp
===================================================================
--- doxygen-1.4.5.orig/src/doxygen.cpp	2005-11-11 12:07:22.000000000 -0500
+++ doxygen-1.4.5/src/doxygen.cpp	2005-11-11 12:20:06.000000000 -0500
@@ -1972,6 +1972,13 @@
         result=FALSE; // arg type is a known type
         goto done;
       }
+      // If the argument is a pointer type, then this is a function prototype.
+      if (a->type.find('*',a->type.length()-1)!=-1)
+      {
+        //printf("%s:%d: false (arg is a pointer)\n",__FILE__,__LINE__);
+        result=FALSE;
+        goto done;
+      }
       if (a->type.find(initChars)==0) 
       {
         result=TRUE; // argument type starts with typical initializer char


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.