[PATCH] D39478: [clang-format] Handle leading comments in using declaration

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 1 12:12:36 PDT 2017


djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Some minor remarks, but generally looks good. Thanks for fixing this!



================
Comment at: lib/Format/UsingDeclarationsSorter.cpp:136
   for (size_t I = 0, E = AnnotatedLines.size(); I != E; ++I) {
+    auto FirstTok = AnnotatedLines[I]->First;
     if (AnnotatedLines[I]->InPPDirective ||
----------------
  const auto *FirstTok

or

  const FormatToken *FirstTok


================
Comment at: lib/Format/UsingDeclarationsSorter.cpp:142
     }
-    if (AnnotatedLines[I]->First->NewlinesBefore > 1)
+    if (FirstTok->NewlinesBefore > 1) {
       endUsingDeclarationBlock(&UsingDeclarations, SourceMgr, &Fixes);
----------------
We don't use braces around single-statement ifs in LLVM style.


================
Comment at: lib/Format/UsingDeclarationsSorter.cpp:145
+    }
+    auto UsingTok =
+        FirstTok->is(tok::comment) ? FirstTok->getNextNonComment() : FirstTok;
----------------
  const auto *UsingTok

or

  const FormatToken *UsingTok


https://reviews.llvm.org/D39478





More information about the cfe-commits mailing list