Skip to content

[BUG] Allow contracts to be parsed when ghost function is forward declared - #6

Merged
SwayamInSync merged 2 commits into
mainfrom
func-fwd-decl
Apr 14, 2026
Merged

SwayamInSync merged 2 commits into
mainfrom
func-fwd-decl

Conversation

@SwayamInSync

Copy link
Copy Markdown
Owner

This pull request updates how function contracts are accessed and stored in the ASTContext to ensure consistency when dealing with redeclared functions. The main change is that function contract information is now always associated with a function's canonical declaration, preventing issues with multiple redeclarations.

Improvements to Function Contract Handling:

  • Updated both getOrCreateFunctionContract and getFunctionContract in ASTContext to use the canonical declaration of a FunctionDecl as the key in the FunctionContracts map, ensuring consistent storage and retrieval for redeclared functions.

@SwayamInSync
SwayamInSync requested a review from Copilot April 14, 2026 10:01

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes inconsistent function contract storage/retrieval across redeclarations by always keying ASTContext::FunctionContracts entries off a function’s canonical declaration.

Changes:

  • Store function contract info under FD->getCanonicalDecl() in getOrCreateFunctionContract.
  • Lookup function contract info using FD->getCanonicalDecl() in getFunctionContract.

Comment thread clang/lib/AST/ASTContext.cpp
Comment thread clang/lib/AST/ASTContext.cpp
@SwayamInSync
SwayamInSync merged commit 5b31869 into main Apr 14, 2026
6 checks passed
@SwayamInSync
SwayamInSync deleted the func-fwd-decl branch June 2, 2026 20:25
SwayamInSync added a commit that referenced this pull request Jul 27, 2026
[BUG] Allow contracts to be parsed when ghost function is forward declared
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants