[clang] [clang][AST] fix ast-print of `extern <lang>` with >=2 declarators (PR #93131)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu May 23 09:26:23 PDT 2024


================
@@ -1145,13 +1145,15 @@ void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
     l = "C++";
   }
 
+  bool HasMoreThanOneDecl =
+      *D->decls_begin() && D->decls_begin()->getNextDeclInContext();
----------------
erichkeane wrote:

It just seems a bit more readable to me.  We're checking if the length of the decls is > 1, so it seemed more clear?

Though, as this isn't performance critical code, perhaps: 
`bool HasMoreThanOneDecl = std::distance(D->decls_begin(), D->decls_end()) > 1` is much more readable.

https://github.com/llvm/llvm-project/pull/93131


More information about the cfe-commits mailing list