@@ -495,6 +495,7 @@ namespace clang {
495495 Expected<InheritedConstructor>
496496 ImportInheritedConstructor (const InheritedConstructor &From);
497497
498+ // Use for allocating string for newly imported object.
498499 StringRef ImportASTStringRef (StringRef FromStr);
499500 Error ImportConstraintSatisfaction (const ASTConstraintSatisfaction &FromSat,
500501 ConstraintSatisfaction &ToSat);
@@ -7021,6 +7022,62 @@ ASTNodeImporter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
70217022 return ToFunc;
70227023}
70237024
7025+ ExpectedDecl ASTNodeImporter::VisitConceptDecl (ConceptDecl *D) {
7026+ DeclContext *DC, *LexicalDC;
7027+ Error Err = ImportDeclContext (D, DC, LexicalDC);
7028+ auto LocationOrErr = importChecked (Err, D->getLocation ());
7029+ auto NameDeclOrErr = importChecked (Err, D->getDeclName ());
7030+ auto ToTemplateParameters = importChecked (Err, D->getTemplateParameters ());
7031+ auto ConstraintExpr = importChecked (Err, D->getConstraintExpr ());
7032+ if (Err)
7033+ return std::move (Err);
7034+
7035+ ConceptDecl *To;
7036+ if (GetImportedOrCreateDecl (To, D, Importer.getToContext (), DC, LocationOrErr,
7037+ NameDeclOrErr, ToTemplateParameters,
7038+ ConstraintExpr))
7039+ return To;
7040+ To->setLexicalDeclContext (LexicalDC);
7041+ LexicalDC->addDeclInternal (To);
7042+ return To;
7043+ }
7044+
7045+ ExpectedDecl
7046+ ASTNodeImporter::VisitRequiresExprBodyDecl (RequiresExprBodyDecl *D) {
7047+ DeclContext *DC, *LexicalDC;
7048+ Error Err = ImportDeclContext (D, DC, LexicalDC);
7049+ auto RequiresLoc = importChecked (Err, D->getLocation ());
7050+ if (Err)
7051+ return std::move (Err);
7052+
7053+ RequiresExprBodyDecl *To;
7054+ if (GetImportedOrCreateDecl (To, D, Importer.getToContext (), DC, RequiresLoc))
7055+ return To;
7056+ To->setLexicalDeclContext (LexicalDC);
7057+ LexicalDC->addDeclInternal (To);
7058+ return To;
7059+ }
7060+
7061+ ExpectedDecl ASTNodeImporter::VisitImplicitConceptSpecializationDecl (
7062+ ImplicitConceptSpecializationDecl *D) {
7063+ DeclContext *DC, *LexicalDC;
7064+ Error Err = ImportDeclContext (D, DC, LexicalDC);
7065+ auto ToSL = importChecked (Err, D->getLocation ());
7066+ if (Err)
7067+ return std::move (Err);
7068+
7069+ SmallVector<TemplateArgument, 2 > ToArgs (D->getTemplateArguments ().size ());
7070+ if (Error Err = ImportTemplateArguments (D->getTemplateArguments (), ToArgs))
7071+ return std::move (Err);
7072+
7073+ ImplicitConceptSpecializationDecl *To;
7074+ if (GetImportedOrCreateDecl (To, D, Importer.getToContext (), DC, ToSL, ToArgs))
7075+ return To;
7076+ To->setLexicalDeclContext (LexicalDC);
7077+ LexicalDC->addDeclInternal (To);
7078+ return To;
7079+ }
7080+
70247081// ----------------------------------------------------------------------------
70257082// Import Statements
70267083// ----------------------------------------------------------------------------
@@ -7545,102 +7602,6 @@ ExpectedStmt ASTNodeImporter::VisitExpr(Expr *E) {
75457602 return make_error<ASTImportError>(ASTImportError::UnsupportedConstruct);
75467603}
75477604
7548- ExpectedStmt ASTNodeImporter::VisitRequiresExpr (RequiresExpr* E) {
7549- Error Err = Error::success ();
7550- auto RequiresKWLoc = importChecked (Err, E->getRequiresKWLoc ());
7551- auto RParenLoc = importChecked (Err, E->getRParenLoc ());
7552- auto RBraceLoc = importChecked (Err, E->getRBraceLoc ());
7553-
7554- auto Body = importChecked (Err, E->getBody ());
7555- auto LParenLoc = importChecked (Err, E->getLParenLoc ());
7556- if (Err)
7557- return std::move (Err);
7558- SmallVector<ParmVarDecl*, 4 > LocalParameters (E->getLocalParameters ().size ());
7559- if (Error Err = ImportArrayChecked (E->getLocalParameters (), LocalParameters.begin ()))
7560- return std::move (Err);
7561- SmallVector<concepts::Requirement *, 4 > Requirements (
7562- E->getRequirements ().size ());
7563- if (Error Err = ImportArrayChecked (E->getRequirements (), Requirements.begin ()))
7564- return std::move (Err);
7565- return RequiresExpr::Create (Importer.getToContext (), RequiresKWLoc, Body,
7566- LParenLoc, LocalParameters, RParenLoc,
7567- Requirements, RBraceLoc);
7568- }
7569-
7570- ExpectedDecl ASTNodeImporter::VisitRequiresExprBodyDecl (RequiresExprBodyDecl* D) {
7571- DeclContext *DC, *LexicalDC;
7572- Error Err = ImportDeclContext (D, DC, LexicalDC);
7573- auto RequiresLoc = importChecked (Err, D->getLocation ());
7574- if (Err)
7575- return std::move (Err);
7576-
7577- RequiresExprBodyDecl *To;
7578- if (GetImportedOrCreateDecl (To, D, Importer.getToContext (), DC, RequiresLoc))
7579- return To;
7580- To->setLexicalDeclContext (LexicalDC);
7581- LexicalDC->addDeclInternal (To);
7582- return To;
7583- }
7584-
7585- ExpectedStmt ASTNodeImporter::VisitConceptSpecializationExpr (ConceptSpecializationExpr* E) {
7586- Error Err = Error::success ();
7587- auto CL = importChecked (Err,E->getConceptReference ());
7588- auto CSD = importChecked (Err,E->getSpecializationDecl ());
7589- if (Err)
7590- return std::move (Err);
7591- if (E->isValueDependent ())
7592- return ConceptSpecializationExpr::Create (
7593- Importer.getToContext (), CL,
7594- const_cast <ImplicitConceptSpecializationDecl *>(CSD), nullptr );
7595- ConstraintSatisfaction Satisfaction;
7596- if (Error Err =
7597- ImportConstraintSatisfaction (E->getSatisfaction (), Satisfaction))
7598- return std::move (Err);
7599- return ConceptSpecializationExpr::Create (
7600- Importer.getToContext (), CL,
7601- const_cast <ImplicitConceptSpecializationDecl *>(CSD), &Satisfaction);
7602- }
7603-
7604- ExpectedDecl ASTNodeImporter::VisitConceptDecl (ConceptDecl* D) {
7605- DeclContext *DC, *LexicalDC;
7606- Error Err = ImportDeclContext (D, DC, LexicalDC);
7607- auto LocationOrErr = importChecked (Err, D->getLocation ());
7608- auto NameDeclOrErr = importChecked (Err,D->getDeclName ());
7609- auto ToTemplateParameters = importChecked (Err, D->getTemplateParameters ());
7610- auto ConstraintExpr = importChecked (Err, D->getConstraintExpr ());
7611- if (Err)
7612- return std::move (Err);
7613-
7614- ConceptDecl *To;
7615- if (GetImportedOrCreateDecl (To, D,
7616- Importer.getToContext (), DC, LocationOrErr,
7617- NameDeclOrErr, ToTemplateParameters,
7618- ConstraintExpr))
7619- return To;
7620- To->setLexicalDeclContext (LexicalDC);
7621- LexicalDC->addDeclInternal (To);
7622- return To;
7623- }
7624-
7625- ExpectedDecl ASTNodeImporter::VisitImplicitConceptSpecializationDecl (ImplicitConceptSpecializationDecl* D) {
7626- DeclContext *DC, *LexicalDC;
7627- Error Err = ImportDeclContext (D, DC, LexicalDC);
7628- auto ToSL = importChecked (Err, D->getLocation ());
7629- if (Err)
7630- return std::move (Err);
7631-
7632- SmallVector<TemplateArgument,2 > ToArgs (D->getTemplateArguments ().size ());
7633- if (Error Err = ImportTemplateArguments (D->getTemplateArguments (), ToArgs))
7634- return std::move (Err);
7635-
7636- ImplicitConceptSpecializationDecl *To;
7637- if (GetImportedOrCreateDecl (To, D, Importer.getToContext (), DC, ToSL, ToArgs))
7638- return To;
7639- To->setLexicalDeclContext (LexicalDC);
7640- LexicalDC->addDeclInternal (To);
7641- return To;
7642- }
7643-
76447605ExpectedStmt ASTNodeImporter::VisitSourceLocExpr (SourceLocExpr *E) {
76457606 Error Err = Error::success ();
76467607 auto ToType = importChecked (Err, E->getType ());
@@ -9336,6 +9297,50 @@ ExpectedStmt ASTNodeImporter::VisitCXXFoldExpr(CXXFoldExpr *E) {
93369297 ToEllipsisLoc, ToRHS, ToRParenLoc, E->getNumExpansions ());
93379298}
93389299
9300+ ExpectedStmt ASTNodeImporter::VisitRequiresExpr (RequiresExpr *E) {
9301+ Error Err = Error::success ();
9302+ auto RequiresKWLoc = importChecked (Err, E->getRequiresKWLoc ());
9303+ auto RParenLoc = importChecked (Err, E->getRParenLoc ());
9304+ auto RBraceLoc = importChecked (Err, E->getRBraceLoc ());
9305+
9306+ auto Body = importChecked (Err, E->getBody ());
9307+ auto LParenLoc = importChecked (Err, E->getLParenLoc ());
9308+ if (Err)
9309+ return std::move (Err);
9310+ SmallVector<ParmVarDecl *, 4 > LocalParameters (E->getLocalParameters ().size ());
9311+ if (Error Err =
9312+ ImportArrayChecked (E->getLocalParameters (), LocalParameters.begin ()))
9313+ return std::move (Err);
9314+ SmallVector<concepts::Requirement *, 4 > Requirements (
9315+ E->getRequirements ().size ());
9316+ if (Error Err =
9317+ ImportArrayChecked (E->getRequirements (), Requirements.begin ()))
9318+ return std::move (Err);
9319+ return RequiresExpr::Create (Importer.getToContext (), RequiresKWLoc, Body,
9320+ LParenLoc, LocalParameters, RParenLoc,
9321+ Requirements, RBraceLoc);
9322+ }
9323+
9324+ ExpectedStmt
9325+ ASTNodeImporter::VisitConceptSpecializationExpr (ConceptSpecializationExpr *E) {
9326+ Error Err = Error::success ();
9327+ auto CL = importChecked (Err, E->getConceptReference ());
9328+ auto CSD = importChecked (Err, E->getSpecializationDecl ());
9329+ if (Err)
9330+ return std::move (Err);
9331+ if (E->isValueDependent ())
9332+ return ConceptSpecializationExpr::Create (
9333+ Importer.getToContext (), CL,
9334+ const_cast <ImplicitConceptSpecializationDecl *>(CSD), nullptr );
9335+ ConstraintSatisfaction Satisfaction;
9336+ if (Error Err =
9337+ ImportConstraintSatisfaction (E->getSatisfaction (), Satisfaction))
9338+ return std::move (Err);
9339+ return ConceptSpecializationExpr::Create (
9340+ Importer.getToContext (), CL,
9341+ const_cast <ImplicitConceptSpecializationDecl *>(CSD), &Satisfaction);
9342+ }
9343+
93399344Error ASTNodeImporter::ImportOverriddenMethods (CXXMethodDecl *ToMethod,
93409345 CXXMethodDecl *FromMethod) {
93419346 Error ImportErrors = Error::success ();
0 commit comments