[PATCH] Improved llvm-namespace-comment check.

Alexander Kornienko alexfh at google.com
Mon May 19 09:43:34 PDT 2014


================
Comment at: clang-tidy/llvm/NamespaceCommentCheck.cpp:66
@@ +65,3 @@
+  Token Tok;
+  while (Lexer::getRawToken(Loc, Tok, Sources, Result.Context->getLangOpts())) {
+    Loc = Loc.getLocWithOffset(1);
----------------
Manuel Klimek wrote:
> Can you add a comment explaining why it's ok to retry on failure with an incremented location?
Done.

================
Comment at: clang-tidy/llvm/NamespaceCommentCheck.cpp:73
@@ +72,3 @@
+  bool NextTokenIsOnSameLine = Sources.getSpellingLineNumber(Loc) == EndLine;
+  bool NeedLineBreak = NextTokenIsOnSameLine && Tok.isNot(tok::eof);
+
----------------
Manuel Klimek wrote:
> Can you explain why we need this? (I'd have expected the fix-it to not change the number of newlines, thus just inserting the comment between the } and the newline).
We need it for the case where the next token after '}' is on the same line (see the test cases on lines 17 and 32 of unittests/clang-tidy/LLVMModuleTest.cpp).

http://reviews.llvm.org/D3825






More information about the cfe-commits mailing list