if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
if (!VD->isFileVarDecl())
return false;
- } else if (!isa<FunctionDecl>(D))
+ } else if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D))
return false;
// Weak references don't produce any output by themselves.
return true;
}
+ if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D))
+ return Method->hasBody();
+
const VarDecl *VD = cast<VarDecl>(D);
assert(VD->isFileVarDecl() && "Expected file scoped var");
if (I != MethodDefinitions.end())
return I->second;
- if (MD->hasBody() && MD->isFromASTFile()) {
- // MD isn't emitted yet because it comes from PCH.
- CGM.EmitTopLevelDecl(const_cast<ObjCMethodDecl*>(MD));
- assert(MethodDefinitions[MD] && "EmitTopLevelDecl didn't emit the method!");
- return MethodDefinitions[MD];
- }
-
return NULL;
}
/// 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.
// 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;
}
/// decls.
static bool isRequiredDecl(const Decl *D, ASTContext &Context) {
// File scoped assembly or obj-c implementation must be seen.
- if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplementationDecl>(D))
+ if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D))
return true;
return Context.DeclMustBeEmitted(D);