Skip to content

Commit 2878282

Browse files
strimo378AaronBallman
authored andcommitted
[clang][DeclPrinter] Fix AST print of out-of-line record definitions
DeclPrinter::VisitCXXRecordDecl did not output qualifiers for records. As result, the output of out-of-line record definitions was incorrect. Differential Revision: https://reviews.llvm.org/D151528
1 parent 4418434 commit 2878282

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

clang/lib/AST/DeclPrinter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,10 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
997997
prettyPrintAttributes(D);
998998

999999
if (D->getIdentifier()) {
1000-
Out << ' ' << *D;
1000+
Out << ' ';
1001+
if (auto *NNS = D->getQualifier())
1002+
NNS->print(Out, Policy);
1003+
Out << *D;
10011004

10021005
if (auto S = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
10031006
ArrayRef<TemplateArgument> Args = S->getTemplateArgs().asArray();

clang/test/AST/ast-print-record-decl.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,19 @@ KW DeclGroupInMemberList {
289289

290290
// A tag decl group in the tag decl's own member list is exercised in
291291
// defSelfRef above.
292+
293+
294+
// Check out-of-line record definition
295+
#ifdef __cplusplus
296+
// PRINT-CXX-NEXT: [[KW]] OutOfLineRecord {
297+
KW OutOfLineRecord {
298+
// PRINT-CXX-NEXT: [[KW]] Inner
299+
KW Inner;
300+
// PRINT-CXX-NEXT: };
301+
};
302+
303+
// PRINT-CXX-NEXT: [[KW]] OutOfLineRecord::Inner {
304+
KW OutOfLineRecord::Inner {
305+
// PRINT-CXX-NEXT: };
306+
};
307+
#endif

0 commit comments

Comments
 (0)