forbid the use of std::endl on std::cerr

std::cerr will flush after each operator<< by default, so it's simpler
to use \n instead of std::endl, especially if we can merge \n into the
previous string.  Ideally we should prefer \n for std::cout as well,
but there are reasonable cases where we want to call std::endl there,
so it's hard to enforce.

* tests/sanity/style.test: Diagnose occurrences of cerr.*<<.*endl.
* bin/autcross.cc, bin/autfilt.cc, bin/ltlcross.cc, bin/ltlsynt.cc,
spot/tl/formula.cc, spot/twa/bdddict.cc, tests/core/checkpsl.cc,
tests/core/checkta.cc, tests/core/consterm.cc, tests/core/emptchk.cc,
tests/core/equalsf.cc, tests/core/ikwiad.cc, tests/core/kind.cc,
tests/core/length.cc, tests/core/ltlrel.cc, tests/core/parity.cc,
tests/core/randtgba.cc, tests/core/reduc.cc, tests/core/syntimpl.cc,
tests/ltsmin/modelcheck.cc: Fix them.
This commit is contained in:
Alexandre Duret-Lutz 2019-07-15 02:31:13 +02:00
parent b4cced9ba8
commit 09c93a3a3d
21 changed files with 148 additions and 170 deletions

View file

@ -1,6 +1,6 @@
#! /bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2009-2018 Laboratoire de Recherche et Développement de
# Copyright (C) 2009-2019 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
# Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6
# (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
@ -67,7 +67,6 @@ for dir in "$TOP/spot" "$TOP/bin" "$TOP/tests"; do
-a -not -path '*.dir/*' \
-a -type f -a -print |
while read file; do
if $GREP 'GNU Bison' "$file" >/dev/null ||
$GREP 'generated by flex' "$file" >/dev/null ; then
continue
@ -266,6 +265,9 @@ for dir in "$TOP/spot" "$TOP/bin" "$TOP/tests"; do
e$GREP '(->|[.])size\(\) [=!]= 0|![a-zA-Z0-9_]*(->|[.])size\(\)|(if |while |assert)\([a-zA-Z0-9_]*(->|[.])size\(\)\)' $tmp &&
diag 'Prefer empty() to check emptiness.'
$GREP -E 'std::cerr.*<<.*endl' $tmp &&
diag 'std::cerr has unitbuf set; use \\n instead of endl'
e$GREP 'assert\((0|!".*")\)' $tmp &&
diag 'Prefer SPOT_UNREACHABLE or SPOT_UNIMPLEMENTED.'