New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ code using templates ending with >> does not get parsed properly (but hey it's not really valid C++ so why should it) (Origin: bugzilla #560512) #3170

Closed
doxygen opened this Issue Jul 2, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@doxygen
Owner

doxygen commented Jul 2, 2018

status RESOLVED severity normal in component build for ---
Reported in version 1.5.7.1 on platform Other
Assigned to: Dimitri van Heesch

Original attachment names and IDs:

On 2008-11-12 14:54:15 +0000, Jonas Truemper wrote:

Please describe the problem:
Doxygen does not parse source code below a Typedef that uses at least two template classes inside the declaration and if the closing braces (">") do not have whitespaces between them. If this is before a class definition, the class will simply not be parsed/present in the output afterwards.

Here is some sample code that if run doxygen on, reproduces the faulty behavior:

######## The header file:

typedef std::pair<std::string, std::vector> SomeTypeDefWithTwoTemplates;

class TestClass {
void foo();
};

######## The implementation:
#include "testclass.h"

void TestClass::foo() {
int x = 0;
}

So pay special attention to the typedef:
typedef std::pair<std::string, std::vector> SomeTypeDefWithTwoTemplates;

would cause doxygen to miss the class definition below.

If you put the typedef as follows, everything works fine:

typedef std::pair<std::string, std::vector > SomeTypeDefWithTwoTemplates;

(See the difference at the template closing brackets, the WHITESPACE)

This is a kind of problematic bug since a lot of header files can contain some typedefs in front of a class definition!

Steps to reproduce:

  1. Save the source code provided in the description to .h and .cpp files
  2. Save the doxygen configuration provided under "other information"
  3. Run doxygen with the provided config file.

Actual results:
Check XML output for correctness. There should be no class file if there is no space between the closing template braces.

Expected results:
There should be an XML file describing the structure of the class TestClass

Does this happen every time?
yes

Other information:
Doxygen config file to reproduce the bug:

Doxyfile 1.5.4

#---------------------------------------------------------------------------

Project related configuration options

#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME =
PROJECT_NUMBER =
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
#---------------------------------------------------------------------------

Build related configuration options

#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = YES
EXTRACT_ANON_NSPACES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------

configuration options related to warning and progress messages

#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = NO
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = NO
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text "
WARN_LOGFILE =
#---------------------------------------------------------------------------

configuration options related to the input files

#---------------------------------------------------------------------------
INPUT =
INPUT_ENCODING = UTF-8
FILE_PATTERNS =
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------

configuration options related to source browsing

#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------

configuration options related to the alphabetical class index

#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------

configuration options related to the HTML output

#---------------------------------------------------------------------------
GENERATE_HTML = NO
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
HTML_DYNAMIC_SECTIONS = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------

configuration options related to the LaTeX output

#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------

configuration options related to the RTF output

#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------

configuration options related to the man page output

#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------

configuration options related to the XML output

#---------------------------------------------------------------------------
GENERATE_XML = YES
XML_OUTPUT = doxygenoutput/
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------

configuration options for the AutoGen Definitions output

#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------

configuration options related to the Perl module output

#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------

Configuration options related to the preprocessor

#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------

Configuration::additions related to external references

#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------

Configuration options related to the dot tool

#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = NO
COLLABORATION_GRAPH = NO
GROUP_GRAPHS = NO
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = NO
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = NO
DIRECTORY_GRAPH = NO
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = NO
DOT_CLEANUP = YES
#---------------------------------------------------------------------------

Configuration::additions related to the search engine

#---------------------------------------------------------------------------
SEARCHENGINE = NO

On 2008-11-12 14:59:31 +0000, Jonas Truemper wrote:

Created attachment 122500
testclass header file

On 2008-11-12 15:02:24 +0000, Jonas Truemper wrote:

Created attachment 122501
testclass implementation file

On 2008-11-12 15:02:47 +0000, Jonas Truemper wrote:

Created attachment 122502
doxygen config file

On 2008-11-12 20:15:14 +0000, Dimitri van Heesch wrote:

Did you know that closing a template with >> is not valid C++?

So you could also argue that there is a bug in your compiler if it accepts this broken code (VC++ does accept this, gcc does not, who do you think is more standards compliant? ;-).

Note that "typedef C>m> T;" is valid C++, where >> is the shift operator, and this is handled correctly by doxygen.

For C# code doxygen does accept the >> as a way to end a template.

On 2008-11-12 22:07:33 +0000, Jonas Truemper wrote:

Hi Dimitri,

thanks for your immediate reply on this!

actually, you're right: I did not know this. And as I'm using VC++ the code compiles without any errors. So I guess I will have to check my code for errors like this.
Is there any switch for Doxygen I did not know yet to display/complain about errors like this? So I could quickly find out which files do contain errors like this..

Last but not least: thanks for this great tool! I'm using doxygen's xml output to analyze the static structure of source code which comes in very handy with doxygen!

So as the described behaviour is a feature and not a bug I guess you can close this one. :-)

Cheers,
Jonas

On 2008-12-24 16:11:15 +0000, Dimitri van Heesch wrote:

I'll leave this bug open as placeholder for other people running into the same issue. Adjusted summary accordingly.

On 2009-01-25 11:06:14 +0000, Dimitri van Heesch wrote:

*** Bug 527202 has been marked as a duplicate of this bug. ***

On 2009-01-25 11:22:17 +0000, Dimitri van Heesch wrote:

See http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=220 for a discussion on this issue.

On 2009-02-28 02:22:13 +0000, David Legault wrote:

With C++0x this is valid syntax under GCC 4.3.2+

I'm coding a new project using C++0x features and the issue with the old > > needing a space is resolved.

Doxygen should cope with the situation.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html

On 2009-04-03 14:34:38 +0000, Dimitri van Heesch wrote:

David Legault wrote "Doxygen should cope with the situation".
Ok, please add the patch that adds support for this then.

On 2009-04-03 14:35:42 +0000, Dimitri van Heesch wrote:

*** Bug 577464 has been marked as a duplicate of this bug. ***

On 2009-07-06 17:50:44 +0000, Dimitri van Heesch wrote:

*** Bug 587629 has been marked as a duplicate of this bug. ***

On 2009-07-19 13:04:45 +0000, Dimitri van Heesch wrote:

I'll implement approach 1 of the article mentioned in comment # 9 to deal with this recurring issue.

On 2009-08-20 10:13:18 +0000, Dimitri van Heesch wrote:

This bug was previously marked ASSIGNED, which means it should be fixed in
doxygen version 1.6.0. Please verify if this is indeed the case and reopen the
bug if you think it is not fixed (include any additional information that you
think can be relevant).

@doxygen doxygen closed this Jul 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment