Skip to content

Commit

Permalink
Configure include cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanoBilenchi committed May 31, 2024
1 parent 2b15216 commit 65b8f5e
Show file tree
Hide file tree
Showing 39 changed files with 125 additions and 53 deletions.
7 changes: 3 additions & 4 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
Checks: >
-*,
clang-analyzer-*,
-clang-analyzer-cplusplus-*,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
modernize-*,
-modernize-macro-to-enum,
-modernize-redundant-void-arg,
-modernize-use-trailing-return-type,
misc-header-include-cycle,
misc-include-cleaner,
performance-*,
portability-*
3 changes: 3 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
Diagnostics:
Suppress: unused-includes
4 changes: 3 additions & 1 deletion include/ubit.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#ifndef UBIT_H
#define UBIT_H

#include "ustd.h"
#include "uattrs.h"
#include "unumber.h"
#include "uutils.h"

/**
* References a specific bitmask type.
Expand Down
8 changes: 6 additions & 2 deletions include/uhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
#ifndef UHASH_H
#define UHASH_H

#include "uhash_func.h"
#include "ustd.h"
#include "ualloc.h"
#include "uhash_func.h" // IWYU pragma: export
#include "unumber.h"
#include "uutils.h"
#include <stdint.h>
#include <string.h>

// Types

Expand Down
1 change: 1 addition & 0 deletions include/uhash_builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define UHASH_BUILTIN_H

#include "uhash.h" // IWYU pragma: export
#include "unumber.h"
#include "ustring.h"

ULIB_BEGIN_DECLS
Expand Down
4 changes: 3 additions & 1 deletion include/uhash_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#ifndef UHASH_FUNC_H
#define UHASH_FUNC_H

#include "ustd.h"
#include "uattrs.h"
#include "unumber.h"
#include <stddef.h>

ULIB_BEGIN_DECLS

Expand Down
1 change: 0 additions & 1 deletion include/ulib.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "umeta.h"
#include "unumber.h"
#include "urand.h"
#include "ustd.h"
#include "ustrbuf.h"
#include "ustream.h"
#include "ustring.h"
Expand Down
32 changes: 0 additions & 32 deletions include/ustd.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/ustream.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#ifndef USTREAM_H
#define USTREAM_H

#include "ustd.h"
#include "ustrbuf.h"
#include "utime.h"
#include <stdio.h>

ULIB_BEGIN_DECLS

Expand Down
6 changes: 5 additions & 1 deletion include/ustring_raw.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
#ifndef USTRING_RAW_H
#define USTRING_RAW_H

#include "ustd.h"
#include "uattrs.h"
#include "unumber.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>

ULIB_BEGIN_DECLS

Expand Down
6 changes: 5 additions & 1 deletion include/utest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
#ifndef UTEST_H
#define UTEST_H

#include "ustd.h"
#include "uattrs.h"
#include "uutils.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

ULIB_BEGIN_DECLS

Expand Down
4 changes: 3 additions & 1 deletion include/uvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#ifndef UVEC_H
#define UVEC_H

#include "ualloc.h"
#include "unumber.h"
#include "urand.h" // IWYU pragma: keep, needed for urand_range
#include "ustd.h"
#include "uutils.h"

ULIB_BEGIN_DECLS

Expand Down
2 changes: 2 additions & 0 deletions src/uhash_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/

#include "uhash_builtin.h"
#include "unumber.h" // IWYU pragma: keep, required for ulib_equals
#include "ustring.h"

UHASH_IMPL(ulib_int, ulib_hash_int, ulib_equals)
UHASH_IMPL(ulib_uint, ulib_hash_int, ulib_equals)
Expand Down
1 change: 1 addition & 0 deletions src/umeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include "umeta.h"
#include "uversion.h"

#ifndef ULIB_VERSION_MAJOR
#define ULIB_VERSION_MAJOR 0
Expand Down
6 changes: 6 additions & 0 deletions src/urand.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
*/

#include "urand.h"
#include "ualloc.h"
#include "unumber.h"
#include "ustring.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

// NOLINTBEGIN(clang-analyzer-security.insecureAPI.rand)

Expand Down
12 changes: 12 additions & 0 deletions src/ustrbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
*/

#include "ustrbuf.h"
#include "ualloc.h"
#include "uattrs.h"
#include "unumber.h"
#include "ustring.h"
#include "ustring_raw.h"
#include "uutils.h"
#include "uvec_builtin.h"
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

uvec_ret ustrbuf_append_format(UStrBuf *buf, char const *format, ...) {
va_list args;
Expand Down
10 changes: 10 additions & 0 deletions src/ustream.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@
*/

#include "ustream.h"
#include "ualloc.h"
#include "uattrs.h"
#include "unumber.h"
#include "ustrbuf.h"
#include "ustring.h"
#include "ustring_raw.h"
#include "utime.h"
#include "uvec_builtin.h"
#include "uversion.h"
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>

typedef struct UStreamBuf {
size_t size;
Expand Down
8 changes: 8 additions & 0 deletions src/ustring.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
*/

#include "ustring.h"
#include "ualloc.h"
#include "uattrs.h"
#include "ulib_ret.h"
#include "unumber.h"
#include "ustrbuf.h"
#include "ustring_raw.h"
#include "uutils.h"
#include <limits.h>
#include <stdarg.h>
#include <string.h>

UString const ustring_null = p_ustring_init_small(0);
UString const ustring_empty = p_ustring_init_small(1);
Expand Down
5 changes: 5 additions & 0 deletions src/ustring_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
*/

#include "ustring_raw.h"
#include "ualloc.h"
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>

char *ulib_str_dup(char const *string, size_t length) {
char *buf = ulib_malloc(length + 1);
Expand Down
6 changes: 6 additions & 0 deletions src/utime.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
*/

#include "utime.h"
#include "uattrs.h"
#include "unumber.h"
#include "ustrbuf.h"
#include "ustream.h"
#include "ustring.h"
#include "uutils.h"
#include <stdlib.h>
#include <time.h>

#define NS_PER_NS (utime_ns)1
Expand Down
3 changes: 3 additions & 0 deletions src/uvec_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/

#include "uvec_builtin.h"
#include "ualloc.h"
#include "unumber.h"
#include "ustring.h"

UVEC_IMPL_IDENTIFIABLE(char)
UVEC_IMPL_IDENTIFIABLE(ulib_byte)
Expand Down
3 changes: 3 additions & 0 deletions src/uversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
*/

#include "uversion.h"
#include "ustrbuf.h"
#include "ustream.h"
#include "ustring.h"
#include <stddef.h>

int uversion_compare(UVersion lhs, UVersion rhs) {
if (lhs.major < rhs.major) return -1;
Expand Down
3 changes: 3 additions & 0 deletions test/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*/

#include "ulib.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SORT_SEED 31
#define SORT_COUNT_SMALL 16
Expand Down
1 change: 1 addition & 0 deletions test/tests/ubit_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "ubit.h"
#include "utest.h"
#include <stdint.h>

#define ubit_test_impl(N) \
bool ubit_test_##N(void) { \
Expand Down
2 changes: 1 addition & 1 deletion test/tests/ubit_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef UBIT_TESTS_H
#define UBIT_TESTS_H

#include "ustd.h"
#include <stdbool.h>

bool ubit_test_8(void);
bool ubit_test_16(void);
Expand Down
3 changes: 3 additions & 0 deletions test/tests/uhash_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
*/

#include "uhash.h"
#include "unumber.h"
#include "utest.h"
#include <stddef.h>
#include <stdint.h>

#define MAX_VAL 100

Expand Down
2 changes: 1 addition & 1 deletion test/tests/uhash_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef UHASH_TESTS_H
#define UHASH_TESTS_H

#include "ustd.h"
#include <stdbool.h>

bool uhash_test_memory(void);
bool uhash_test_base(void);
Expand Down
4 changes: 4 additions & 0 deletions test/tests/urand_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
*/

#include "urand_tests.h"
#include "unumber.h"
#include "urand.h"
#include "ustring.h"
#include "utest.h"
#include "uvec_builtin.h"
#include <stddef.h>
#include <string.h>

bool urand_int_test(void) {
urand_set_seed(12345);
Expand Down
2 changes: 1 addition & 1 deletion test/tests/urand_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef URAND_TESTS_H
#define URAND_TESTS_H

#include "ustd.h"
#include <stdbool.h>

bool urand_int_test(void);
bool urand_float_test(void);
Expand Down
4 changes: 4 additions & 0 deletions test/tests/ustream_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
*/

#include "ustream_tests.h"
#include "ualloc.h"
#include "ustream.h"
#include "utest.h"
#include <stddef.h>
#include <stdio.h>
#include <string.h>

#define USTREAM_INPUT_FILE "ustream_input.txt"
#define USTREAM_OUTPUT_FILE "ustream_output.txt"
Expand Down
2 changes: 1 addition & 1 deletion test/tests/ustream_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef USTREAM_TESTS_H
#define USTREAM_TESTS_H

#include "ustd.h"
#include <stdbool.h>

bool uistream_path_test(void);
bool uistream_buf_test(void);
Expand Down
7 changes: 7 additions & 0 deletions test/tests/ustring_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
*/

#include "ustring_tests.h"
#include "ualloc.h"
#include "ulib_ret.h"
#include "unumber.h"
#include "ustrbuf.h"
#include "ustring.h"
#include "ustring_raw.h"
#include "utest.h"
#include "uutils.h"
#include "uvec.h"
#include <stddef.h>

#define MAX_ASCII 127

Expand Down
Loading

0 comments on commit 65b8f5e

Please sign in to comment.