diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-10 00:22:34 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-10 00:22:34 +0000 |
commit | 94da1587f7d584fc61df793229d197969f204cd9 (patch) | |
tree | 1f09c2f52a72685507e78317b5167f66aa0f66ff /lib/Serialization/ASTReaderDecl.cpp | |
parent | d1fe529b1a17a2422f28f1b938ee70453dc7199d (diff) |
Clean up our handling of Objective-C definitions in AST files. Rather
than having CodeGen check whether a declaration comes from an AST file
(which it shouldn't know or care about), make sure that the AST writer and
reader pass along "interesting" declarations that CodeGen needs to
know about.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139441 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 594dc93325..9210056fbb 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -1393,14 +1393,19 @@ inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) { /// code generation, e.g., inline function definitions, Objective-C /// declarations with metadata, etc. static bool isConsumerInterestedIn(Decl *D) { - if (isa<FileScopeAsmDecl>(D)) + if (isa<FileScopeAsmDecl>(D) || + isa<ObjCProtocolDecl>(D) || + isa<ObjCImplDecl>(D)) return true; if (VarDecl *Var = dyn_cast<VarDecl>(D)) return Var->isFileVarDecl() && Var->isThisDeclarationADefinition() == VarDecl::Definition; if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D)) return Func->doesThisDeclarationHaveABody(); - return isa<ObjCProtocolDecl>(D) || isa<ObjCImplementationDecl>(D); + if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D)) + return Method->hasBody(); + + return false; } /// \brief Get the correct cursor and offset for loading a declaration. @@ -1732,9 +1737,15 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { // AST consumer might need to know about, queue it. // We don't pass it to the consumer immediately because we may be in recursive // loading, and some declarations may still be initializing. - if (isConsumerInterestedIn(D)) - InterestingDecls.push_back(D); - + if (isConsumerInterestedIn(D)) { + if (Consumer) { + DeclGroupRef DG(D); + Consumer->HandleInterestingDecl(DG); + } else { + InterestingDecls.push_back(D); + } + } + return D; } |