Skip to content

Commit

Permalink
tree wide: add IWYU pragma: export where needed
Browse files Browse the repository at this point in the history
We occasionally have some public `foo.h` header that includes a private
`foo_arch.h` header. Users are expected to include the `foo.h` header
and not the `foo_arch.h`. However, clangd will claim that the `#include`
of `foo.h` is unused if only functions / macros/ types / ... from
`foor_arch.h` is used and nothing from `foo.h`.

This adds the `IWYU pragma: export` comment to the include of
`foo_arch.h` in `foo.h`, so that clangd treats functions / macros /
types provided by `foo_arch.h` as if they were instead provided by
`foo.h`, which fixes the false positives.
  • Loading branch information
maribu committed Apr 14, 2024
1 parent 3cdc437 commit cf6fa4e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/include/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
#include "thread_flags.h"
#endif

#include "thread_arch.h"
#include "thread_arch.h" /* IWYU pragma: export */

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/include/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ MAYBE_INLINE bool irq_is_enabled(void);
MAYBE_INLINE bool irq_is_in(void);

#else
#include "irq_arch.h"
#include "irq_arch.h" /* IWYU pragma: export */
#endif /* IRQ_API_INLINED */

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion drivers/include/periph/gpio_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ static inline void gpio_ll_switch_dir_input(gpio_port_t port, uword_t inputs)

/* the hardware specific implementation relies on the types such as gpio_port_t
* to be provided */
#include "gpio_ll_arch.h"
#include "gpio_ll_arch.h" /* IWYU pragma: export */

#endif /* PERIPH_GPIO_LL_H */
/** @} */
2 changes: 1 addition & 1 deletion drivers/include/periph/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ bool timer_poll_channel(tim_t dev, int channel);
#endif

#if defined(MODULE_PERIPH_TIMER_POLL)
#include "timer_arch.h"
#include "timer_arch.h" /* IWYU pragma: export */
#endif

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion sys/include/architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <inttypes.h>
#include <limits.h>

#include "architecture_arch.h"
#include "architecture_arch.h" /* IWYU pragma: export */

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion sys/include/atomic_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
#include "macros/utils.h"
#include "sched.h"

#include "atomic_utils_arch.h"
#include "atomic_utils_arch.h" /* IWYU pragma: export */

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion sys/include/flash_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include "kernel_defines.h"

#if IS_ACTIVE(HAS_FLASH_UTILS_ARCH)
#include "flash_utils_arch.h"
#include "flash_utils_arch.h" /* IWYU pragma: export */
#endif

#ifdef __cplusplus
Expand Down

0 comments on commit cf6fa4e

Please sign in to comment.