Title: Handle line splicing (backslash-newline) in TokenList::Stream · Issue #741 · cppcheck-opensource/simplecpp · GitHub
Open Graph Title: Handle line splicing (backslash-newline) in TokenList::Stream · Issue #741 · cppcheck-opensource/simplecpp
X Title: Handle line splicing (backslash-newline) in TokenList::Stream · Issue #741 · cppcheck-opensource/simplecpp
Description: simplecpp removes a backslash-newline only when it is between tokens. A splice inside a token splits the token instead of joining it. The standard does line splicing in translation phase 2, before tokenization, so the token must be joine...
Open Graph Description: simplecpp removes a backslash-newline only when it is between tokens. A splice inside a token splits the token instead of joining it. The standard does line splicing in translation phase 2, before ...
X Description: simplecpp removes a backslash-newline only when it is between tokens. A splice inside a token splits the token instead of joining it. The standard does line splicing in translation phase 2, before ...
Opengraph URL: https://github.com/cppcheck-opensource/simplecpp/issues/741
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Handle line splicing (backslash-newline) in TokenList::Stream","articleBody":" simplecpp removes a backslash-newline only when it is between tokens. A splice inside a token splits the token instead of joining it.\n The standard does line splicing in translation phase 2, before tokenization, so the token must be joined.\n\n | Input | gcc | simplecpp |\n |---|---|---|\n | `ab\\`⏎`cd` | `abcd` | `ab cd` |\n | `12\\`⏎`34` | `1234` | `12 34` |\n | `x +\\`⏎`= 1;` | `x += 1;` | `x + = 1 ;` |\n | `/\\`⏎`/ comment` | (comment) | `/ / comment` |\n | `#def\\`⏎`ine A 1` / `A` | `1` | `A` |\n\n ### Proposed change\n\n Remove backslash-newline in `TokenList::Stream::readChar()`, using the lookahead buffer from #739, and count the removed lines.\n `readfile` adds the count to the line number at the next newline, as it does now for splices between tokens. The splice code in\n `readfile`, `readLineComment()` and `readErrorText()` can then be removed or simplified.\n\n ### Must stay unchanged\n\n - Raw token locations. Tokens after a splice keep the line of the start of the logical line (cppcheck uses these locations, for\n example for inline suppressions).\n - Splices between tokens, in string and character literals, in comments, and in `#define` bodies.\n - Raw string literals: the splice is kept, so `R\"(a\\`⏎`b)\"` still contains the backslash and the newline (C++ [lex.pptoken]).\n - `\\` followed by spaces or tabs and a newline is still a splice, and still gives the \"Combination 'backslash space newline' is not\n portable.\" warning.\n\n ### Testing\n\n - Tests for the cases in the table above, with all input types (including `FileStream` through `readfileFromFile()`).\n - Compare `-l` output and raw tokens before and after for real code (/usr/include, cppcheck sources, simplecpp testsuite) and CRLF,\n CR, BOM and UTF-16 copies of them, with all 4 `-input` types.\n\n Part of #708.\n","author":{"url":"https://github.com/danmar","@type":"Person","name":"danmar"},"datePublished":"2026-11-07T22:17:08Z","url":"https://github.com/cppcheck-opensource/simplecpp/issues/741"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:55b971b8-9e6f-52b6-3264-3d212e820d93 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF78:2B3610:1C2F1B:284A4C:6AFC4AE9 |
| html-safe-nonce | 22d0214ddc5b016d1a7765b5bbb9b63b9c76ab292b848db30e46e053cd2e0a56 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjc4OjJCMzYxMDoxQzJGMUI6Mjg0QTRDOjZBRkM0QUU5IiwidmlzaXRvcl9pZCI6IjE1NTE2ODMzMDgyOTc2NjkzNTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 929fb987486a5aaba20870008856ddb72e54768674bf6a81d80f2858fb279048 |
| hovercard-subject-tag | issue:6264784299 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cppcheck-opensource/simplecpp/741/issue_layout |
| twitter:image | https://opengraph.githubassets.com/730793e22adf51d3eaec5175945f2b359f592623a28bfe009da4be379b5ff732/cppcheck-opensource/simplecpp/issues/741 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/730793e22adf51d3eaec5175945f2b359f592623a28bfe009da4be379b5ff732/cppcheck-opensource/simplecpp/issues/741 |
| og:image:alt | simplecpp removes a backslash-newline only when it is between tokens. A splice inside a token splits the token instead of joining it. The standard does line splicing in translation phase 2, before ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | danmar |
| hostname | github.com |
| expected-hostname | github.com |
| None | 20dfdada12bc00bbf8065dc10dfe3ff3711b85db5cc117f83296f8074e861960 |
| turbo-cache-control | no-preview |
| go-import | github.com/cppcheck-opensource/simplecpp git https://github.com/cppcheck-opensource/simplecpp.git |
| octolytics-dimension-user_id | 278097703 |
| octolytics-dimension-user_login | cppcheck-opensource |
| octolytics-dimension-repository_id | 33434464 |
| octolytics-dimension-repository_nwo | cppcheck-opensource/simplecpp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33434464 |
| octolytics-dimension-repository_network_root_nwo | cppcheck-opensource/simplecpp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 041909865f220ab51714e7efdc276dd349a99ade |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width