[llvm-dev] -Wmisleading-indentation violations

Duncan P. N. Exon Smith via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 1 23:02:16 PDT 2016


> On 2016-Jun-01, at 22:51, Dan Liew <dan at su-root.co.uk> wrote:
> 
> ```
> /home/dsl11/dev/llvm-upstream/src/lib/AsmParser/LLParser.cpp: In
> member function ‘bool llvm::LLParser::ParseTopLevelEntities()’:
> 
> /home/dsl11/dev/llvm-upstream/src/lib/AsmParser/LLParser.cpp:260:34:
> warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
> 
>                                 if (ParseUseListOrderBB()) return true; break;
> 
>                                 ^~
> 
> /home/dsl11/dev/llvm-upstream/src/lib/AsmParser/LLParser.cpp:260:74:
> note: ...this statement, but the latter is misleadingly indented as if
> it
> 
> is guarded by the ‘if’
> 
>                                 if (ParseUseListOrderBB()) return true; break;
> 
>                                                                         ^~~~~
> ```

LLParser::ParseTopLevelEntities() hasn't been clang-formatted.  The
style is one case per line (and every case uses the exact same pattern:
`if`, `return true`, `break`).

I think the density this provides makes the code easier to read than
clang-format's preference, but maybe a local macro would be better?
--
 #define DISPATCH_TOP_LEVEL_ENTITY(token, parser) \
   case lltok::token:                             \
     if (parser)                                  \
       return true;                               \
     break;
 DISPATCH_TOP_LEVEL_ENTITY(kw_declare, ParseDeclare())
 DISPATCH_TOP_LEVEL_ENTITY(kw_define, ParseDefine())
 ...
 #undef DISPATCH_TOP_LEVEL_ENTITY
--



More information about the llvm-dev mailing list