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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu May 30 06:49:29 PDT 2024


================
@@ -662,6 +678,11 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   CXXConversionDecl *ConversionDecl = dyn_cast<CXXConversionDecl>(D);
   CXXDeductionGuideDecl *GuideDecl = dyn_cast<CXXDeductionGuideDecl>(D);
   if (!Policy.SuppressSpecifiers) {
+    if (const char *lang = tryGetUnbracedLinkageLanguage(D)) {
+      // the "extern" specifier is implicit
+      assert(D->getStorageClass() == SC_None);
+      Out << "extern \"" << lang << "\" ";
+    }
----------------
AaronBallman wrote:

```suggestion
    if (const char *Lang = tryGetUnbracedLinkageLanguage(D)) {
      // the "extern" specifier is implicit
      assert(D->getStorageClass() == SC_None);
      Out << "extern \"" << Lang << "\" ";
    }
```

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


More information about the cfe-commits mailing list