Index: clang/lib/AST/DeclPrinter.cpp =================================================================== --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -997,7 +997,10 @@ prettyPrintAttributes(D); if (D->getIdentifier()) { - Out << ' ' << *D; + Out << ' '; + if (auto *NNS = D->getQualifier()) + NNS->print(Out, Policy); + Out << *D; if (auto S = dyn_cast(D)) { ArrayRef Args = S->getTemplateArgs().asArray(); Index: clang/test/AST/ast-print-record-decl.c =================================================================== --- clang/test/AST/ast-print-record-decl.c +++ clang/test/AST/ast-print-record-decl.c @@ -289,3 +289,19 @@ // A tag decl group in the tag decl's own member list is exercised in // defSelfRef above. + + +// Check out-of-line record definition +#ifdef __cplusplus +// PRINT-CXX-NEXT: [[KW]] OutOfLineRecord { +KW OutOfLineRecord { + // PRINT-CXX-NEXT: [[KW]] Inner + KW Inner; + // PRINT-CXX-NEXT: }; +}; + +// PRINT-CXX-NEXT: [[KW]] OutOfLineRecord::Inner { +KW OutOfLineRecord::Inner { + // PRINT-CXX-NEXT: }; +}; +#endif