Here is a patch series with some significant reworking and adjusting of
how the coverage analysis tools are run.  The result should be that the
"make coverage" runs are faster and more robust, the results are more
accurate, and the code is simpler.  Please see the individual patches
for details.

I have replaced "make coverage-html" with "make coverage" (but kept the
previous name for compatibility), since the old meaning of the latter
has gone away and was never very useful.  Other than that, the usage of
everything stays the same.

I will add it to the commit fest.  Testing with different versions of
tools would be especially valuable.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 3c8a2c6afb3a8873a70c61c427128bb4d1cade2b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 1/9] Run only top-level recursive lcov

This is the way lcov was intended to be used.  It is much faster and
more robust and makes the makefiles simpler than running it in each
subdirectory.

This also removes the direct gcov calls and lets lcov do it instead.
The direct gcov calls are useless because lcov/geninfo call gcov
internally and use that information.
---
 .gitignore                |  3 +--
 GNUmakefile.in            |  2 +-
 doc/src/sgml/regress.sgml |  2 +-
 src/Makefile.global.in    | 33 +++++++++++----------------------
 4 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4976fd9119..2052f719d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,10 +19,9 @@ objfiles.txt
 .deps/
 *.gcno
 *.gcda
-*.gcov
-*.gcov.out
 lcov.info
 coverage/
+coverage-stamp
 *.vcproj
 *.vcxproj
 win32ver.rc
diff --git a/GNUmakefile.in b/GNUmakefile.in
index dc76a5d11d..8d77b01eea 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -41,7 +41,7 @@ install-world-contrib-recurse: install-world-src-recurse
 
 $(call recurse,installdirs uninstall init-po update-po,doc src config)
 
-$(call recurse,distprep coverage,doc src config contrib)
+$(call recurse,distprep,doc src config contrib)
 
 # clean, distclean, etc should apply to contrib too, even though
 # it's not built by default
diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml
index 7c2b1029c2..796cdc26ff 100644
--- a/doc/src/sgml/regress.sgml
+++ b/doc/src/sgml/regress.sgml
@@ -699,7 +699,7 @@ <title>Test Coverage Examination</title>
 ./configure --enable-coverage ... OTHER OPTIONS ...
 make
 make check # or other test suite
-make coverage-html
+make coverage
 </screen>
     Then point your HTML browser
     to <filename>coverage/index.html</filename>.
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 0d3f8ca950..b01e578238 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -19,7 +19,7 @@
 #
 # Meta configuration
 
-standard_targets = all install installdirs uninstall distprep clean distclean 
maintainer-clean coverage check installcheck init-po update-po
+standard_targets = all install installdirs uninstall distprep clean distclean 
maintainer-clean check installcheck init-po update-po
 # these targets should recurse even into subdirectories not being built:
 standard_always_targets = distprep clean distclean maintainer-clean
 
@@ -863,34 +863,23 @@ endif # enable_nls
 #              (by gcc -ftest-coverage)
 #   foo.gcda   gcov data file, created when the program is run (for
 #              programs compiled with gcc -fprofile-arcs)
-#   foo.c.gcov gcov output file with coverage information, created by
-#              gcov from foo.gcda (by "make coverage")
-#   foo.c.gcov.out  stdout captured when foo.c.gcov is created, mildly
-#              interesting
 #   lcov.info  lcov tracefile, built from gcda files in one directory,
 #              later collected by "make coverage-html"
 
 ifeq ($(enable_coverage), yes)
 
-# There is a strange interaction between lcov and existing .gcov
-# output files.  Hence the rm command and the ordering dependency.
-
-gcda_files := $(wildcard *.gcda)
+gcda_files = $(shell find . -name '*.gcda' -print)
 
 lcov.info: $(gcda_files)
-       rm -f *.gcov
-       $(if $^,$(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV))
-
-%.c.gcov: %.gcda | lcov.info
-       $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
-
-coverage: $(gcda_files:.gcda=.c.gcov) lcov.info
+       $(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV)
 
-.PHONY: coverage-html
-coverage-html: coverage
+coverage-stamp: lcov.info
        rm -rf coverage
-       mkdir coverage
-       $(GENHTML) --show-details --legend --output-directory=coverage 
--title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) `find . -name 
lcov.info -print`
+       $(GENHTML) --show-details --legend --output-directory=coverage 
--title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) $<
+       touch $@
+
+.PHONY: coverage coverage-html
+coverage coverage-html: coverage-stamp
 
 
 # hook for clean-up
@@ -898,8 +887,8 @@ clean distclean maintainer-clean: clean-coverage
 
 .PHONY: clean-coverage
 clean-coverage:
-       rm -rf coverage
-       rm -f *.gcda *.gcno lcov.info *.gcov *.gcov.out
+       rm -rf coverage/ coverage-stamp
+       rm -f *.gcda *.gcno lcov.info
 
 
 # User-callable target to reset counts between test runs

base-commit: 8d6442377df5451a8db598788847e6a70b3b49ef
-- 
2.14.0

From 6f8b86db57e395712fcf3789a337c0e5b8f22e05 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 2/9] Have lcov exclude external files

Call lcov with --no-external option to exclude external files (for
example, system headers with inline functions) from output.
---
 src/Makefile.global.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index b01e578238..9e162c40f0 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -871,7 +871,7 @@ ifeq ($(enable_coverage), yes)
 gcda_files = $(shell find . -name '*.gcda' -print)
 
 lcov.info: $(gcda_files)
-       $(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV)
+       $(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV) --no-external
 
 coverage-stamp: lcov.info
        rm -rf coverage
-- 
2.14.0

From 23b05ddceceabfcbb006a4df912dda613ee96dfc Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 3/9] Add lcov --initial

By just running lcov on the produced .gcda data files, we don't account
for source files that are not touched by tests at all.  To fix that, run
lcov --initial to create a base line info file with all zero counters,
and merge that with the actual counters when creating the final report.
---
 .gitignore             |  2 +-
 src/Makefile.global.in | 25 +++++++++++++++++++------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index 2052f719d1..de6365cb4f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,7 +19,7 @@ objfiles.txt
 .deps/
 *.gcno
 *.gcda
-lcov.info
+lcov*.info
 coverage/
 coverage-stamp
 *.vcproj
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 9e162c40f0..70e92ee800 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -863,19 +863,32 @@ endif # enable_nls
 #              (by gcc -ftest-coverage)
 #   foo.gcda   gcov data file, created when the program is run (for
 #              programs compiled with gcc -fprofile-arcs)
-#   lcov.info  lcov tracefile, built from gcda files in one directory,
+#   lcov_test.info
+#              lcov tracefile, built from gcda files in one directory,
 #              later collected by "make coverage-html"
+#   lcov_base.info
+#              tracefile for zero counters for every file, so that
+#              even files that are not touched by tests are counted
+#              for the overall coverage rate
 
 ifeq ($(enable_coverage), yes)
 
+LCOV += --gcov-tool $(GCOV)
+LCOVFLAGS = --no-external
+
+gcno_files = $(shell find . -name '*.gcno' -print)
+
+lcov_base.info: $(gcno_files)
+       $(LCOV) $(LCOVFLAGS) -c -i -d . -o $@
+
 gcda_files = $(shell find . -name '*.gcda' -print)
 
-lcov.info: $(gcda_files)
-       $(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV) --no-external
+lcov_test.info: $(gcda_files)
+       $(LCOV) $(LCOVFLAGS) -c -d . -o $@
 
-coverage-stamp: lcov.info
+coverage-stamp: lcov_base.info lcov_test.info
        rm -rf coverage
-       $(GENHTML) --show-details --legend --output-directory=coverage 
--title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) $<
+       $(GENHTML) --show-details --legend --output-directory=coverage 
--title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) $^
        touch $@
 
 .PHONY: coverage coverage-html
@@ -888,7 +901,7 @@ clean distclean maintainer-clean: clean-coverage
 .PHONY: clean-coverage
 clean-coverage:
        rm -rf coverage/ coverage-stamp
-       rm -f *.gcda *.gcno lcov.info
+       rm -f *.gcda *.gcno lcov*.info
 
 
 # User-callable target to reset counts between test runs
-- 
2.14.0

From 8596718d2ecdabafe351aa8a7076fec39f6fcd2c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 4/9] Add PostgreSQL version to coverage output

Also make overriding the title easier.  That helps telling where the
report came from and labeling different variants of a report.
---
 src/Makefile.global.in | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 70e92ee800..554e72b8ee 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -875,6 +875,8 @@ ifeq ($(enable_coverage), yes)
 
 LCOV += --gcov-tool $(GCOV)
 LCOVFLAGS = --no-external
+GENHTML_FLAGS = --show-details --legend
+GENHTML_TITLE = PostgreSQL $(VERSION)
 
 gcno_files = $(shell find . -name '*.gcno' -print)
 
@@ -888,7 +890,7 @@ lcov_test.info: $(gcda_files)
 
 coverage-stamp: lcov_base.info lcov_test.info
        rm -rf coverage
-       $(GENHTML) --show-details --legend --output-directory=coverage 
--title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) $^
+       $(GENHTML) $(GENHTML_FLAGS) -o coverage --title='$(GENHTML_TITLE)' 
--num-spaces=4 --prefix='$(abs_top_srcdir)' $^
        touch $@
 
 .PHONY: coverage coverage-html
-- 
2.14.0

From 3a254dbba98609701409ee30db2c51437d833a5f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 5/9] Remove coverage details view

This is only useful if we name the different tests, which we don't do at
the moment.
---
 src/Makefile.global.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 554e72b8ee..e865aedfb6 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -875,7 +875,7 @@ ifeq ($(enable_coverage), yes)
 
 LCOV += --gcov-tool $(GCOV)
 LCOVFLAGS = --no-external
-GENHTML_FLAGS = --show-details --legend
+GENHTML_FLAGS = --legend
 GENHTML_TITLE = PostgreSQL $(VERSION)
 
 gcno_files = $(shell find . -name '*.gcno' -print)
-- 
2.14.0

From 4da5bd0597eb90aa5fb383b7528144a30c9b92fd Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 6/9] Run coverage commands quietly

They are very chatty by default, but the output doesn't seem all that
useful for normal operation.
---
 src/Makefile.global.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index e865aedfb6..f40b1db0cd 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -874,8 +874,8 @@ endif # enable_nls
 ifeq ($(enable_coverage), yes)
 
 LCOV += --gcov-tool $(GCOV)
-LCOVFLAGS = --no-external
-GENHTML_FLAGS = --legend
+LCOVFLAGS = -q --no-external
+GENHTML_FLAGS = -q --legend
 GENHTML_TITLE = PostgreSQL $(VERSION)
 
 gcno_files = $(shell find . -name '*.gcno' -print)
-- 
2.14.0

From 51a957805710244928c47877d54ff828bdba70ea Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 7/9] Improve vpath support in plperl build

Run xsubpp with the -output option instead of redirecting stdout.  That
ensures that the #line directives in the output file point to the right
place in a vpath build.  This in turn fixes an error in coverage builds
that it can't find the source files.

Refactor the makefile rules while we're here.
---
 src/pl/plperl/GNUmakefile | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index 191f74067a..66a2c3d4c9 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -81,13 +81,9 @@ perlchunks.h: $(PERLCHUNKS)
 
 all: all-lib
 
-SPI.c: SPI.xs plperl_helpers.h
+%.c: %.xs
        @if [ x"$(perl_privlibexp)" = x"" ]; then echo "configure switch 
--with-perl was not specified."; exit 1; fi
-       $(PERL) $(XSUBPPDIR)/ExtUtils/xsubpp -typemap 
$(perl_privlibexp)/ExtUtils/typemap $< >$@
-
-Util.c: Util.xs plperl_helpers.h
-       @if [ x"$(perl_privlibexp)" = x"" ]; then echo "configure switch 
--with-perl was not specified."; exit 1; fi
-       $(PERL) $(XSUBPPDIR)/ExtUtils/xsubpp -typemap 
$(perl_privlibexp)/ExtUtils/typemap $< >$@
+       $(PERL) $(XSUBPPDIR)/ExtUtils/xsubpp -typemap 
$(perl_privlibexp)/ExtUtils/typemap -output $@ $<
 
 
 install: all install-lib install-data
-- 
2.14.0

From ab0151123c233a670b88013363e3a36483364912 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 8/9] Support coverage on vpath builds

A few paths needed to be tweaked so everything looks into the
appropriate directories.
---
 src/Makefile.global.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index f40b1db0cd..54ea92bbfb 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -881,16 +881,16 @@ GENHTML_TITLE = PostgreSQL $(VERSION)
 gcno_files = $(shell find . -name '*.gcno' -print)
 
 lcov_base.info: $(gcno_files)
-       $(LCOV) $(LCOVFLAGS) -c -i -d . -o $@
+       $(LCOV) $(LCOVFLAGS) -c -i -d . -d $(srcdir) -o $@
 
 gcda_files = $(shell find . -name '*.gcda' -print)
 
 lcov_test.info: $(gcda_files)
-       $(LCOV) $(LCOVFLAGS) -c -d . -o $@
+       $(LCOV) $(LCOVFLAGS) -c -d . -d $(srcdir) -o $@
 
 coverage-stamp: lcov_base.info lcov_test.info
        rm -rf coverage
-       $(GENHTML) $(GENHTML_FLAGS) -o coverage --title='$(GENHTML_TITLE)' 
--num-spaces=4 --prefix='$(abs_top_srcdir)' $^
+       $(GENHTML) $(GENHTML_FLAGS) -o coverage --title='$(GENHTML_TITLE)' 
--num-spaces=4 $^
        touch $@
 
 .PHONY: coverage coverage-html
-- 
2.14.0

From ddd4f65ddcbe26c442d792d553ff46b93524c8d3 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Thu, 10 Aug 2017 23:33:47 -0400
Subject: [PATCH 9/9] Exclude flex-generated code from coverage testing

Flex generates a lot of functions that are not actually used.  In order
to avoid coverage figures being ruined by that, mark up the part of the
.l files where the generated code appears by lcov exclusion markers.
That way, lcov will typically only reported on coverage for the .l file,
which is under our control, but not for the .c file.
---
 contrib/cube/cubescan.l                   | 4 ++++
 contrib/seg/segscan.l                     | 4 ++++
 src/backend/bootstrap/bootscanner.l       | 3 +++
 src/backend/parser/scan.l                 | 5 +++++
 src/backend/replication/repl_scanner.l    | 3 +++
 src/backend/replication/syncrep_scanner.l | 3 +++
 src/backend/utils/misc/guc-file.l         | 4 +++-
 src/bin/pgbench/exprscan.l                | 4 ++++
 src/bin/psql/psqlscanslash.l              | 4 ++++
 src/fe_utils/psqlscan.l                   | 4 ++++
 src/interfaces/ecpg/preproc/pgc.l         | 6 ++++++
 src/test/isolation/specscanner.l          | 4 ++++
 12 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/contrib/cube/cubescan.l b/contrib/cube/cubescan.l
index dada917820..bd400e3684 100644
--- a/contrib/cube/cubescan.l
+++ b/contrib/cube/cubescan.l
@@ -4,6 +4,8 @@
  * contrib/cube/cubescan.l
  */
 
+/* LCOV_EXCL_START */
+
 /* No reason to constrain amount of data slurped */
 #define YY_READ_BUF_SIZE 16777216
 
@@ -56,6 +58,8 @@ NaN          [nN][aA][nN]
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 /* result is not used, but Bison expects this signature */
 void
 yyerror(NDBOX **result, const char *message)
diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l
index 6db24fdd1f..5f6595e9eb 100644
--- a/contrib/seg/segscan.l
+++ b/contrib/seg/segscan.l
@@ -3,6 +3,8 @@
  * A scanner for EMP-style numeric ranges
  */
 
+/* LCOV_EXCL_START */
+
 /* No reason to constrain amount of data slurped */
 #define YY_READ_BUF_SIZE 16777216
 
@@ -51,6 +53,8 @@ float        ({integer}|{real})([eE]{integer})?
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 void
 yyerror(SEG *result, const char *message)
 {
diff --git a/src/backend/bootstrap/bootscanner.l 
b/src/backend/bootstrap/bootscanner.l
index 6467882fa3..4fd23f932c 100644
--- a/src/backend/bootstrap/bootscanner.l
+++ b/src/backend/bootstrap/bootscanner.l
@@ -38,6 +38,7 @@
 /* Not needed now that this file is compiled as part of bootparse. */
 /* #include "bootparse.h" */
 
+/* LCOV_EXCL_START */
 
 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
 #undef fprintf
@@ -134,6 +135,8 @@ insert                      { return(INSERT_TUPLE); }
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 void
 yyerror(const char *message)
 {
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index 634bfa512f..6af2199cdc 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -41,6 +41,9 @@
 }
 
 %{
+
+/* LCOV_EXCL_START */
+
 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
 #undef fprintf
 #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
@@ -1011,6 +1014,8 @@ other                     .
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 /*
  * Arrange access to yyextra for subroutines of the main yylex() function.
  * We expect each subroutine to have a yyscanner parameter.  Rather than
diff --git a/src/backend/replication/repl_scanner.l 
b/src/backend/replication/repl_scanner.l
index 52ae7b343f..9c2f5fdd65 100644
--- a/src/backend/replication/repl_scanner.l
+++ b/src/backend/replication/repl_scanner.l
@@ -38,6 +38,8 @@ static char *litbufdup(void);
 static void addlit(char *ytext, int yleng);
 static void addlitchar(unsigned char ychar);
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -185,6 +187,7 @@ USE_SNAPSHOT                { return K_USE_SNAPSHOT; }
                                }
 %%
 
+/* LCOV_EXCL_STOP */
 
 static void
 startlit(void)
diff --git a/src/backend/replication/syncrep_scanner.l 
b/src/backend/replication/syncrep_scanner.l
index d1d1b26a48..1fbc936aa6 100644
--- a/src/backend/replication/syncrep_scanner.l
+++ b/src/backend/replication/syncrep_scanner.l
@@ -32,6 +32,8 @@ static YY_BUFFER_STATE scanbufhandle;
 
 static StringInfoData xdbuf;
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -112,6 +114,7 @@ xdinside            [^"]+
 .                      { return JUNK; }
 %%
 
+/* LCOV_EXCL_STOP */
 
 /* Needs to be here for access to yytext */
 void
diff --git a/src/backend/utils/misc/guc-file.l 
b/src/backend/utils/misc/guc-file.l
index f01b814c6e..3de8e791f2 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -57,6 +57,8 @@ static void record_config_file_error(const char *errmsg,
 static int     GUC_flex_fatal(const char *msg);
 static char *GUC_scanstr(const char *s);
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -107,7 +109,7 @@ STRING                      \'([^'\\\n]|\\.|\'\')*\'
 
 %%
 
-
+/* LCOV_EXCL_STOP */
 
 /*
  * Exported function to read and process the configuration file. The
diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l
index dc1367bbdb..15cedd3c9d 100644
--- a/src/bin/pgbench/exprscan.l
+++ b/src/bin/pgbench/exprscan.l
@@ -43,6 +43,8 @@ static bool last_was_newline = false;
 extern int     expr_yyget_column(yyscan_t yyscanner);
 extern void expr_yyset_column(int column_no, yyscan_t yyscanner);
 
+/* LCOV_EXCL_START */
+
 %}
 
 /* Except for the prefix, these options should match psqlscan.l */
@@ -190,6 +192,8 @@ continuation        \\{newline}
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 void
 expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more)
 {
diff --git a/src/bin/psql/psqlscanslash.l b/src/bin/psql/psqlscanslash.l
index db7a1b9eea..080dc37a2f 100644
--- a/src/bin/psql/psqlscanslash.l
+++ b/src/bin/psql/psqlscanslash.l
@@ -67,6 +67,8 @@ static void evaluate_backtick(PsqlScanState state);
 extern int     slash_yyget_column(yyscan_t yyscanner);
 extern void slash_yyset_column(int column_no, yyscan_t yyscanner);
 
+/* LCOV_EXCL_START */
+
 %}
 
 /* Except for the prefix, these options should match psqlscan.l */
@@ -450,6 +452,8 @@ other                       .
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 /*
  * Scan the command name of a psql backslash command.  This should be called
  * after psql_scan() returns PSCAN_BACKSLASH.  It is assumed that the input
diff --git a/src/fe_utils/psqlscan.l b/src/fe_utils/psqlscan.l
index 27689d72da..205756a2fe 100644
--- a/src/fe_utils/psqlscan.l
+++ b/src/fe_utils/psqlscan.l
@@ -71,6 +71,8 @@ typedef int YYSTYPE;
 extern int     psql_yyget_column(yyscan_t yyscanner);
 extern void psql_yyset_column(int column_no, yyscan_t yyscanner);
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option reentrant
@@ -884,6 +886,8 @@ other                       .
 
 %%
 
+/* LCOV_EXCL_STOP */
+
 /*
  * Create a lexer working state struct.
  *
diff --git a/src/interfaces/ecpg/preproc/pgc.l 
b/src/interfaces/ecpg/preproc/pgc.l
index 7b2bfdccc9..8602748faa 100644
--- a/src/interfaces/ecpg/preproc/pgc.l
+++ b/src/interfaces/ecpg/preproc/pgc.l
@@ -79,6 +79,8 @@ static struct _if_value
        short else_branch;
 } stacked_if_value[MAX_NESTED_IF];
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -1249,7 +1251,11 @@ cppline                  
{space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
                                        }
                                }
 <INITIAL>{other}|\n    { mmfatal(PARSE_ERROR, "internal error: unreachable 
state; please report this to <pgsql-b...@postgresql.org>"); }
+
 %%
+
+/* LCOV_EXCL_STOP */
+
 void
 lex_init(void)
 {
diff --git a/src/test/isolation/specscanner.l b/src/test/isolation/specscanner.l
index aed9269c63..7c571bc101 100644
--- a/src/test/isolation/specscanner.l
+++ b/src/test/isolation/specscanner.l
@@ -17,6 +17,8 @@ static int litbufpos = 0;
 
 static void addlitchar(char c);
 
+/* LCOV_EXCL_START */
+
 %}
 
 %option 8bit
@@ -93,6 +95,8 @@ teardown              { return(TEARDOWN); }
                                }
 %%
 
+/* LCOV_EXCL_STOP */
+
 static void
 addlitchar(char c)
 {
-- 
2.14.0

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to