Skip to content

Extend clang lexer to support contract-keywords and gate behind -fverify-contracts - #1

Closed
SwayamInSync wants to merge 2 commits into
mainfrom
contract-keywords
Closed

SwayamInSync wants to merge 2 commits into
mainfrom
contract-keywords

Conversation

@SwayamInSync

Copy link
Copy Markdown
Owner

Summary

Extends Clang with first-class contract syntax keywords for deductive verification, gated behind the -fverify-contracts flag.

Changes

  • Add new keywords to TokenKinds.def: pre, post, invariant, decreases, ghost, spec_fn, proof_fn
  • Gate keywords with KEYCONTRACT flag, only active when -fverify-contracts is passed
  • Add -fverify-contracts / -fno-verify-contracts driver and CC1 flags
  • Add VerifyContracts to LangOptions
  • Update IdentifierTable to handle contract keyword registration
  • Add driver test (verify_contracts.cpp) and lexer test (verify_contracts_keywords.cpp)

Design

Keywords are invisible to normal compilation — they remain plain identifiers unless -fverify-contracts is explicitly passed. This ensures zero impact on existing C++ code.

@SwayamInSync SwayamInSync changed the title Add contract keywords and gate behind -fverify-contracts Extend clang lexer to support contract-keywords and gate behind -fverify-contracts Apr 9, 2026
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.

1 participant