Skip to content

Fix LLVMTaintConfig struct-field tainting mapping all struct types#836

Open
fabianbs96 wants to merge 1 commit into
developmentfrom
f-Fix835
Open

Fix LLVMTaintConfig struct-field tainting mapping all struct types#836
fabianbs96 wants to merge 1 commit into
developmentfrom
f-Fix835

Conversation

@fabianbs96
Copy link
Copy Markdown
Member

Fix #835

)

The StructConfigMap-building loop incorrectly mapped every identified
LLVM struct type to the configured field name whenever any debug-info
struct type matched the configured scope. This caused fields of
unrelated struct types with the same name to be wrongly tainted.

Fix: build the map by walking debug-declare records on allocas and
correlating DICompositeType names with the alloca's allocated type,
avoiding any dependency on LLVM IR type naming conventions.

Performance: pre-build a StringMap (scope→name) so each alloca
lookup is O(1) instead of O(|Variables|); replace double
contains/at with a single find in the GEP check; add early-out
when Config.Variables is empty.

Boilerplate: extract forEachDbgDeclare and stripTypedefsToStruct
into LLVMIRToSrc (LLVM-version-specific includes confined to the
.cpp; header uses llvm::function_ref for a stable interface).

Regression test: DataMember_02_Json verifies that X::A GEPs are
sources while Y::A GEPs are not when only X is configured.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fabianbs96 fabianbs96 self-assigned this May 12, 2026
@fabianbs96 fabianbs96 added the bug Something isn't working label May 12, 2026
@fabianbs96 fabianbs96 marked this pull request as ready for review May 12, 2026 16:26
@fabianbs96 fabianbs96 requested a review from MMory as a code owner May 12, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revisit LLVMTaintConfig

1 participant