taskGNU Octave - Tasks: task #14501, Review #include declarations in...


You are not allowed to post comments on this tracker with your current authentication level.

task #14501: Review #include declarations in code base

Submitter:  Rik <rik5>
Submitted:  Tue 02 May 2017 05:11:17 PM UTC
Should Start On:  Tue 02 May 2017 07:00:00 AM UTC Should be Finished on:  Tue 01 Aug 2017 07:00:00 AM UTC
Category:  Wish Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Open Fixed Release:  None
Planned Release:  None

Thu 11 May 2017 06:22:12 PM UTC, comment #3: 

Unfortunately, it wasn't very automated.


1) make clean
2) make -j1
  2a) Use Ctrl+C to stop compilation after gnulib (first target in SUBDIRS) has been built
3) Run make, but substitute include-what-you-use for the actual C++ compiler

make -k -j1 V=1 CXX="/usr/bin/iwyu -std=c++11 -Xiwyu --check_also='*.h'" CPPFLAGS="-I/usr/lib/llvm-3.5/lib/clang/3.5.2/include" | &tee inc.log

4) Postprocess inc.log to extract the interesting bits.  I used this Perl script.

#!/usr/bin/perl -w -n

$do_print = /should add these lines:/ .. /^---$/;

print $_ if ($do_print);

5) Further postprocess the include list to remove the repeated elements.  I used this Perl script.

#!/usr/bin/perl -w -n

$in_config = /^\Qconfig.h should add these lines\E/ .. /^---$/;
$in_octconfig = /^\Qoctave-config.h should add these lines\E/ .. /^---$/;
$in_post = /^\Qoct-conf-post.h should add these lines\E/ .. /^---$/;

next if ($in_config || $in_octconfig || $in_post);

print $_;

As you can see, not that easy.

Rik <rik5>
Group administrator
Thu 11 May 2017 05:53:25 PM UTC, comment #2: 

Could you show how you generated that list?  Is it something that can be added as a Makefile target?

John W. Eaton <jwe>
Group administrator
Tue 09 May 2017 03:49:05 PM UTC, comment #1: 

I rationalized the #includes in the liboctave/numeric directory.  See this cset http://hg.savannah.gnu.org/hgweb/octave/rev/d691ed308237.

The new, reduced list of #includes for review is attached.

(file #40631)

Rik <rik5>
Group administrator
Tue 02 May 2017 05:11:17 PM UTC, original submission:  

I ran include-what-you-use on the Octave code base to get an idea of which declarations are unnecessary and where we are in fact missing declarations.

The tool is very much imperfect, but I can see there are some problems that could be corrected.  Unfortunately, this will require manual review of the results.  For instance, the tool completely misunderstands that config.h is always included and by extension oct-conf-post.h is also included.  The suggestion to remove config.h and add oct-conf-post.h should be ignored.

Because this is such a big job I am uploading the log file and asking that anyone who has free time tackle a few files.  Only by dividing up the work can it all get done.

For reference, the Octave coding guidelines are that the order of includes is


C standard lib headers

C++ standard lib headers

liboctave headers

other headers

Within each category the headers are alphabetized.

As an example, here is the list for libinterp/corefcn/__delaunayn__.cc

#if defined (HAVE_CONFIG_H)
#  include "config.h"

#include <cstdio>

#include <limits>
#include <string>

#include "Array.h"
#include "dMatrix.h"
#include "dRowVector.h"
#include "oct-locbuf.h"
#include "unwind-prot.h"

#include "defun-dld.h"
#include "error.h"
#include "errwarn.h"
#include "ovl.h"

Rik <rik5>
Group administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #40631:  include.list added by rik5 (2MiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-05-09 rik5 Attached File- Added include.list, #40631

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code