cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

simplify asm labels

Open DGarry82 opened this issue 3 years ago • 4 comments

Fixes cppcheck 2.7 regression and adds support for proper (i hope) asm labels processing (https://gcc.gnu.org/onlinedocs/gcc/Asm-Labels.html).

How it looks in cppcheck 2.7:

$ cppcheck asmlabel.c
Checking asmlabel.c ...
asmlabel.c:2:7: error: There is an unknown macro here somewhere. Configuration is required. If func is a macro then please configure it. [unknownMacro]
void* func() asm ("myfunc") ;
      ^
$ cat asmlabel.c
int* pfoo asm ("pmyfoo") = NULL;
void* func() asm ("myfunc") ;

$ cppcheck --debug asmlabel.c
Checking asmlabel.c ...


##file asmlabel.c
1: int * pfoo asm ( ""pmyfoo"" ) ; = NULL ;
2: void * func ( ) asm ( ""myfunc"" ) ;



##Value flow
asmlabel.c:2:7: error: There is an unknown macro here somewhere. Configuration is required. If func is a macro then please configure it. [unknownMacro]
void* func() asm ("myfunc") ;

DGarry82 avatar Feb 12 '22 21:02 DGarry82

Well.. Have to find a way to distinguish asm label from asm inline. For example, testsuite failure @ test/testother.cpp:4810 shows that just analyzing adjacent tokens is not enough.

( test/testother.cpp:4810)

        check("void f() {\n"
              "    if (b)\n"
              "        __asm__(\"mov ax, bx\");\n"
              "    else\n"
              "        __asm__(\"mov ax, bx\");\n"
              "}");
        ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style, inconclusive) Found duplicate branches for 'if' and 'else'.\n", errout.str());

DGarry82 avatar Feb 12 '22 22:02 DGarry82

Baffled by "format / build" check failure. Log message: 2022-02-13T12:13:15.7455536Z FAIL: lib/tokenize.cpp (File size changed from 491084 to 491087 All formatting (indents, braces etc) seems to be identical to existing code. Any ideas?

DGarry82 avatar Feb 13 '22 12:02 DGarry82

Baffled by "format / build" check failure. Log message: 2022-02-13T12:13:15.7455536Z FAIL: lib/tokenize.cpp (File size changed from 491084 to 491087 All formatting (indents, braces etc) seems to be identical to existing code. Any ideas?

You should run uncrustify and compare its output to your tokenize.cpp.

chrchr-github avatar Feb 13 '22 13:02 chrchr-github

Baffled by "format / build" check failure. Log message: 2022-02-13T12:13:15.7455536Z FAIL: lib/tokenize.cpp (File size changed from 491084 to 491087 All formatting (indents, braces etc) seems to be identical to existing code. Any ideas?

You should run uncrustify and compare its output to your tokenize.cpp.

Thanks a lot, it helped (found one missing space in indents). It's a pity that diff between original and "uncrustified" file isn't shown in job logs.

DGarry82 avatar Feb 13 '22 14:02 DGarry82