deadcode

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: GPL-2.0, GPL-2.0-only Imports: 9 Imported by: 0

Documentation

Overview

Package deadcode detects and filters cryptographic findings that fall inside C/C++ preprocessor dead code blocks (e.g., #if 0 ... #endif).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterReport

func FilterReport(report *entities.InterimReport, targetDir string) *entities.InterimReport

FilterReport removes cryptographic assets that fall entirely within preprocessor dead code regions (#if 0 blocks) in C/C++ files. Non-C/C++ files are passed through unchanged. If a source file cannot be read, its findings are kept (best-effort filtering). C/C++ files are processed concurrently using a bounded worker pool.

func IsInsideDeadRegion

func IsInsideDeadRegion(regions []Region, startLine, endLine int) bool

IsInsideDeadRegion checks whether a line range [startLine, endLine] falls entirely within any dead code region.

Types

type Region

type Region struct {
	StartLine int // line number of the #if 0 directive
	EndLine   int // line number of the matching #endif (or #else/#elif at depth 1)
}

Region represents a contiguous block of dead code delimited by preprocessor directives.

func FindDeadRegions

func FindDeadRegions(filePath string) ([]Region, error)

FindDeadRegions scans a C/C++ file and returns all preprocessor dead code regions. A dead region is a block of code inside a statically-false #if expression (e.g., #if 0) up to its matching #endif, #else, or #elif.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL