Repository navigation
Conversation
Fixes clang-tidy readability-convert-member-functions-to-static. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no crash, hang or regression. All test suites pass. I have two remarks:
INTMAX_C/UINTMAX_Care not handled.isIntegerConstantMacro()only accepts n = 8/16/32/64. The C standard (C11 7.20.4.2) also listsINTMAX_CandUINTMAX_Camong the integer constant macros, and for thoseargstays empty.argis not always the text as written. If the call is inside a macro body (for example#define X(a) UINT32_C(a)),argholds the substituted text with macros already expanded. WithX(R(7) /* c */ + 8)it is7 + 8, notR ( 7 ) + 8. The comment insimplecpp.hsays "as written in the call". Either the code or that comment should change.
This is the first review of the PR; comments.md is empty.
Testing
Build and test suites
make -j8 testrunner simplecpp CXXOPTS=-Werrorinpr/built cleanly../testrunnerpassed with no failures.python3 run-tests.py: 176 tests, 0 failed (21 skipped, 15 todo, the same as before).python3 -m pytest integration_test.py: 128 passed../selfcheck.shexited with 0.
Own driver
I wrote a small driver, scratch/drv.cpp. It calls simplecpp::preprocess with a macroUsage list and prints name line:col [arg] for each entry. I ran it on these cases:
- calls inside a define (
#define X(a) UINT32_C(a),#define Q UINT32_C,#define Y UINT32_C(7)) - a call nested in another macro's arguments (
F(UINT32_C(9))) - a macro passed as an argument (
V(UINT32_C)) - arguments that span lines, both at top level and inside a multi-line outer call (
R(\nUINT32_C(5\n+6))) - comments, with comments both removed and kept
- an unterminated
UINT32_C(at end of file
The arguments came out as expected and there was no crash or hang. The preprocessed output matched gcc -E.
Problems found
INTMAX_C/UINTMAX_Cget no argument:
#define INTMAX_C(x) x
#define UINTMAX_C(x) x
INTMAX_C(300) UINTMAX_C(1)./drv t6.c prints:
INTMAX_C 3:1 []
UINTMAX_C 3:15 []
- Inside a macro body, the argument is the expanded text, not the written text:
#define UINT32_C(x) x
#define X(a) UINT32_C(a)
#define R(a) a
X(R(7) /* c */ + 8)The driver prints UINT32_C 4:1 [7 + 8].
Automated review of ca6cd8d by Claude. The pull request was built and tested locally.
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no new problems. The earlier review raised two points, and both are fixed in the current code. isIntegerConstantMacro() now accepts INTMAX_C and UINTMAX_C, which macroUsageArg7 covers. The doc comment of MacroUsage::arg in simplecpp.h now says that for a call inside a macro body the argument is the substituted and expanded text, and macroUsageArg6 tests that case. The build is clean with -Werror, all test suites pass, and my own cases gave the expected arg with no crash and no change to the preprocessed output compared with base.
Comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | INTMAX_C / UINTMAX_C are not handled | AI review | general | ✅ Fixed |
| 2 | arg is not the written text when the call is in a macro body; the doc comment is wrong | AI review | general | ✅ Fixed |
| 3 | isIntegerConstantMacro misses INTMAX_C / UINTMAX_C | AI review | simplecpp.cpp:2280 |
✅ Fixed |
| 4 | the 'as written' doc comment is wrong for calls in a macro body; no test for it | AI review | simplecpp.h:468 |
✅ Fixed |
Testing
Build and test suites
make -j8 testrunner simplecpp CXXOPTS=-Werrorinpr/: built cleanly../testrunner: 0 failed (21 skipped, 15 todo).python3 run-tests.py: no failures.python3 -m pytest integration_test.py: 128 passed../selfcheck.sh: exit code 0.
Own driver
I wrote scratch/drv.cpp, which calls simplecpp::preprocess with a macroUsage list and prints name line:col [arg] for each entry. I ran it on these cases:
- a macro passed as an argument and then called inside the body (
#define F(m) m(5)/F(UINT32_C)): gives[5] - a call formed after expansion (
G(UINT32_C)(7+1)): gives[7 + 1] - an object-like macro that opens the call (
#define H UINT32_C(/H 3)): gives[3] - the name and
(on different lines: gives[4] - calls in a macro body whose arguments span several lines (
X(1\n+2),Y(\n3\n),Z(1,\n\n2)): gives[1 + 2],[3]and[9],[1 2] - nested integer constant macros together with a
//comment: the outer call gives[INT8_C ( 1 ) + 2]and the inner one[1] - a call inside another macro's argument (
W(UINT32_C(W(4)))): gives[W ( 4 )] - a stringified call (
S(UINT32_C(3))): no usage is recorded - two calls in one object-like body: gives
[1]and[2] - unterminated calls inside a define, including
UINTMAX_C
There was no crash or hang. diff <(../base/simplecpp d.c) <(../pr/simplecpp d.c) showed no difference, so the PR does not change the preprocessed output.
Automated review of 5d9ba16 by Claude. The pull request was built and tested locally.
No description provided.