edk2/BaseTools/Source/Python/Ecc
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
..
CParser4 BaseTools: Ecc: Update to ANTLR 4.13.2 2026-04-08 22:23:35 +00:00
MetaFileWorkspace BaseTools: Ecc: Remove unnecessary code 2025-07-01 09:51:38 +08:00
Xml BaseTools: Ecc: Remove unnecessary code 2025-07-01 09:51:38 +08:00
__init__.py BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
c.py BaseTools: Fix MODEL_IDENTIFIER_MACRO_PROGMA typo 2026-06-26 02:18:38 +00:00
Check.py BaseTools/Ecc: Add check for traditional include guards 2026-06-26 02:18:38 +00:00
CodeFragment.py BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
CodeFragmentCollector.py BaseTools: Ecc: Update to ANTLR 4.13.2 2026-04-08 22:23:35 +00:00
config.ini BaseTools/Ecc: Add check for traditional include guards 2026-06-26 02:18:38 +00:00
Configuration.py BaseTools/Ecc: Add check for traditional include guards 2026-06-26 02:18:38 +00:00
Database.py BaseTools: Ecc: Remove unnecessary code 2025-07-01 09:51:38 +08:00
EccGlobalData.py BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
EccMain.py BaseTools: Clean up os.path.normcase and os.path.normpath usage 2025-01-09 07:25:45 +00:00
EccToolError.py BaseTools/Ecc: Add check for traditional include guards 2026-06-26 02:18:38 +00:00
Exception.py BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
exception.xml BaseTools: Ecc/exception: Added _ModuleEntryPoint into exception list 2021-02-01 10:01:02 -08:00
FileProfile.py BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00
MetaDataParser.py BaseTools/Ecc: Fix ECC check MetaFile Copyright information issue 2020-10-27 06:50:06 +00:00
ParserWarning.py BaseTools: Replace BSD License with BSD+Patent License 2019-04-09 09:10:20 -07:00