René's URL Explorer Experiment


Title: Add a macro expander that uses hide sets · Issue #742 · cppcheck-opensource/simplecpp · GitHub

Open Graph Title: Add a macro expander that uses hide sets · Issue #742 · cppcheck-opensource/simplecpp

X Title: Add a macro expander that uses hide sets · Issue #742 · cppcheck-opensource/simplecpp

Description: Part of the macro expansion rewrite (#708, step 4). Problems with the current macro expansion The standard describes macro expansion in translation phase 4 (C11 6.10.3.4, C++ [cpp.rescan]): the replacement list is rescanned together with...

Open Graph Description: Part of the macro expansion rewrite (#708, step 4). Problems with the current macro expansion The standard describes macro expansion in translation phase 4 (C11 6.10.3.4, C++ [cpp.rescan]): the rep...

X Description: Part of the macro expansion rewrite (#708, step 4). Problems with the current macro expansion The standard describes macro expansion in translation phase 4 (C11 6.10.3.4, C++ [cpp.rescan]): the rep...

Opengraph URL: https://github.com/cppcheck-opensource/simplecpp/issues/742

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add a macro expander that uses hide sets","articleBody":"  Part of the macro expansion rewrite (#708, step 4).\n\n  ### Problems with the current macro expansion\n\nThe standard describes macro expansion in translation phase 4 (C11 6.10.3.4, C++ [cpp.rescan]): the replacement list is rescanned together with the rest of the source, and a macro name found inside its own expansion is not replaced. simplecpp's `Macro::expand()` doesn't model these rules directly. It approximates them, and that causes bugs and makes the code hard to change:\n\n  - **No model of \"painted\" tokens.** Recursion is prevented with an `expandedmacros` set that is copied down the call stack, together with per-token \"expanded from\" markers. A \"temporary amnesia\" step removes the current macro from the set again while its arguments are expanded.\n  - **The same rule in three places.** \"The expansion ends with the name of a function-like macro and its arguments follow in the source\" is implemented three times: in the public `Macro::expand()`, in `expandTrailingCalls()`, and in a callback in `expandArg()`.\n  - **Arguments are expanded each time they are used**, not once before substitution. For example, macro usage is reported twice for `B(A)` with `#define B(x) x A`.\n  - **Hard to change.** It is about 1000 lines, and fixes are added as special cases.\n\n  Wrong results that follow from this:\n\n  | Input | gcc | simplecpp |\n  |---|---|---|\n  | `#define f(x) x` / `f(f)(1)` | `f(1)` | `1` |\n  | `#define R()` / `R` at the end of the file | `R` | error: wrong number of parameters |\n  | `ELLIP_FUNC(F LPAREN 'a', 'b' RPAREN)` (clang `macro_rescan_varargs.c`) | `'a' + 'b'` | `F ( 'a' , 'b' )` |\n\n  ### Proposed solution\n\n  Use the established algorithm for this: Prosser's hide-set algorithm, as used by mcpp, ucpp and chibicc. It implements the standard's rules directly:\n\n  - Each token has a hide set: the macros it must not be expanded into.\n  - An object-like macro adds itself to the hide set of its result. For a function-like macro, the result's hide set is the intersection of the hide sets of the name and the `)`, plus the macro.\n  - Each argument is fully expanded once, except where it is an operand of `#` or `##`.\n  - The result is pushed back onto the input and scanned again. A call whose arguments follow in the source is found by normal rescanning, so no special code is needed for it.\n\n  The new expander is written next to the old one and selected with `DUI::hideSetExpansion`, so both can be compared on real code and in cppcheck before the old one is removed. Functions are broken out of the old code and shared where possible (argument splitting and count check, `__FILE__`/`__LINE__`/`__COUNTER__`, `defined`, `#`, the `##` checks).\n","author":{"url":"https://github.com/danmar","@type":"Person","name":"danmar"},"datePublished":"2026-11-08T12:10:06Z","url":"https://github.com/cppcheck-opensource/simplecpp/issues/742"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0cc6bd30-2d60-2b9d-b887-996a4007bdb1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8E00:32143D:209EE6:2D48D7:6AFC4B05
html-safe-nonce6289030f01fe3d13686a6a3b06496035ed058971fc1607a727abf81b643b3d63
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTAwOjMyMTQzRDoyMDlFRTY6MkQ0OEQ3OjZBRkM0QjA1IiwidmlzaXRvcl9pZCI6Ijc3MzI0NzYxNTE2MTE1NDIyNzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacadb4890e459c8697f8992b6425ee1fdb944c0f1886cbf8f331e903d3c009265e
hovercard-subject-tagissue:6270763012
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cppcheck-opensource/simplecpp/742/issue_layout
twitter:imagehttps://opengraph.githubassets.com/407a496af23a3f61c6c6bd610dc0a2107cd7f9643ef116843bb7f5fb29d2e73f/cppcheck-opensource/simplecpp/issues/742
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/407a496af23a3f61c6c6bd610dc0a2107cd7f9643ef116843bb7f5fb29d2e73f/cppcheck-opensource/simplecpp/issues/742
og:image:altPart of the macro expansion rewrite (#708, step 4). Problems with the current macro expansion The standard describes macro expansion in translation phase 4 (C11 6.10.3.4, C++ [cpp.rescan]): the rep...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedanmar
hostnamegithub.com
expected-hostnamegithub.com
None20dfdada12bc00bbf8065dc10dfe3ff3711b85db5cc117f83296f8074e861960
turbo-cache-controlno-preview
go-importgithub.com/cppcheck-opensource/simplecpp git https://github.com/cppcheck-opensource/simplecpp.git
octolytics-dimension-user_id278097703
octolytics-dimension-user_logincppcheck-opensource
octolytics-dimension-repository_id33434464
octolytics-dimension-repository_nwocppcheck-opensource/simplecpp
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id33434464
octolytics-dimension-repository_network_root_nwocppcheck-opensource/simplecpp
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release041909865f220ab51714e7efdc276dd349a99ade
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/cppcheck-opensource/simplecpp/issues/742#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcppcheck-opensource%2Fsimplecpp%2Fissues%2F742
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcppcheck-opensource%2Fsimplecpp%2Fissues%2F742
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=cppcheck-opensource%2Fsimplecpp
Reloadhttps://github.com/cppcheck-opensource/simplecpp/issues/742
Reloadhttps://github.com/cppcheck-opensource/simplecpp/issues/742
Reloadhttps://github.com/cppcheck-opensource/simplecpp/issues/742
cppcheck-opensourcehttps://github.com/cppcheck-opensource
simplecpphttps://github.com/cppcheck-opensource/simplecpp
Codehttps://github.com/cppcheck-opensource/simplecpp
Issues86 (86)https://github.com/cppcheck-opensource/simplecpp/issues
Pull requests36 (36)https://github.com/cppcheck-opensource/simplecpp/pulls
Actionshttps://github.com/cppcheck-opensource/simplecpp/actions
Wikihttps://github.com/cppcheck-opensource/simplecpp/wiki
Security and qualityhttps://github.com/cppcheck-opensource/simplecpp/security
Insightshttps://github.com/cppcheck-opensource/simplecpp/pulse
https://github.com/cppcheck-opensource/simplecpp
New issuehttps://github.com/login?return_to=https://github.com/cppcheck-opensource/simplecpp/issues/742
New issuehttps://github.com/login?return_to=https://github.com/cppcheck-opensource/simplecpp/issues/742
Add a macro expander that uses hide setshttps://github.com/cppcheck-opensource/simplecpp/issues/742#top
https://github.com/danmar
danmarhttps://github.com/danmar
on Nov 8, 2026https://github.com/cppcheck-opensource/simplecpp/issues/742#issue-6270763012
#708https://github.com/cppcheck-opensource/simplecpp/issues/708
danmarhttps://github.com/danmar
on Nov 8, 2026https://github.com/cppcheck-opensource/simplecpp/issues/742#event-35490938013
Restructure the preprocessor to follow the standard's translation phases #708https://github.com/cppcheck-opensource/simplecpp/issues/708
danmarhttps://github.com/danmar
on Nov 10, 2026https://github.com/cppcheck-opensource/simplecpp/issues/742#event-35520843910
Add regression tests for macro expansion #744https://github.com/cppcheck-opensource/simplecpp/issues/744
Refactoring: Split expandHashHash and expandHash into check and build helpers #746https://github.com/cppcheck-opensource/simplecpp/issues/746
Move the argument count check into Macro::getMacroParameters() #748https://github.com/cppcheck-opensource/simplecpp/issues/748
Extract expandBuiltin, expandDefined and copyMacroCall #750https://github.com/cppcheck-opensource/simplecpp/issues/750
Add TokenList::setLocation() for setting the location of all tokens #752https://github.com/cppcheck-opensource/simplecpp/issues/752
hash: keep the space after an operator of two characters #754https://github.com/cppcheck-opensource/simplecpp/issues/754
hash hash: pasting a name or number with a string or character literal is an error #756https://github.com/cppcheck-opensource/simplecpp/issues/756
Sign up for freehttps://github.com/signup?return_to=https://github.com/cppcheck-opensource/simplecpp/issues/742
Sign in to commenthttps://github.com/login?return_to=https://github.com/cppcheck-opensource/simplecpp/issues/742
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.