[PATCH] [clang-tidy] Add check misc-braces-around-statements.
Alexander Kornienko
alexfh at google.com
Tue Sep 30 06:09:06 PDT 2014
This looks good for the initial version once you address the comments.
I'd also ask you to run the check over LLVM source code as a smoke test and take a look at the changes the script produces (you can use the run-clang-tidy.py script for this). This can be done after submitting the code.
Thanks again for the great job!
================
Comment at: clang-tidy/misc/BracesAroundStatementsCheck.cpp:169
@@ +168,3 @@
+ SourceLocation StartLoc =
+ backwardSkipWhitespaceAndComments(WS->getBody()->getLocStart(),
+ *Result.SourceManager,
----------------
Sorry for missing this previously: here and in the next branch you could find the right parenthesis by skipping forward starting from Lexer::getLocForEndOfToken(WS->getCond()->getLocEnd(), 0, ...). This would probably be more efficient and use only one skip function.
================
Comment at: test/clang-tidy/misc-braces-around-statements.cpp:179
@@ +178,3 @@
+ // CHECK-MESSAGES: :[[@LINE-5]]:38: warning: statement should be inside braces
+ // CHECK-FIXES: if (1) { while (2) { if (3) { for (;;) { do { ; } while(false) /**/;
+ // CHECK-FIXES-NEXT: }
----------------
What happens with the comment that was after the semicolon? Could you please add it to the appropriate check line?
http://reviews.llvm.org/D5395
More information about the cfe-commits
mailing list