public inbox for sourcenav@sourceware.org
 help / color / mirror / Atom feed
* Can I use SN to ask questions about C++?
@ 2000-09-24 12:19 Mark Stankus
  2000-09-24 12:41 ` Ian Roxborough
  2000-09-27 21:38 ` Ben Elliston
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Stankus @ 2000-09-24 12:19 UTC (permalink / raw)
  To: sourcenav

 
Dear Source Navigator Developer(s),
 
  I love Source Navigator(SN).
 
  I was wondering if there is an API for SN so that I could write small
programs
(or write data base queries) to ask questions about the C++ code which
has been "SN-ed".
The goal is to look for inefficiencies in C++ code and improve
maintainability of C++
via computer programs.  The questions below are samples (requiring some
SQL would be
fine or, even better, a C++ interface).
 
(Note, if any of the following questions can be answered by an existing
tool,
I would like to know.)
 
Thanks,
Mark Stankus
mstankus@calpoly.edu
 
1) Determine all class names which have a default constructor generated
by the compiler.
2) Determine all class names which have a default constructor generated
by the compiler
   and it is used.
3) Determine all class names which have a copy constructor generated by
the compiler.
4) Determine all class names which have a copy constructor generated by
the compiler
   and it is used.
5) Find all class names which use the macro
USE_GENERATED_DEFAULT_CONSTRUCTOR
6) Find all class names which use the macro
   USE_GENERATED_DEFAULT_CONSTRUCTOR, and define a default constructor.
   ( This would be some "AND" in terms of data base queries or a list
intersection
     for a C++ interface. )
   (BY THE WAY, I would like to start putting EITHER
USE_GENERATED_DEFAULT_CONSTRUCTOR or X()
    but not both in every class X which I write so that my intentions
are clear.)
7) Find all instances of 'bool operator==(unsigned int,int)' in the
code.
   (For example,  int main() {
                    unsigned int a,b;
                    int c;
                    bool d = a==b;
                    bool e = a==c;
                    bool f = 0==1L;
                    bool g = 0U==1;
                    return 0;
                  }
                  would indicate the 'e' and 'g' lines.)         
 
8) Determine all locations where adding the keyword 'explicit' to a
   constructor, say 'X(const Y &)', will create a compiler error.
   (See http://www.calpoly.edu/~mstankus/mozilla )
9) Find all locations where adding the keyword 'explicit' to the code
   wherever appropriate would generate compiler errors.
   (See http://www.calpoly.edu/~mstankus/mozilla )
10) Determine when temporaries are created.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can I use SN to ask questions about C++?
  2000-09-24 12:19 Can I use SN to ask questions about C++? Mark Stankus
@ 2000-09-24 12:41 ` Ian Roxborough
  2000-09-27 21:38   ` Ben Elliston
  2000-09-27 21:38 ` Ben Elliston
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Roxborough @ 2000-09-24 12:41 UTC (permalink / raw)
  To: Mark Stankus; +Cc: sourcenav

Mark Stankus wrote:
>   I was wondering if there is an API for SN so that I could write small
> programs
> (or write data base queries) to ask questions about the C++ code which
> has been "SN-ed".
> The goal is to look for inefficiencies in C++ code and improve
> maintainability of C++ via computer programs.

Code Refactoring.  This is something I want to add to SN sometime
down the line.  The requirements of code refactoring would make a 
good start for how well the parsers should work.

> The questions below are samples (requiring some
> SQL would be
> fine or, even better, a C++ interface).
> 
> (Note, if any of the following questions can be answered by an existing
> tool,
> I would like to know.)

There is documentation on the database API (Programmers Reference Guide)
with should help you do most of these things.

Note: alot of these questions seem to require knowledge about the
compiler and action the compiler will take, SN knows nothing about
what the compiler is thinking.  But hopeful you should beadle to
get the information you need from the database.

> 1) Determine all class names which have a default constructor generated
> by the compiler.

Is this the same as "Determine all class name which don't have a
default constructor in the source code".

> 2) Determine all class names which have a default constructor generated
> by the compiler
>    and it is used.

> 3) Determine all class names which have a copy constructor generated by
> the compiler.
> 4) Determine all class names which have a copy constructor generated by
> the compiler
>    and it is used.

I don't really know enough about C++ to answer this.

> 5) Find all class names which use the macro
> USE_GENERATED_DEFAULT_CONSTRUCTOR

This should be relative easy.

> 6) Find all class names which use the macro
>    USE_GENERATED_DEFAULT_CONSTRUCTOR, and define a default constructor.
>    ( This would be some "AND" in terms of data base queries or a list
> intersection
>      for a C++ interface. )
>    (BY THE WAY, I would like to start putting EITHER
> USE_GENERATED_DEFAULT_CONSTRUCTOR or X()
>     but not both in every class X which I write so that my intentions
> are clear.)
> 7) Find all instances of 'bool operator==(unsigned int,int)' in the
> code.
>    (For example,  int main() {
>                     unsigned int a,b;
>                     int c;
>                     bool d = a==b;
>                     bool e = a==c;
>                     bool f = 0==1L;
>                     bool g = 0U==1;
>                     return 0;
>                   }
>                   would indicate the 'e' and 'g' lines.)

This could probably be done with a little hacking.
Maybe improving the C++ parser could help a little here.
 
> 8) Determine all locations where adding the keyword 'explicit' to a
>    constructor, say 'X(const Y &)', will create a compiler error.
>    (See http://www.calpoly.edu/~mstankus/mozilla )
> 9) Find all locations where adding the keyword 'explicit' to the code
>    wherever appropriate would generate compiler errors.
>    (See http://www.calpoly.edu/~mstankus/mozilla )
> 10) Determine when temporaries are created.

I'm not sure if SN handles the keyword 'explicit' (if it doesn't
choke it might just ignore it).

How can we determine when temporaries are created?
(by looking at the source code).

Ian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can I use SN to ask questions about C++?
  2000-09-24 12:19 Can I use SN to ask questions about C++? Mark Stankus
  2000-09-24 12:41 ` Ian Roxborough
@ 2000-09-27 21:38 ` Ben Elliston
  1 sibling, 0 replies; 4+ messages in thread
From: Ben Elliston @ 2000-09-27 21:38 UTC (permalink / raw)
  To: Mark Stankus; +Cc: sourcenav

Hi,

     I was wondering if there is an API for SN so that I could write
   small programs (or write data base queries) to ask questions about the
   C++ code which has been "SN-ed". The goal is to look for
   inefficiencies in C++ code and improve maintainability of C++ via
   computer programs.  The questions below are samples (requiring some
   SQL would be fine or, even better, a C++ interface).

There are some examples in the sdk/ subdirectory -- take a look at
`diamonds.tcl', for instance:

# Description:
# This Tcl tool can be used to locate multiple inheritence diamonds in C++
# class hierarchies.

I hope this helps.

Ben

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can I use SN to ask questions about C++?
  2000-09-24 12:41 ` Ian Roxborough
@ 2000-09-27 21:38   ` Ben Elliston
  0 siblings, 0 replies; 4+ messages in thread
From: Ben Elliston @ 2000-09-27 21:38 UTC (permalink / raw)
  To: Ian Roxborough; +Cc: Mark Stankus, sourcenav

   > 2) Determine all class names which have a default constructor
   generated > by the compiler > and it is used. > 3) Determine all class
   names which have a copy constructor generated by > the compiler. > 4)
   Determine all class names which have a copy constructor generated by >
   the compiler > and it is used.
   
   I don't really know enough about C++ to answer this.

It's quite straightforward: clases which lack a copy constructor will have
one generated by the compiler.  This shouldn't be too hard to do.

Ben

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-09-27 21:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-24 12:19 Can I use SN to ask questions about C++? Mark Stankus
2000-09-24 12:41 ` Ian Roxborough
2000-09-27 21:38   ` Ben Elliston
2000-09-27 21:38 ` Ben Elliston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).