]> granicus.if.org Git - clang/commitdiff
When in C++, invoke ASTConsumer::HandleTagDeclDefinition in Sema::ActOnFinishCXXClassDef,
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 9 Aug 2008 00:58:37 +0000 (00:58 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 9 Aug 2008 00:58:37 +0000 (00:58 +0000)
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

lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp

index 3b4ad02dea5ea0222a241873b527d494cb9108d3..a96195e525f14edca5e728f8ca3b16665b18854e 100644 (file)
@@ -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<CXXRecordDecl>(Record))
+      Consumer.HandleTagDeclDefinition(Record);
   } else {
     ObjCIvarDecl **ClsFields = reinterpret_cast<ObjCIvarDecl**>(&RecFields[0]);
     if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(EnclosingDecl))
index 87efe2ba4b18b40bc6698dc5aeb02da83a57bf98..554e7426694543c637b1f794181628932b2022db 100644 (file)
@@ -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<Decl *>(D);
-  assert(isa<CXXRecordDecl>(Dcl) &&
-         "Invalid parameter, expected CXXRecordDecl");
+  CXXRecordDecl *Rec = cast<CXXRecordDecl>(static_cast<Decl *>(D));
   FieldCollector->FinishClass();
   PopDeclContext();
+
+  // Everything, including inline method definitions, have been parsed.
+  // Let the consumer know of the new TagDecl definition.
+  Consumer.HandleTagDeclDefinition(Rec);
 }
 
 //===----------------------------------------------------------------------===//