edk2/BaseTools/Source
Michael Kubacki 35b5565764 BaseTools/Ecc: Add check for traditional include guards
Adds a new ECC check, `IncludeFileCheckPragmaOnce` (error code 6006),
that flags header files using a traditional `#ifndef`/`#define`
include guard and recommends `#pragma once` instead.

A guard is detected when a '#ifndef NAME' is immediately followed by a
valueless '#define NAME' using the same macro name. Feature macros
such as '#define FOO 1' and files already using '#pragma once' are not
flagged.

The check reports against the parsed preprocessor directive rows in
the identifier tables rather than the File table. Those rows carry the
actual source line number, whereas File-level findings resolve to
"line 1" in the report. This gives an accurate line number, to the
EccCheck CI plugin, so it can reconcile findings with the changed line
ranges of a commit.

It uses the binary extension list and the exception list, consistent
with the other include file checks.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-06-26 02:18:38 +00:00
..
C BaseTools/GenFv: Parse ,XIP suffix for per-file rebase control 2026-06-22 15:18:12 +00:00
Python BaseTools/Ecc: Add check for traditional include guards 2026-06-26 02:18:38 +00:00