Incorrect snav method definition signature

From FetchWiki

Jump to: navigation, search


[edit] Status

  • Problem replicated
  • Solution suggested

[edit] Problem description

Consider the following source extract, copied from cell.h in example project Teamspirit:

namespace Spreadsheetns {
 using std::string;
 class Cell: {
   Cell(const long, const long, const string, const bool, IFormula* vector<Cell*>);

The line in SourceNavigator's dbdump file for method declarations is:

Cell Cell 000082.003 spreadsheet/cell.h;82.7 0x4004 {int} {const long,const long,const int,const bool,IFormula *,vector<Cell*>} {,,string,,,} {}

This is clearly incorrect, as it should indicate:

Cell Cell 000082.003 spreadsheet/cell.h;82.7 0x4004 {int} {const long,const long,const string,const bool,IFormula *,vector<Cell*>} {,,string,,,} {}

In contrast, the method implementation is specified as follows in file cell.cxx:

Cell::Cell(const long colNr, const long rowNr, const string str, bool hasText, IFormula *formula, vector<Cell*> publishers) :

The corresponding line in SourceNavigator's dbdump file for method implementations is:

Cell Cell 000081.001 spreadsheet/cell.cxx;81.11 0x4000 {int} {const long,const long,const string,bool,IFormula *,vector<Cell*>} {colNr,rowNr,str,hasText,formula,publishers} {}

This seems to indicate that the presence of the parameter name str helps SourceNavigator in recognizing the correct parameter type.

[edit] Relevance

The resolution of this issue is relevant, as it causes snavtofamix to consider the following two generated entities as two different methods. Snavtofamix thus extracts the following CDIF entity:

(Method FM866                 <------ The declaration in the header file
       (name "Cell")
       (belongsTo "Cell")
       (uniqueName "Cell.Cell(long,long,int,bool,IFormula *,vector<Cell*>)")
       (isAbstract -FALSE-)
       (accessControlQualifier "public")
       (signature "Cell(long,long,int,bool,IFormula *,vector<Cell*>)")
       (isConstructor -TRUE-)
       (sourceAnchor #[file "spreadsheet/cell.h" start 82 end 82|]#)

(Method FM1463                 <------ The implementation in the source file
       (name "Cell")
       (belongsTo "Cell")
       (uniqueName "Cell.Cell(long,long,string,bool,IFormula *,vector<Cell*>)")
       (isAbstract -FALSE-)
       (accessControlQualifier "")
       (signature "Cell(long,long,string,bool,IFormula *,vector<Cell*>)")
       (isConstructor -TRUE-)
       (sourceAnchor #[file "spreadsheet/cell.cxx" start 81 end 81|]#)

However, the latter is merely the implementation of the former, for which no CDIF entity is supposed to be generated. In other words, the CDIF representation of class Cell will contain one additional method.

[edit] Problem replication

The problem was replicated using the following code fragment, contained in a file Foo.cpp:

#include <string>

using std::string;

class Foo {
		Foo(const long, const long, const string, const bool);
		Foo(long, string, bool);
		Foo(const bool b, const long l1, const string s, const long l2);

After creating a SourceNavigator project for file Foo.cpp, the resulting method declaration database dump contained the following lines:

Foo Foo 000007.002 Foo.cpp;7.5 0x4004 {int} {const long,const long,const int,const bool} {,,string,} {}
Foo Foo 000008.002 Foo.cpp;8.5 0x4004 {int} {long,string,bool} {,,} {}
Foo Foo 000009.002 Foo.cpp;9.5 0x4004 {int} {const bool,const long,const string,const long} {b,l1,s,l2} {}

This example indicates that the issue only applies in case the method declaration has a nameless parameter of type const int.

[edit] Suggested solutions

  • Use the parameter name-type combination to identify occurrences of this issue. However, since string is a valid parameter name, we must ensure that the name of the parameter of type const int is in fact not just string. We might do this by verifying whether the #include <string> include directive was used in the includes dictionary.
Personal tools