Repository navigation
Conversation
|
I had a quick look at some of the failed jobs and they seem not related to my changes is this correct? Or is it expected from me to fixe something to get this change merged? |
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
Requesting changes: the PR stops the syntax error but also stops cppcheck from checking ACTION bodies.
- Bodies are no longer analysed (new false negatives).
ACTIONandACTION_Pnow expand to nothing, so the body is left as a bare{ ... }block at namespace scope. Cppcheck doesn't analyse code there. At top level the base config checks these bodies and finds bugs in them; with this PR it reports nothing. The macros should expand to a function header instead, asTESTandMATCHERalready do in this file. I tried that and both the syntax error and the missing warnings went away. ACTION_Pkis not a real gmock macro. gmock usesACTION_P2…ACTION_P10, which this PR doesn't define.ACTION_P2(Foo, p1, p2){}inside a namespace still givessyntaxError. Thekin the PR description is a placeholder, not a macro name.- No tests.
test/cfg/googletest.cppgets no cases for the new defines.
Testing
Built cppcheck from pr/ with make -j8 cppcheck. I didn't build base/: to get the old behaviour I ran the PR's binary with --library=../base/cfg/googletest.cfg. The PR only changes the cfg, so that gives the same results as a base build.
The motivating cases are fixed. namespace{int x;ACTION_P(B, p){}} and namespace{int x;ACTION(B){}} give syntaxError with the base cfg and no error with the PR.
Real ACTION_P2/ACTION_P3 still fail
// c.cpp
namespace{int x;ACTION_P2(Foo, p1, p2){}}$ cppcheck -q --library=googletest c.cpp
c.cpp:1:17: error: syntax error [syntaxError]
Regression: bugs inside ACTION bodies are no longer found
// e.cpp
ACTION(Foo) { int *p = 0; return *p; }
ACTION_P(Bar, n) { char buf[10]; buf[10] = n; return 0; }
void f() { int *p = 0; *p = 1; }With the base cfg (--library=base/cfg/googletest.cfg):
e.cpp:2:37: error: Array 'buf[10]' accessed at index 10, which is out of bounds. [arrayIndexOutOfBounds]
e.cpp:1:35: error: Null pointer dereference: p [nullPointer]
e.cpp:3:25: error: Null pointer dereference: p [nullPointer]
With the PR (--library=googletest), only the warning in f() is left:
e.cpp:3:25: error: Null pointer dereference: p [nullPointer]
--debug shows why: ACTION(Foo) { ... } turns into a bare block at file scope, 1: { int * p@var1 ; p@var1 = 0 ; return * p@var1 ; }, which is never analysed.
The suggested fix works. I tried these defines in a modified copy of the cfg:
ACTION(name)→auto name##Action(int arg0, int arg1)ACTION_P(name,p0)→template<class p0##_type> auto name##ActionP(p0##_type p0, int arg0)
With them, a.cpp and b.cpp have no syntax error and e.cpp reports all three errors again.
Automated review of ac6bae4 by Claude. The pull request was built and tested locally.
c21b1b6 to
e3cb45e
Compare
|
Updated missing things and added some tests cases. |
|
Thanks for running the CI 👍 i will take an other look into it tomorrow seems the new test doesn't do what i expected in ci |
e3cb45e to
87df375
Compare
|
Tests pass now locally: |
They seem to fail when they are in a namespace
with a statement before the macro.
Motivating examples: