From 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 19 Jan 2019 10:04:05 +0000 Subject: Vendor import of clang trunk r351319 (just before the release_80 branch point): https://llvm.org/svn/llvm-project/cfe/trunk@351319 --- lib/AST/DeclPrinter.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/AST/DeclPrinter.cpp') diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 09e22f19f87a..517851f9eeb1 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -100,6 +100,7 @@ namespace { void VisitUsingDecl(UsingDecl *D); void VisitUsingShadowDecl(UsingShadowDecl *D); void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D); + void VisitOMPRequiresDecl(OMPRequiresDecl *D); void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D); void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D); @@ -422,7 +423,8 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) { // FIXME: Need to be able to tell the DeclPrinter when const char *Terminator = nullptr; - if (isa(*D) || isa(*D)) + if (isa(*D) || isa(*D) || + isa(*D)) Terminator = nullptr; else if (isa(*D) && cast(*D)->hasBody()) Terminator = nullptr; @@ -544,7 +546,7 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) { prettyPrintAttributes(D); if (Expr *Init = D->getInitExpr()) { Out << " = "; - Init->printPretty(Out, nullptr, Policy, Indentation, &Context); + Init->printPretty(Out, nullptr, Policy, Indentation, "\n", &Context); } } @@ -1091,6 +1093,10 @@ void DeclPrinter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { printTemplateParameters(FD->getTemplateParameterList(I)); } VisitRedeclarableTemplateDecl(D); + // Declare target attribute is special one, natural spelling for the pragma + // assumes "ending" construct so print it here. + if (D->getTemplatedDecl()->hasAttr()) + Out << "#pragma omp end declare target\n"; // Never print "instantiations" for deduction guides (they don't really // have them). @@ -1540,6 +1546,15 @@ void DeclPrinter::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) { } } +void DeclPrinter::VisitOMPRequiresDecl(OMPRequiresDecl *D) { + Out << "#pragma omp requires "; + if (!D->clauselist_empty()) { + OMPClausePrinter Printer(Out, Policy); + for (auto I = D->clauselist_begin(), E = D->clauselist_end(); I != E; ++I) + Printer.Visit(*I); + } +} + void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { if (!D->isInvalidDecl()) { Out << "#pragma omp declare reduction ("; -- cgit v1.3