Add various widely useful "IWYU pragma" annotations, such as
- Common header files such as c.h, postgres.h should be "always_keep".
- System headers included in c.h, postgres.h etc. should be considered
"export".
- Some portability headers such as getopt_long.h should be
"always_keep", so they are not considered superfluous on some
platforms.
- Certain system headers included from portability headers should be
considered "export" because the purpose of the portability header is
to wrap them.
- Superfluous includes marked as "for backward compatibility" get a
formal IWYU annotation.
- Generated header included in utils/syscache.h is marked exported.
This is a very commonly used include and this avoids lots of
complaints.
Discussion: https://www.postgresql.org/message-id/flat/
9395d484-eff4-47c2-b276-
8e228526c8ae@eisentraut.org
*
*-------------------------------------------------------------------------
*/
+/* IWYU pragma: always_keep */
/*
*----------------------------------------------------------------
* TABLE OF CONTENTS
#ifndef C_H
#define C_H
+/* IWYU pragma: begin_exports */
+
/*
* These headers must be included before any system headers, because on some
* platforms they affect the behavior of the system headers (for example, by
/* /port compatibility functions */
#include "port.h"
+/* IWYU pragma: end_exports */
+
#endif /* C_H */
*
* src/include/getopt_long.h
*/
+/* IWYU pragma: always_keep */
#ifndef GETOPT_LONG_H
#define GETOPT_LONG_H
-#include "pg_getopt.h"
+#include "pg_getopt.h" /* IWYU pragma: export */
#ifndef HAVE_STRUCT_OPTION
*
* src/include/pg_getopt.h
*/
+/* IWYU pragma: always_keep */
#ifndef PG_GETOPT_H
#define PG_GETOPT_H
/* POSIX says getopt() is provided by unistd.h */
-#include <unistd.h>
+#include <unistd.h> /* IWYU pragma: export */
/* rely on the system's getopt.h if present */
#ifdef HAVE_GETOPT_H
-#include <getopt.h>
+#include <getopt.h> /* IWYU pragma: export */
#endif
/*
#ifndef PG_TRACE_H
#define PG_TRACE_H
-#include "utils/probes.h"
+#include "utils/probes.h" /* IWYU pragma: export */
#endif /* PG_TRACE_H */
#include "portability/instr_time.h"
#include "postmaster/pgarch.h" /* for MAX_XFN_CHARS */
#include "replication/conflict.h"
-#include "utils/backend_progress.h" /* for backward compatibility */
-#include "utils/backend_status.h" /* for backward compatibility */
+#include "utils/backend_progress.h" /* for backward compatibility */ /* IWYU pragma: export */
+#include "utils/backend_status.h" /* for backward compatibility */ /* IWYU pragma: export */
#include "utils/pgstat_kind.h"
#include "utils/relcache.h"
-#include "utils/wait_event.h" /* for backward compatibility */
+#include "utils/wait_event.h" /* for backward compatibility */ /* IWYU pragma: export */
/* ----------
#ifndef WIN32
#include <limits.h>
-#include <sys/uio.h>
+#include <sys/uio.h> /* IWYU pragma: export */
#include <unistd.h>
#else
#ifndef PG_PTHREAD_H
#define PG_PTHREAD_H
-#include <pthread.h>
+#include <pthread.h> /* IWYU pragma: export */
#ifndef HAVE_PTHREAD_BARRIER_WAIT
*
*-------------------------------------------------------------------------
*/
+/* IWYU pragma: always_keep */
/*
*----------------------------------------------------------------
* TABLE OF CONTENTS
#ifndef POSTGRES_H
#define POSTGRES_H
+/* IWYU pragma: begin_exports */
+
#include "c.h"
#include "utils/elog.h"
#include "utils/palloc.h"
+/* IWYU pragma: end_exports */
+
/* ----------------------------------------------------------------
* Section 1: Datum type + support functions
* ----------------------------------------------------------------
*
*-------------------------------------------------------------------------
*/
+/* IWYU pragma: always_keep */
#ifndef POSTGRES_EXT_H
#define POSTGRES_EXT_H
*
*-------------------------------------------------------------------------
*/
+/* IWYU pragma: always_keep */
#ifndef POSTGRES_FE_H
#define POSTGRES_FE_H
#define FRONTEND 1
#endif
+/* IWYU pragma: begin_exports */
+
#include "c.h"
#include "common/fe_memutils.h"
+/* IWYU pragma: end_exports */
+
#endif /* POSTGRES_FE_H */
#include "access/htup.h"
/* we intentionally do not include utils/catcache.h here */
-#include "catalog/syscache_ids.h"
+#include "catalog/syscache_ids.h" /* IWYU pragma: export */
extern void InitCatalogCache(void);
extern void InitCatalogCachePhase2(void);
#include "fe-auth-sasl.h"
#include "pqexpbuffer.h"
+/* IWYU pragma: begin_exports */
#ifdef ENABLE_GSS
#if defined(HAVE_GSSAPI_H)
#include <gssapi.h>
#include <gssapi/gssapi.h>
#endif
#endif
+/* IWYU pragma: end_exports */
#ifdef ENABLE_SSPI
#define SECURITY_WIN32