1 suggestion
Optional improvements
[suggestion] · Boundary check accepts misordered guard directives
The new span check can accept content outside a misordered guard; this is inherited permissiveness, and no current tracked header with that layout was found.
Location: test/lint/lint-include-guards.py:76 (head).
Details and suggested fix
guard_line_nums records only matching line numbers, and the count check does not establish which directives they represent. For example, #ifndef ID, followed by #endif // ID, then #include <x.h>, and finally #define ID supplies three matches with no content outside their first-to-last span. The lint therefore accepts the header even though the include is processed on every inclusion. Record each match's directive kind and require the order ifndef, define, endif // before using those positions as boundaries. This rejects the example while preserving the valid ordering in the three headers changed here.