1 suggestion
Optional improvements
[suggestion] · Lint does not verify that the final #endif closes the include guard
The lint can accept content outside an early-closed guard when a later conditional supplies the expected final #endif; no current tracked header with this layout was identified.
Location: test/lint/lint-include-guards.py:80 (head).
Details and suggested fix
The first/second/last-line checks accept this balanced layout for src/example.h, even though the include is processed on every inclusion:
#ifndef BITCOIN_EXAMPLE_H
#define BITCOIN_EXAMPLE_H
#endif // BITCOIN_EXAMPLE_H
#include <cstdint>
#if 0
#endif // BITCOIN_EXAMPLE_H
The old regex counted four guard lines and rejected this variant, so accepting it is a narrow regression. Using a bare early #endif instead already escaped the old check. Track conditional depth while scanning, and reject a return to depth zero before the final line while retaining the existing boundary checks. Recognize whitespace after #, since existing headers such as src/compat/byteswap.h use directives like # if.