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

Artem Yurchenko via cfe-commits cfe-commits at lists.llvm.org
Thu May 23 09:15:10 PDT 2024


================
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+
+// CHECK: extern "C" int printf(const char *, ...);
+extern "C" int printf(const char *...);
+
+// CHECK: extern "C++" {
----------------
temyurchenko wrote:

Unfortunately, I'm not aware of the design goals of `DeclPrinter`. How accurately is it trying to represent the original code? Because AST's are naturally a lossy projection of CST's, so there is always going to be a difference to the original. How much of that difference is admissible?

I can try to work around that by querying `VarDecl::isInExternCContext`/`isInExternCXXContext` inside of `VarDecl`, but my initial naive implementation didn't have the desired result. 

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


More information about the cfe-commits mailing list