From: Argyrios Kyrtzidis Date: Sat, 9 Aug 2008 00:58:37 +0000 (+0000) Subject: When in C++, invoke ASTConsumer::HandleTagDeclDefinition in Sema::ActOnFinishCXXClassDef, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4755c6ffab02586162170199d0c0594efaa273c;p=clang When in C++, invoke ASTConsumer::HandleTagDeclDefinition in Sema::ActOnFinishCXXClassDef, at which point the C++ struct/class/union is fully parsed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54569 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 3b4ad02dea..a96195e525 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2142,7 +2142,10 @@ void Sema::ActOnFields(Scope* S, // Okay, we successfully defined 'Record'. if (Record) { Record->defineBody(&RecFields[0], RecFields.size()); - Consumer.HandleTagDeclDefinition(Record); + // If this is a C++ record, HandleTagDeclDefinition will be invoked in + // Sema::ActOnFinishCXXClassDef. + if (!isa(Record)) + Consumer.HandleTagDeclDefinition(Record); } else { ObjCIvarDecl **ClsFields = reinterpret_cast(&RecFields[0]); if (ObjCInterfaceDecl *ID = dyn_cast(EnclosingDecl)) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 87efe2ba4b..554e742669 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -13,6 +13,7 @@ #include "Sema.h" #include "clang/Basic/LangOptions.h" +#include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/Expr.h" @@ -469,11 +470,13 @@ void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, } void Sema::ActOnFinishCXXClassDef(DeclTy *D) { - Decl *Dcl = static_cast(D); - assert(isa(Dcl) && - "Invalid parameter, expected CXXRecordDecl"); + CXXRecordDecl *Rec = cast(static_cast(D)); FieldCollector->FinishClass(); PopDeclContext(); + + // Everything, including inline method definitions, have been parsed. + // Let the consumer know of the new TagDecl definition. + Consumer.HandleTagDeclDefinition(Rec); } //===----------------------------------------------------------------------===//