Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

C/C++: Disable constant folding of address-vs-null comparisons#21258

Open
IdrissRio wants to merge 4 commits intomainfrom
idrissrio/cpp/edg/unfolding
Open

C/C++: Disable constant folding of address-vs-null comparisons#21258
IdrissRio wants to merge 4 commits intomainfrom
idrissrio/cpp/edg/unfolding

Conversation

@IdrissRio
Copy link
Contributor

@IdrissRioIdrissRio commentedFeb 3, 2026
edited
Loading

The EDG frontend constant-folds address-vs-null comparisons (e.g.,&var == NULL) cause the IR to lose theVariableAddressInstruction.

This PR adds acontainsAddressOf predicate used inisIRConstant so these expressions are expanded instead of collapsed.

@IdrissRioIdrissRioforce-pushed theidrissrio/cpp/edg/unfolding branch 3 times, most recently from15ff5d6 toa7c6736CompareFebruary 4, 2026 08:42
@IdrissRioIdrissRioforce-pushed theidrissrio/cpp/edg/unfolding branch froma7c6736 to8cfa0a3CompareFebruary 4, 2026 09:16
@IdrissRioIdrissRio added the no-change-note-requiredThis PR does not need a change note labelFeb 4, 2026
@IdrissRioIdrissRio marked this pull request as ready for reviewFebruary 6, 2026 14:46
@IdrissRioIdrissRio requested a review froma team as acode ownerFebruary 6, 2026 14:46
CopilotAI review requested due to automatic review settingsFebruary 6, 2026 14:46
Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

This PR addresses an issue where the EDG frontend constant-folds address-vs-null comparisons (e.g.,&var == NULL), causing the intermediate representation (IR) to loseVariableAddressInstruction nodes. The fix adds acontainsAddressOf predicate to prevent constant folding of expressions containing address-of operators, ensuring that address operations remain visible in the IR for proper analysis.

Changes:

  • AddedcontainsAddressOf predicate to detect expressions containing address-of operations
  • ModifiedisIRConstant to exclude expressions containing address-of operators
  • Added comprehensive test coverage for address-vs-null comparisons with global, local, and parameter variables

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

FileDescription
cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qllAddedcontainsAddressOf predicate and integrated it intoisIRConstant to prevent constant folding of expressions containing address-of operators
cpp/ql/test/library-tests/ir/address_constant_folding/test.cComprehensive test file with various address-vs-null comparison scenarios covering global, local, and parameter variables
cpp/ql/test/library-tests/ir/address_constant_folding/variable_addresses.qlTest query to verifyVariableAddressInstruction nodes are present in the IR
cpp/ql/test/library-tests/ir/address_constant_folding/variable_addresses.expectedAuto-generated test expectations file (empty, will be populated when tests run)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

C++no-change-note-requiredThis PR does not need a change note

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

CPP: IR inconsistency with global variable and address-of related to constant-folding(?)

1 participant

@IdrissRio

[8]ページ先頭

©2009-2026 Movatter.jp