An example that using asm could bypass the style checker.
Closed this issue · 1 comments
qazwsxedcrfvtg14 commented
#include <stdio.h>
#include <stdint.h>
#define CONCATE(X, Y) X##Y
#define GLUE(X, Y) CONCATE(X,Y)
#define MYLABEL(LABEL) uint64_t LABEL;\
asm volatile("%=:lea %=b(%%rip), %0;": "=r"(LABEL))
#define MYGOTO(LABEL) asm volatile("jmp *%0"::"r"(LABEL));
#define MYCONDITIONGOTO(CONDITION, LABEL) { \
int __contition__ = CONDITION; \
asm volatile("test %1, %1; jz %=f; jmp *%0;%=:"::\
"r"(LABEL), "r"(__contition__));}
#define MYDOWHILE(BLOCK, CONDITION) { \
MYLABEL(GLUE(__label_,__LINE__)); \
{BLOCK}; \
MYCONDITIONGOTO(CONDITION, GLUE(__label_,__LINE__));}
int main(){
int a = 0;
MYDOWHILE({
printf("test A\n");
a++;
}, a<10);
int b = 0;
MYDOWHILE({
printf("test B\n");
b++;
}, b<5);
int c = 0;
MYDOWHILE({
int d = 0;
MYDOWHILE({
printf("test CD\n");
d++;
}, d<3);
c++;
}, c<2);
return 0;
}
Output result:
suffix c
global variables found: 0
============================
if case while for found: 0
============================
? found: 0
============================
estimated cyclomatic complexity: 0
============================
goto found: 0
============================
the length of the longest line: 59
pangfengliu commented
The asm is blocked and a warning message is added.