Fix RULE-5-10-1 false positives on compiler-predefined function identifiers - #1171
Open
castler wants to merge 1 commit into
Open
Fix RULE-5-10-1 false positives on compiler-predefined function identifiers#1171castler wants to merge 1 commit into
castler wants to merge 1 commit into
Conversation
castler
force-pushed
the
fix-rule-5-10-1-predefined-function-identifiers
branch
from
August 4, 2026 13:48
5ee9d5f to
8bcf85d
Compare
…ifiers RULE-5-10-1 (poorly-formed identifier) flagged the compiler-predefined function identifiers __func__, __FUNCTION__ and __PRETTY_FUNCTION__ for containing double underscores / leading underscores. These are not user-defined identifiers: __func__ is mandated by the C++ standard and __FUNCTION__/__PRETTY_FUNCTION__ are GCC/Clang extensions, synthesized once per enclosing function. They frequently surface via assert-style macros, producing one finding per macro invocation site (on this codebase, 228 findings, ~79% of the rule's results). The shared IdentifierIntroduction library already excludes `variable.isCompilerGenerated()`, but the extractor does not mark these predefined variables as compiler generated, so they leak through. Exclude them in VariableDeclarationEntryIdentifier using a name-independent structural signal: they are `static` local variables with no definition (their only declaration entry is located at a use site), whereas a genuine `static` local always has an in-source definition. This deliberately avoids hard-coding the names, so a user who really declares such an identifier (on a compiler that does not predefine it) still has a definition and is therefore still flagged. Add a regression test to RULE-5-10-1 covering __func__ and __PRETTY_FUNCTION__ (COMPLIANT). The false positive reproduces in the single-translation-unit test harness: without this fix the test fails with the four spurious findings; with it the test passes. The existing RULE-5-10-1 and Identifiers library tests continue to pass. Fixes github#1170
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
RULE-5-10-1 (poorly-formed identifier) flagged the compiler-predefined
function identifiers func, FUNCTION and PRETTY_FUNCTION for
containing double underscores / leading underscores. These are not
user-defined identifiers: func is mandated by the C++ standard and
FUNCTION/PRETTY_FUNCTION are GCC/Clang extensions, synthesized
once per enclosing function. They frequently surface via assert-style
macros, producing one finding per macro invocation site (on this
codebase, 228 findings, ~79% of the rule's results).
The shared IdentifierIntroduction library already excludes
variable.isCompilerGenerated(), but the extractor does not mark thesepredefined variables as compiler generated, so they leak through.
Exclude them in VariableDeclarationEntryIdentifier using a
name-independent structural signal: they are
staticlocal variableswith no definition (their only declaration entry is located at a use
site), whereas a genuine
staticlocal always has an in-sourcedefinition. This deliberately avoids hard-coding the names, so a user
who really declares such an identifier (on a compiler that does not
predefine it) still has a definition and is therefore still flagged.
Fixes #1170
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.