diff options
Diffstat (limited to 'lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 62 |
1 files changed, 53 insertions, 9 deletions
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 002b43f811..159a76d5ef 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -1,9 +1,8 @@ //===--- ASTWriterDecl.cpp - Declaration Serialization --------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -145,8 +144,10 @@ namespace clang { void VisitObjCPropertyDecl(ObjCPropertyDecl *D); void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D); + void VisitOMPAllocateDecl(OMPAllocateDecl *D); void VisitOMPRequiresDecl(OMPRequiresDecl *D); void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D); + void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D); void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D); /// Add an Objective-C type parameter list to the given record. @@ -595,6 +596,16 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { Record.AddSourceLocation(FTSInfo->getPointOfInstantiation()); + if (MemberSpecializationInfo *MemberInfo = + FTSInfo->getMemberSpecializationInfo()) { + Record.push_back(1); + Record.AddDeclRef(MemberInfo->getInstantiatedFrom()); + Record.push_back(MemberInfo->getTemplateSpecializationKind()); + Record.AddSourceLocation(MemberInfo->getPointOfInstantiation()); + } else { + Record.push_back(0); + } + if (D->isCanonicalDecl()) { // Write the template that contains the specializations set. We will // add a FunctionTemplateSpecializationInfo to it when reading. @@ -1110,6 +1121,7 @@ void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) { Record.push_back(D->blockMissingReturnType()); Record.push_back(D->isConversionFromLambda()); Record.push_back(D->doesNotEscape()); + Record.push_back(D->canAvoidCopyToHeap()); Record.push_back(D->capturesCXXThis()); Record.push_back(D->getNumCaptures()); for (const auto &capture : D->captures()) { @@ -1553,6 +1565,9 @@ void ASTDeclWriter::VisitClassScopeFunctionSpecializationDecl( ClassScopeFunctionSpecializationDecl *D) { VisitDecl(D); Record.AddDeclRef(D->getSpecialization()); + Record.push_back(D->hasExplicitTemplateArgs()); + if (D->hasExplicitTemplateArgs()) + Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten()); Code = serialization::DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION; } @@ -1743,10 +1758,22 @@ void ASTDeclWriter::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) { Code = serialization::DECL_OMP_THREADPRIVATE; } +void ASTDeclWriter::VisitOMPAllocateDecl(OMPAllocateDecl *D) { + Record.push_back(D->varlist_size()); + Record.push_back(D->clauselist_size()); + VisitDecl(D); + for (auto *I : D->varlists()) + Record.AddStmt(I); + OMPClauseWriter ClauseWriter(Record); + for (OMPClause *C : D->clauselists()) + ClauseWriter.writeClause(C); + Code = serialization::DECL_OMP_ALLOCATE; +} + void ASTDeclWriter::VisitOMPRequiresDecl(OMPRequiresDecl *D) { Record.push_back(D->clauselist_size()); VisitDecl(D); - OMPClauseWriter ClauseWriter(Record); + OMPClauseWriter ClauseWriter(Record); for (OMPClause *C : D->clauselists()) ClauseWriter.writeClause(C); Code = serialization::DECL_OMP_REQUIRES; @@ -1766,6 +1793,19 @@ void ASTDeclWriter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { Code = serialization::DECL_OMP_DECLARE_REDUCTION; } +void ASTDeclWriter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) { + Record.push_back(D->clauselist_size()); + VisitValueDecl(D); + Record.AddSourceLocation(D->getBeginLoc()); + Record.AddStmt(D->getMapperVarRef()); + Record.AddDeclarationName(D->getVarName()); + Record.AddDeclRef(D->getPrevDeclInScope()); + OMPClauseWriter ClauseWriter(Record); + for (OMPClause *C : D->clauselists()) + ClauseWriter.writeClause(C); + Code = serialization::DECL_OMP_DECLARE_MAPPER; +} + void ASTDeclWriter::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) { VisitVarDecl(D); Code = serialization::DECL_OMP_CAPTUREDEXPR; @@ -2152,7 +2192,8 @@ void ASTWriter::WriteDeclAbbrevs() { Abv = std::make_shared<BitCodeAbbrev>(); Abv->Add(BitCodeAbbrevOp(serialization::EXPR_DECL_REF)); //Stmt - //Expr + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsOMPStructuredBlock + // Expr Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent @@ -2175,7 +2216,8 @@ void ASTWriter::WriteDeclAbbrevs() { Abv = std::make_shared<BitCodeAbbrev>(); Abv->Add(BitCodeAbbrevOp(serialization::EXPR_INTEGER_LITERAL)); //Stmt - //Expr + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsOMPStructuredBlock + // Expr Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent @@ -2193,7 +2235,8 @@ void ASTWriter::WriteDeclAbbrevs() { Abv = std::make_shared<BitCodeAbbrev>(); Abv->Add(BitCodeAbbrevOp(serialization::EXPR_CHARACTER_LITERAL)); //Stmt - //Expr + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsOMPStructuredBlock + // Expr Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent @@ -2211,6 +2254,7 @@ void ASTWriter::WriteDeclAbbrevs() { Abv = std::make_shared<BitCodeAbbrev>(); Abv->Add(BitCodeAbbrevOp(serialization::EXPR_IMPLICIT_CAST)); // Stmt + Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsOMPStructuredBlock // Expr Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //TypeDependent @@ -2259,7 +2303,7 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context, if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D)) return true; - if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) { + if (WritingModule && isPartOfPerModuleInitializer(D)) { // These declarations are part of the module initializer, and are emitted // if and when the module is imported, rather than being emitted eagerly. return false; |