Skip to content
  • Ondřej Surý's avatar
    Use coccinelle to add braces to nested single line statement · 36c6105e
    Ondřej Surý authored
    Both clang-tidy and uncrustify chokes on statement like this:
    
    for (...)
    	if (...)
    		break;
    
    This commit uses a very simple semantic patch (below) to add braces around such
    statements.
    
    Semantic patch used:
    
    @@
    statement S;
    expression E;
    @@
    
    while (...)
    - if (E) S
    + { if (E) { S } }
    
    @@
    statement S;
    expression E;
    @@
    
    for (...;...;...)
    - if (E) S
    + { if (E) { S } }
    
    @@
    statement S;
    expression E;
    @@
    
    if (...)
    - if (E) S
    + { if (E) { S } }
    36c6105e