[PATCH] D141714: Fix ast print of variables with attributes

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 7 09:09:16 PDT 2023


erichkeane added inline comments.


================
Comment at: clang/lib/AST/DeclPrinter.cpp:312
+          // printing on the left side for readbility.
+        else if (const VarDecl *VD = dyn_cast<VarDecl>(D);
+                   VD && VD->getInit() &&
----------------
While compiling this, I discovered that the lack of curley braces on the `else if (canPrintOnLeftSide(A))` means that this `else-if` is actually an else to THAT instead, despite its indention (which implies it should be associated with the `if (const FunctionDecl...`).

Which is it?  I presume the indenting is what you mean, but it hasn't been tested in a way that matters.  Can you add a test that validates the var-decl printing on the LHS ONLY happens when it 'can' print on the LHS?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714



More information about the cfe-commits mailing list