njames93 added a comment.

I'd argue this check isn't following the enforcement specified in the relevant 
guideline:

  Enforcement:
  Warn when a variable modified inside the for-statement is declared outside 
the loop and not being used outside the loop.

All this is checking is that there is a declStmt in the for stmt, it doesn't 
even have to be a relevant declaration, this code would be considered ok by the 
implementation in here.

  int I = 0;
  for (int Unused = 0; I < 10; ++I) {}

Ideally you want to check for variables modified in the condition or iteration 
expression that aren't declared in the init statement.
To be fully compliant with the wording you would also need to ensure the 
variable isn't referenced outside the loop.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100092/new/

https://reviews.llvm.org/D100092

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to