[PATCH] D33440: clang-format: better handle statement and namespace macros

Francois Ferrand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 13 08:49:09 PDT 2017


Typz marked 8 inline comments as done.
Typz added inline comments.


================
Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:155
   const FormatToken *NamespaceTok = AnnotatedLines[StartLineIndex]->First;
-  // Detect "(inline)? namespace" in the beginning of a line.
-  if (NamespaceTok->is(tok::kw_inline))
-    NamespaceTok = NamespaceTok->getNextNonComment();
-  if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))
-    return nullptr;
-  return NamespaceTok;
+  return NamespaceTok->getNamespaceToken();
+}
----------------
krasimir wrote:
> What happened to the old `// Detect "(inline)? namespace" in the beginning of a line.`
Moved to `FormatToken::getNamespaceToken()`


================
Comment at: unittests/Format/FormatTest.cpp:1588
+  Style.NamespaceIndentation = FormatStyle::NI_All;
+  verifyFormat("TESTSUITE(A) {\n"
+               "  int foo();\n"
----------------
krasimir wrote:
> Hm, what would happen if you have a namespace macro with two or more parameters?
only the first argument is used, as seen in previous test case.


https://reviews.llvm.org/D33440





More information about the cfe-commits mailing list