void Transaction::appendUnique(DeclGroupRef DGR) { for (const_iterator I = decls_begin(), E = decls_end(); I != E; ++I) { if (DGR.isNull() || (*I).getAsOpaquePtr() == DGR.getAsOpaquePtr()) return; } m_DeclQueue.push_back(DGR); }
bool UnionToStruct::isTheFirstDecl(const VarDecl *VD) { // always return false if VD is declared in a LinkageSpecDecl, // because the first decl should be implicitly declared union record, // which is handled by rewriteOneRecordDecl const DeclContext *Ctx = VD->getDeclContext(); if (dyn_cast<LinkageSpecDecl>(Ctx)) { return false; } DeclGroupRef DGR; if (const DeclStmt *DS = VarToDeclStmt[VD]) DGR = DS->getDeclGroup(); else DGR = VarToDeclGroup[VD]; TransAssert(!DGR.isNull() && "Bad DeclRefGroup!"); if (DGR.isSingleDecl()) return true; DeclGroupRef::const_iterator I = DGR.begin(); const VarDecl *FirstVD = dyn_cast<VarDecl>(*I); if (!FirstVD) return false; return (VD == FirstVD); }
bool Transaction::comesFromASTReader(DeclGroupRef DGR) const { assert(!DGR.isNull() && "DeclGroupRef is Null!"); if (getCompilationOpts().CodeGenerationForModule) return true; // Take the first/only decl in the group. Decl* D = *DGR.begin(); return D->isFromASTFile(); }
bool DeclCollector::comesFromASTReader(DeclGroupRef DGR) const { assert(!DGR.isNull() && "DeclGroupRef is Null!"); assert(m_CurTransaction && "No current transaction when deserializing"); if (m_CurTransaction->getCompilationOpts().CodeGenerationForModule) return true; // Take the first/only decl in the group. Decl* D = *DGR.begin(); return D->isFromASTFile(); }
bool DeclCollector::HandleTopLevelDecl(DeclGroupRef DGR) { if (!Transform(DGR)) return false; if (DGR.isNull()) return true; assert(m_CurTransaction && "Missing transction"); Transaction::DelayCallInfo DCI(DGR, Transaction::kCCIHandleTopLevelDecl); m_CurTransaction->append(DCI); if (!m_Consumer || getTransaction()->getIssuedDiags() == Transaction::kErrors) return true; if (comesFromASTReader(DGR)) { for (DeclGroupRef::iterator DI = DGR.begin(), DE = DGR.end(); DI != DE; ++DI) { DeclGroupRef SplitDGR(*DI); // FIXME: The special namespace treatment (not sending itself to // CodeGen, but only its content - if the contained decl should be // emitted) works around issue with the static initialization when // having a PCH and loading a library. We don't want to generate // code for the static that will come through the library. // // This will be fixed with the clang::Modules. Make sure we remember. // assert(!getCI()->getLangOpts().Modules && "Please revisit!"); if (NamespaceDecl* ND = dyn_cast<NamespaceDecl>(*DI)) { for (NamespaceDecl::decl_iterator NDI = ND->decls_begin(), EN = ND->decls_end(); NDI != EN; ++NDI) { // Recurse over decls inside the namespace, like // CodeGenModule::EmitNamespace() does. if (!shouldIgnore(*NDI)) m_Consumer->HandleTopLevelDecl(DeclGroupRef(*NDI)); } } else if (!shouldIgnore(*DI)) { m_Consumer->HandleTopLevelDecl(DeclGroupRef(*DI)); } continue; } } else { m_Consumer->HandleTopLevelDecl(DGR); } return true; }