@@ -1055,7 +1055,7 @@ Parser::WalkClassTemplateSpecialization(const clang::ClassTemplateSpecialization
10551055 TS->isIncomplete = true ;
10561056 if (CTS->getDefinition ())
10571057 {
1058- auto Complete = WalkDeclaration (CTS->getDefinition ());
1058+ auto Complete = WalkDeclarationDef (CTS->getDefinition ());
10591059 if (!Complete->isIncomplete )
10601060 TS->completeDeclaration = Complete;
10611061 }
@@ -1105,7 +1105,7 @@ Parser::WalkClassTemplatePartialSpecialization(const clang::ClassTemplatePartial
11051105 TS->isIncomplete = true ;
11061106 if (CTS->getDefinition ())
11071107 {
1108- auto Complete = WalkDeclaration (CTS->getDefinition ());
1108+ auto Complete = WalkDeclarationDef (CTS->getDefinition ());
11091109 if (!Complete->isIncomplete )
11101110 TS->completeDeclaration = Complete;
11111111 }
@@ -3468,7 +3468,18 @@ void Parser::HandleDeclaration(const clang::Decl* D, Declaration* Decl)
34683468
34693469Declaration* Parser::WalkDeclarationDef (clang::Decl* D)
34703470{
3471- return WalkDeclaration (D);
3471+ auto Decl = WalkDeclaration (D);
3472+ if (!Decl || Decl->definitionOrder > 0 )
3473+ return Decl;
3474+ // We store a definition order index into the declarations.
3475+ // This is needed because declarations are added to their contexts as
3476+ // soon as they are referenced and we need to know the original order
3477+ // of the declarations.
3478+ clang::RecordDecl* RecordDecl;
3479+ if ((RecordDecl = llvm::dyn_cast<clang::RecordDecl>(D)) &&
3480+ RecordDecl->isCompleteDefinition ())
3481+ Decl->definitionOrder = index++;
3482+ return Decl;
34723483}
34733484
34743485Declaration* Parser::WalkDeclaration (const clang::Decl* D)
@@ -3483,41 +3494,13 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D)
34833494 case Decl::Record:
34843495 {
34853496 auto RD = cast<RecordDecl>(D);
3486- auto Record = WalkRecord (RD);
3487-
3488- // We store a definition order index into the declarations.
3489- // This is needed because declarations are added to their contexts as
3490- // soon as they are referenced and we need to know the original order
3491- // of the declarations.
3492-
3493- if (Record->definitionOrder == 0 &&
3494- RD->isCompleteDefinition ())
3495- {
3496- Record->definitionOrder = index++;
3497- // Debug("%d: %s\n", Index++, GetTagDeclName(RD).c_str());
3498- }
3499-
3500- Decl = Record;
3497+ Decl = WalkRecord (RD);
35013498 break ;
35023499 }
35033500 case Decl::CXXRecord:
35043501 {
35053502 auto RD = cast<CXXRecordDecl>(D);
3506- auto Class = WalkRecordCXX (RD);
3507-
3508- // We store a definition order index into the declarations.
3509- // This is needed because declarations are added to their contexts as
3510- // soon as they are referenced and we need to know the original order
3511- // of the declarations.
3512-
3513- if (Class->definitionOrder == 0 &&
3514- RD->isCompleteDefinition ())
3515- {
3516- Class->definitionOrder = index++;
3517- // Debug("%d: %s\n", Index++, GetTagDeclName(RD).c_str());
3518- }
3519-
3520- Decl = Class;
3503+ Decl = WalkRecordCXX (RD);
35213504 break ;
35223505 }
35233506 case Decl::ClassTemplate:
0 commit comments