Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/common/src/mlib/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
#define _WIN32_WINNT 0x601
#endif
// Winsock must be included before windows.h
#include <winsock2.h>
#include <windows.h>
#include <winsock2.h> // IWYU pragma: export
#include <windows.h> // IWYU pragma: export
#endif

// POSIX headers
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h> // IWYU pragma: export
#include <fcntl.h> // IWYU pragma: export
#include <sys/types.h> // IWYU pragma: export
#endif

// clang-format on
Expand Down
5 changes: 3 additions & 2 deletions src/libbson/src/bson/bson-context-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
#ifndef BSON_CONTEXT_PRIVATE_H
#define BSON_CONTEXT_PRIVATE_H

#include <bson/bson-context.h> // IWYU pragma: export

#include <common-thread-private.h>
//

#include <bson/bson-context.h>
#include <common-thread-private.h>


BSON_BEGIN_DECLS
Expand Down
5 changes: 4 additions & 1 deletion src/libbson/src/bson/bson-error-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
#ifndef BSON_ERROR_PRIVATE_H
#define BSON_ERROR_PRIVATE_H

#include <bson/error.h>
#include <bson/error.h> // IWYU pragma: export

//

#include <bson/macros.h>


Expand Down
1 change: 1 addition & 0 deletions src/libbson/src/bson/bson-json-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef BSON_JSON_PRIVATE_H
#define BSON_JSON_PRIVATE_H

#include <bson/bson-json.h> // IWYU pragma: export

struct _bson_json_opts_t {
bson_json_mode_t mode;
Expand Down
3 changes: 3 additions & 0 deletions src/libbson/src/bson/bson-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#ifndef BSON_PRIVATE_H
#define BSON_PRIVATE_H

#include <bson/bson.h> // IWYU pragma: export
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest removing export, since I do not think bson-private.h is the direct private analog to bson.h.

(Aside: bson-private.h should probably be renamed to bson-types-private.h for consistency?)

Since bson-private.h defines the implementation types of bson_t, I would rather rename to bson_t-private.h.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Changed the component header to <bson/bson_t.h> and renamed it to bson_t-private.h accordingly.


//

#include <bson/bson-types.h>
#include <bson/macros.h>
Expand Down
4 changes: 4 additions & 0 deletions src/libbson/src/bson/bson-vector-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#ifndef BSON_VECTOR_PRIVATE_H
#define BSON_VECTOR_PRIVATE_H

#include <bson/bson-vector.h> // IWYU pragma: export

//

#include <bson/compat.h>
#include <bson/macros.h>

Expand Down
2 changes: 2 additions & 0 deletions src/libbson/src/bson/bson-vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#define BSON_VECTOR_H

#include <bson/bson-endian.h>
#include <bson/bson-types.h>
#include <bson/bson_t.h>
#include <bson/compat.h>
#include <bson/macros.h>

Expand Down
44 changes: 23 additions & 21 deletions src/libbson/src/bson/bson.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,29 @@

#define BSON_INSIDE

#include <bson/bson-bcon.h>
#include <bson/bson-clock.h>
#include <bson/bson-context.h>
#include <bson/bson-decimal128.h>
#include <bson/bson-iter.h>
#include <bson/bson-json.h>
#include <bson/bson-keys.h>
#include <bson/bson-oid.h>
#include <bson/bson-reader.h>
#include <bson/bson-string.h>
#include <bson/bson-types.h>
#include <bson/bson-utf8.h>
#include <bson/bson-value.h>
#include <bson/bson-vector.h>
#include <bson/bson-version-functions.h>
#include <bson/bson-writer.h>
#include <bson/compat.h>
#include <bson/config.h>
#include <bson/macros.h>
#include <bson/memory.h>
#include <bson/version.h>
#include <bson/bson-bcon.h> // IWYU pragma: export
#include <bson/bson-clock.h> // IWYU pragma: export
#include <bson/bson-context.h> // IWYU pragma: export
#include <bson/bson-decimal128.h> // IWYU pragma: export
#include <bson/bson-iter.h> // IWYU pragma: export
#include <bson/bson-json.h> // IWYU pragma: export
#include <bson/bson-keys.h> // IWYU pragma: export
#include <bson/bson-oid.h> // IWYU pragma: export
#include <bson/bson-reader.h> // IWYU pragma: export
#include <bson/bson-string.h> // IWYU pragma: export
#include <bson/bson-types.h> // IWYU pragma: export
#include <bson/bson-utf8.h> // IWYU pragma: export
#include <bson/bson-value.h> // IWYU pragma: export
#include <bson/bson-vector.h> // IWYU pragma: export
#include <bson/bson-version-functions.h> // IWYU pragma: export
#include <bson/bson-writer.h> // IWYU pragma: export
#include <bson/bson_t.h> // IWYU pragma: export
#include <bson/compat.h> // IWYU pragma: export
#include <bson/config.h> // IWYU pragma: export
#include <bson/error.h> // IWYU pragma: export
#include <bson/macros.h> // IWYU pragma: export
#include <bson/memory.h> // IWYU pragma: export
#include <bson/version.h> // IWYU pragma: export

#include <string.h>
#include <time.h>
Expand Down
33 changes: 17 additions & 16 deletions src/libbson/src/bson/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#endif
#endif

#include <bson/config.h>
#include <bson/macros.h>
#include <bson/config.h> // IWYU pragma: export
#include <bson/macros.h> // IWYU pragma: export


#ifdef BSON_OS_WIN32
Expand All @@ -42,36 +42,37 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <winsock2.h>
#include <winsock2.h> // IWYU pragma: export
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windows.h> // IWYU pragma: export
#undef WIN32_LEAN_AND_MEAN
#else
#include <windows.h>
#include <windows.h> // IWYU pragma: export
#endif
#include <direct.h>
#include <io.h>
#include <direct.h> // IWYU pragma: export
#include <io.h> // IWYU pragma: export
#endif


#ifdef BSON_OS_UNIX
#include <sys/time.h>
#include <unistd.h>
#include <sys/time.h> // IWYU pragma: export
#include <sys/types.h> // IWYU pragma: export
#include <unistd.h> // IWYU pragma: export
#endif


#include <bson/macros.h>

#include <fcntl.h>
#include <sys/stat.h>
#include <fcntl.h> // IWYU pragma: export
#include <sys/stat.h> // IWYU pragma: export

#include <ctype.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The various stdlib and system includes in bson-compat.h which are currently marked as "unused" by IWYU are left as-is (to avoid potentially breaking downstream users) and do not have the IWYU export pragma applied

To check: is that still true? I do not see any warnings from clangd. However, something may be different in my local environment. Removing other IWYU pragmas in this file (e.g. limits.h, stdbool.h) does not show unused include warnings as I would expect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because much of the contents of this file were to support old pre-C99 compatibility, and despite incremental removal of pre-C89 compat features, I do not think the include directives were cleaned up accordingly.

Applied the "keep" pragma to headers currently marked as unused.

#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <limits.h> // IWYU pragma: export
#include <stdarg.h> // IWYU pragma: export
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unneeded export pragma? Later code references va_copy:

#if !defined(va_copy) && defined(__va_copy)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a compatibility header, this header conditionally provides va_copy when <stdarg.h> does not. Therefore, this header transitively provides <stdarg.h>.

#include <stdbool.h> // IWYU pragma: export
#include <stdint.h> // IWYU pragma: export
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -81,7 +82,7 @@
BSON_BEGIN_DECLS

#if !defined(_MSC_VER) || (_MSC_VER >= 1800)
#include <inttypes.h>
#include <inttypes.h> // IWYU pragma: export
#endif
#ifdef _MSC_VER
#ifndef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/libbson/src/bson/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef BSON_MACROS_H
#define BSON_MACROS_H

#include <bson/config.h>
#include <bson/config.h> // IWYU pragma: export

#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 3 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-apm-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#ifndef MONGOC_APM_PRIVATE_H
#define MONGOC_APM_PRIVATE_H

#include <mongoc/mongoc-apm.h>
#include <mongoc/mongoc-apm.h> // IWYU pragma: export

//

#include <bson/bson.h>

Expand Down
4 changes: 4 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-bulk-operation-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#ifndef MONGOC_BULK_OPERATION_PRIVATE_H
#define MONGOC_BULK_OPERATION_PRIVATE_H

#include <mongoc/mongoc-bulk-operation.h> // IWYU pragma: export

//

#include <mongoc/mongoc-array-private.h>
#include <mongoc/mongoc-write-command-private.h>

Expand Down
5 changes: 4 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-change-stream-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
#ifndef MONGOC_CHANGE_STREAM_PRIVATE_H
#define MONGOC_CHANGE_STREAM_PRIVATE_H

#include <mongoc/mongoc-change-stream.h> // IWYU pragma: export

//

#include <mongoc/mongoc-opts-helpers-private.h>
#include <mongoc/mongoc-opts-private.h>

#include <mongoc/mongoc-change-stream.h>
#include <mongoc/mongoc-client-session.h>
#include <mongoc/mongoc-collection.h>
#include <mongoc/mongoc-cursor.h>
Expand Down
5 changes: 4 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-client-pool-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
#ifndef MONGOC_CLIENT_POOL_PRIVATE_H
#define MONGOC_CLIENT_POOL_PRIVATE_H

#include <mongoc/mongoc-client-pool.h> // IWYU pragma: export

//

#include <mongoc/mongoc-topology-private.h>

#include <mongoc/mongoc-client-pool.h>
#include <mongoc/mongoc-topology-description.h>

#include <bson/bson.h>
Expand Down
5 changes: 4 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-client-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
#ifndef MONGOC_CLIENT_PRIVATE_H
#define MONGOC_CLIENT_PRIVATE_H

#include <mongoc/mongoc-client.h> // IWYU pragma: export

//

#include <mongoc/mongoc-apm-private.h>
#include <mongoc/mongoc-buffer-private.h>
#include <mongoc/mongoc-cluster-private.h>
#include <mongoc/mongoc-rpc-private.h>

#include <mongoc/mongoc-client.h>
#include <mongoc/mongoc-config.h>
#include <mongoc/mongoc-host-list.h>
#include <mongoc/mongoc-opcode.h>
Expand Down
4 changes: 3 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-client-session-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#ifndef MONGOC_CLIENT_SESSION_PRIVATE_H
#define MONGOC_CLIENT_SESSION_PRIVATE_H

#include <mongoc/mongoc-client-session.h>
#include <mongoc/mongoc-client-session.h> // IWYU pragma: export

//

#include <bson/bson.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
#ifndef MONGOC_CLIENT_SIDE_ENCRYPTION_PRIVATE_H
#define MONGOC_CLIENT_SIDE_ENCRYPTION_PRIVATE_H

#include <mongoc/mongoc-client-side-encryption.h> // IWYU pragma: export

//

#include <mongoc/mongoc-cmd-private.h>
#include <mongoc/mongoc-topology-private.h>

#include <mongoc/mongoc-client-pool.h>
#include <mongoc/mongoc-client-side-encryption.h>
#include <mongoc/mongoc-client.h>

#include <bson/bson.h>
Expand Down
4 changes: 4 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-collection-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#ifndef MONGOC_COLLECTION_PRIVATE_H
#define MONGOC_COLLECTION_PRIVATE_H

#include <mongoc/mongoc-collection.h> // IWYU pragma: export

//

#include <mongoc/mongoc-client.h>

#include <bson/bson.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/src/mongoc/mongoc-crypto-cng-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <mongoc/mongoc-prelude.h>

#include <mongoc/mongoc-crypto-private.h>
#include <mongoc/mongoc-crypto-private.h> // IWYU pragma: export

#include <bson/bson.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#ifndef MONGOC_CRYPTO_COMMON_CRYPTO_PRIVATE_H
#define MONGOC_CRYPTO_COMMON_CRYPTO_PRIVATE_H

#include <mongoc/mongoc-crypt-private.h> // IWYU pragma: export

//

#include <mongoc/mongoc-config.h>

Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/src/mongoc/mongoc-crypto-openssl-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#ifndef MONGOC_CRYPTO_OPENSSL_PRIVATE_H
#define MONGOC_CRYPTO_OPENSSL_PRIVATE_H

#include <mongoc/mongoc-crypto-private.h>
#include <mongoc/mongoc-crypto-private.h> // IWYU pragma: export

BSON_BEGIN_DECLS

Expand Down
4 changes: 4 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-cursor-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#ifndef MONGOC_CURSOR_PRIVATE_H
#define MONGOC_CURSOR_PRIVATE_H

#include <mongoc/mongoc-cursor.h> // IWYU pragma: export

//

#include <mongoc/mongoc-buffer-private.h>
#include <mongoc/mongoc-cluster-private.h>
#include <mongoc/mongoc-rpc-private.h>
Expand Down
4 changes: 4 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-database-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#ifndef MONGOC_DATABASE_PRIVATE_H
#define MONGOC_DATABASE_PRIVATE_H

#include <mongoc/mongoc-database.h> // IWYU pragma: export

//

#include <mongoc/mongoc-client.h>
#include <mongoc/mongoc-read-concern.h>
#include <mongoc/mongoc-read-prefs.h>
Expand Down
3 changes: 2 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-errno-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

#include <bson/bson.h>

#include <errno.h>
#include <errno.h> // IWYU pragma: export

#ifdef _WIN32
#include <winerror.h>
#include <winsock2.h>
Expand Down
5 changes: 4 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-error-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
#ifndef MONGOC_ERROR_PRIVATE_H
#define MONGOC_ERROR_PRIVATE_H

#include <mongoc/mongoc-error.h>
#include <mongoc/mongoc-error.h> // IWYU pragma: export

//

#include <mongoc/mongoc-server-description.h>

#include <bson/bson.h>
Expand Down
Loading