diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 22b3acabd4ea..ac1f89936d0c 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -184,6 +184,7 @@ void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) { D->RedeclLink.getNext() == D && !D->isInvalidDecl() && !D->isReferenced() && + !D->isTopLevelDeclInObjCContainer() && D->getAccess() == AS_none && !D->isModulePrivate() && D->getDeclName().getNameKind() == DeclarationName::Identifier) @@ -234,6 +235,7 @@ void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) { D->RedeclLink.getNext() == D && !D->isInvalidDecl() && !D->isReferenced() && + !D->isTopLevelDeclInObjCContainer() && D->getAccess() == AS_none && !D->isModulePrivate() && !CXXRecordDecl::classofKind(D->getKind()) && @@ -257,6 +259,7 @@ void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) { D->RedeclLink.getNext() == D && !D->isInvalidDecl() && !D->isReferenced() && + !D->isTopLevelDeclInObjCContainer() && D->getAccess() == AS_none && !D->isModulePrivate() && !CXXRecordDecl::classofKind(D->getKind()) && @@ -627,6 +630,7 @@ void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) { !D->isUsed(false) && !D->isInvalidDecl() && !D->isReferenced() && + !D->isTopLevelDeclInObjCContainer() && !D->isModulePrivate() && !D->getBitWidth() && !D->hasInClassInitializer() && @@ -679,6 +683,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) { !D->isUsed(false) && !D->isInvalidDecl() && !D->isReferenced() && + !D->isTopLevelDeclInObjCContainer() && D->getAccess() == AS_none && !D->isModulePrivate() && D->getDeclName().getNameKind() == DeclarationName::Identifier && diff --git a/clang/test/Index/annotate-toplevel-in-objccontainer.m b/clang/test/Index/annotate-toplevel-in-objccontainer.m index 61c0f04a1b1f..cd1903b7f88d 100644 --- a/clang/test/Index/annotate-toplevel-in-objccontainer.m +++ b/clang/test/Index/annotate-toplevel-in-objccontainer.m @@ -27,7 +27,7 @@ static int glob2; // CHECK-IMPL: Identifier: "meth1" [14:8 - 14:13] ObjCInstanceMethodDecl=meth1:14:1 (Definition) // CHECK-IMPL: Identifier: "meth2" [15:8 - 15:13] ObjCInstanceMethodDecl=meth2:15:1 (Definition) -// RUN: c-index-test -test-annotate-tokens=%s.h:5:1:7:1 %s -include %t.h \ +// RUN: c-index-test -test-annotate-tokens=%s.h:7:1:9:1 %s -include %t.h \ // RUN: | FileCheck -check-prefix=PCH %s -// CHECK-PCH: Identifier: "meth1" [5:8 - 5:13] ObjCInstanceMethodDecl=meth1:5:1 -// CHECK-PCH: Identifier: "meth2" [6:8 - 6:13] ObjCInstanceMethodDecl=meth2:6:1 +// CHECK-PCH: Identifier: "meth1" [7:8 - 7:13] ObjCInstanceMethodDecl=meth1:7:1 +// CHECK-PCH: Identifier: "meth2" [8:8 - 8:13] ObjCInstanceMethodDecl=meth2:8:1 diff --git a/clang/test/Index/annotate-toplevel-in-objccontainer.m.h b/clang/test/Index/annotate-toplevel-in-objccontainer.m.h index 191a10cf9359..fe507fc0b7cd 100644 --- a/clang/test/Index/annotate-toplevel-in-objccontainer.m.h +++ b/clang/test/Index/annotate-toplevel-in-objccontainer.m.h @@ -2,6 +2,8 @@ void funcPCH1(int); void funcPCH2(int); +enum E { Cake }; + -(void)meth1; -(void)meth2; @end