curdeius added inline comments.

================
Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:27
 // Returns "" for anonymous namespace.
-std::string computeName(const FormatToken *NamespaceTok) {
+bool computeName(const FormatToken *NamespaceTok, std::string &name) {
   assert(NamespaceTok &&
----------------
It seems to be a good place for optional, nope?


================
Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:183
   const FormatToken *NamespaceTok = AnnotatedLines[StartLineIndex]->First;
   if (NamespaceTok->is(tok::l_brace)) {
     // "namespace" keyword can be on the line preceding '{', e.g. in styles
----------------
Maybe just checking previous (non-comment) token to be not a semicolon would be 
enough?


================
Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:250
+    std::string NamespaceName;
+    if (!computeName(NamespaceTok, NamespaceName)) {
+      // Its likely a namespace alias.
----------------
As an alternative, couldn't we avoid computing the name for namespace aliases 
by searching the next semicolon (don't compute) or l_brace (compute)?


================
Comment at: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp:1189
+
+TEST_F(ShortNamespaceLinesTest, NameSpaceAlias) {
+  auto Style = getLLVMStyle();
----------------
Nit: `NamespaceAlias` with small 's'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115647

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

Reply via email to