• Home
  • Raw
  • Download

Lines Matching refs:OS

188     virtual void writeAccessors(raw_ostream &OS) const = 0;
189 virtual void writeAccessorDefinitions(raw_ostream &OS) const {} in writeAccessorDefinitions()
190 virtual void writeASTVisitorTraversal(raw_ostream &OS) const {} in writeASTVisitorTraversal()
191 virtual void writeCloneArgs(raw_ostream &OS) const = 0;
192 virtual void writeTemplateInstantiationArgs(raw_ostream &OS) const = 0;
193 virtual void writeTemplateInstantiation(raw_ostream &OS) const {} in writeTemplateInstantiation()
194 virtual void writeCtorBody(raw_ostream &OS) const {} in writeCtorBody()
195 virtual void writeCtorInitializers(raw_ostream &OS) const = 0;
196 virtual void writeCtorDefaultInitializers(raw_ostream &OS) const = 0;
197 virtual void writeCtorParameters(raw_ostream &OS) const = 0;
198 virtual void writeDeclarations(raw_ostream &OS) const = 0;
199 virtual void writePCHReadArgs(raw_ostream &OS) const = 0;
200 virtual void writePCHReadDecls(raw_ostream &OS) const = 0;
201 virtual void writePCHWrite(raw_ostream &OS) const = 0;
202 virtual void writeValue(raw_ostream &OS) const = 0;
203 virtual void writeDump(raw_ostream &OS) const = 0;
204 virtual void writeDumpChildren(raw_ostream &OS) const {} in writeDumpChildren()
205 virtual void writeHasChildren(raw_ostream &OS) const { OS << "false"; } in writeHasChildren()
210 virtual void writeImplicitCtorArgs(raw_ostream &OS) const { in writeImplicitCtorArgs()
211 OS << getUpperName(); in writeImplicitCtorArgs()
225 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
226 OS << " " << type << " get" << getUpperName() << "() const {\n"; in writeAccessors()
227 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
228 OS << " }"; in writeAccessors()
230 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
231 OS << getLowerName(); in writeCloneArgs()
233 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
234 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
236 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
237 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
239 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
240 OS << getLowerName() << "()"; in writeCtorDefaultInitializers()
242 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
243 OS << type << " " << getUpperName(); in writeCtorParameters()
245 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
246 OS << type << " " << getLowerName() << ";"; in writeDeclarations()
248 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
250 OS << " " << type << " " << getLowerName() << " = " << read << ";\n"; in writePCHReadDecls()
252 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
253 OS << getLowerName(); in writePCHReadArgs()
255 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
256 OS << " " << WritePCHRecord(type, "SA->get" + in writePCHWrite()
259 void writeValue(raw_ostream &OS) const override { in writeValue()
261 OS << "\" << get" << getUpperName() in writeValue()
264 OS << "\" << get" << getUpperName() << "()->getName() << \""; in writeValue()
266 OS << "\" << get" << getUpperName() << "().getAsString() << \""; in writeValue()
268 OS << "\" << get" << getUpperName() << "() << \""; in writeValue()
271 void writeDump(raw_ostream &OS) const override { in writeDump()
273 OS << " OS << \" \";\n"; in writeDump()
274 OS << " dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; in writeDump()
276 OS << " OS << \" \" << SA->get" << getUpperName() in writeDump()
279 OS << " OS << \" \" << SA->get" << getUpperName() in writeDump()
282 OS << " if (SA->get" << getUpperName() << "()) OS << \" " in writeDump()
285 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n"; in writeDump()
300 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
301 SimpleArgument::writeAccessors(OS); in writeAccessors()
303 OS << "\n\n static const " << getType() << " Default" << getUpperName() in writeAccessors()
314 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
315 OS << " llvm::StringRef get" << getUpperName() << "() const {\n"; in writeAccessors()
316 OS << " return llvm::StringRef(" << getLowerName() << ", " in writeAccessors()
318 OS << " }\n"; in writeAccessors()
319 OS << " unsigned get" << getUpperName() << "Length() const {\n"; in writeAccessors()
320 OS << " return " << getLowerName() << "Length;\n"; in writeAccessors()
321 OS << " }\n"; in writeAccessors()
322 OS << " void set" << getUpperName() in writeAccessors()
324 OS << " " << getLowerName() << "Length = S.size();\n"; in writeAccessors()
325 OS << " this->" << getLowerName() << " = new (C, 1) char [" in writeAccessors()
327 OS << " std::memcpy(this->" << getLowerName() << ", S.data(), " in writeAccessors()
329 OS << " }"; in writeAccessors()
331 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
332 OS << "get" << getUpperName() << "()"; in writeCloneArgs()
334 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
335 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
337 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
338 OS << " std::memcpy(" << getLowerName() << ", " << getUpperName() in writeCtorBody()
341 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
342 OS << getLowerName() << "Length(" << getUpperName() << ".size())," in writeCtorInitializers()
346 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
347 OS << getLowerName() << "Length(0)," << getLowerName() << "(0)"; in writeCtorDefaultInitializers()
349 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
350 OS << "llvm::StringRef " << getUpperName(); in writeCtorParameters()
352 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
353 OS << "unsigned " << getLowerName() << "Length;\n"; in writeDeclarations()
354 OS << "char *" << getLowerName() << ";"; in writeDeclarations()
356 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
357 OS << " std::string " << getLowerName() in writePCHReadDecls()
360 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
361 OS << getLowerName(); in writePCHReadArgs()
363 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
364 OS << " AddString(SA->get" << getUpperName() << "(), Record);\n"; in writePCHWrite()
366 void writeValue(raw_ostream &OS) const override { in writeValue()
367 OS << "\\\"\" << get" << getUpperName() << "() << \"\\\""; in writeValue()
369 void writeDump(raw_ostream &OS) const override { in writeDump()
370 OS << " OS << \" \\\"\" << SA->get" << getUpperName() in writeDump()
381 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
382 OS << " bool is" << getUpperName() << "Dependent() const;\n"; in writeAccessors()
384 OS << " unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n"; in writeAccessors()
386 OS << " bool is" << getUpperName() << "Expr() const {\n"; in writeAccessors()
387 OS << " return is" << getLowerName() << "Expr;\n"; in writeAccessors()
388 OS << " }\n"; in writeAccessors()
390 OS << " Expr *get" << getUpperName() << "Expr() const {\n"; in writeAccessors()
391 OS << " assert(is" << getLowerName() << "Expr);\n"; in writeAccessors()
392 OS << " return " << getLowerName() << "Expr;\n"; in writeAccessors()
393 OS << " }\n"; in writeAccessors()
395 OS << " TypeSourceInfo *get" << getUpperName() << "Type() const {\n"; in writeAccessors()
396 OS << " assert(!is" << getLowerName() << "Expr);\n"; in writeAccessors()
397 OS << " return " << getLowerName() << "Type;\n"; in writeAccessors()
398 OS << " }"; in writeAccessors()
400 void writeAccessorDefinitions(raw_ostream &OS) const override { in writeAccessorDefinitions()
401 OS << "bool " << getAttrName() << "Attr::is" << getUpperName() in writeAccessorDefinitions()
403 OS << " if (is" << getLowerName() << "Expr)\n"; in writeAccessorDefinitions()
404 OS << " return " << getLowerName() << "Expr && (" << getLowerName() in writeAccessorDefinitions()
407 OS << " else\n"; in writeAccessorDefinitions()
408 OS << " return " << getLowerName() in writeAccessorDefinitions()
410 OS << "}\n"; in writeAccessorDefinitions()
417 OS << "unsigned " << getAttrName() << "Attr::get" << getUpperName() in writeAccessorDefinitions()
419 OS << " assert(!is" << getUpperName() << "Dependent());\n"; in writeAccessorDefinitions()
420 OS << " if (is" << getLowerName() << "Expr)\n"; in writeAccessorDefinitions()
421 OS << " return (" << getLowerName() << "Expr ? " << getLowerName() in writeAccessorDefinitions()
424 OS << " else\n"; in writeAccessorDefinitions()
425 OS << " return 0; // FIXME\n"; in writeAccessorDefinitions()
426 OS << "}\n"; in writeAccessorDefinitions()
428 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
429 OS << "is" << getLowerName() << "Expr, is" << getLowerName() in writeCloneArgs()
434 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
438 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
439 OS << " if (is" << getLowerName() << "Expr)\n"; in writeCtorBody()
440 OS << " " << getLowerName() << "Expr = reinterpret_cast<Expr *>(" in writeCtorBody()
442 OS << " else\n"; in writeCtorBody()
443 OS << " " << getLowerName() in writeCtorBody()
447 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
448 OS << "is" << getLowerName() << "Expr(Is" << getUpperName() << "Expr)"; in writeCtorInitializers()
450 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
451 OS << "is" << getLowerName() << "Expr(false)"; in writeCtorDefaultInitializers()
453 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
454 OS << "bool Is" << getUpperName() << "Expr, void *" << getUpperName(); in writeCtorParameters()
456 void writeImplicitCtorArgs(raw_ostream &OS) const override { in writeImplicitCtorArgs()
457 OS << "Is" << getUpperName() << "Expr, " << getUpperName(); in writeImplicitCtorArgs()
459 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
460 OS << "bool is" << getLowerName() << "Expr;\n"; in writeDeclarations()
461 OS << "union {\n"; in writeDeclarations()
462 OS << "Expr *" << getLowerName() << "Expr;\n"; in writeDeclarations()
463 OS << "TypeSourceInfo *" << getLowerName() << "Type;\n"; in writeDeclarations()
464 OS << "};"; in writeDeclarations()
466 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
467 OS << "is" << getLowerName() << "Expr, " << getLowerName() << "Ptr"; in writePCHReadArgs()
469 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
470 OS << " bool is" << getLowerName() << "Expr = Record[Idx++];\n"; in writePCHReadDecls()
471 OS << " void *" << getLowerName() << "Ptr;\n"; in writePCHReadDecls()
472 OS << " if (is" << getLowerName() << "Expr)\n"; in writePCHReadDecls()
473 OS << " " << getLowerName() << "Ptr = ReadExpr(F);\n"; in writePCHReadDecls()
474 OS << " else\n"; in writePCHReadDecls()
475 OS << " " << getLowerName() in writePCHReadDecls()
478 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
479 OS << " Record.push_back(SA->is" << getUpperName() << "Expr());\n"; in writePCHWrite()
480 OS << " if (SA->is" << getUpperName() << "Expr())\n"; in writePCHWrite()
481 OS << " AddStmt(SA->get" << getUpperName() << "Expr());\n"; in writePCHWrite()
482 OS << " else\n"; in writePCHWrite()
483 OS << " AddTypeSourceInfo(SA->get" << getUpperName() in writePCHWrite()
486 void writeValue(raw_ostream &OS) const override { in writeValue()
487 OS << "\";\n"; in writeValue()
488 OS << " assert(is" << getLowerName() << "Expr && " << getLowerName() in writeValue()
490 OS << " " << getLowerName() << "Expr->printPretty(OS, 0, Policy);\n"; in writeValue()
491 OS << " OS << \""; in writeValue()
493 void writeDump(raw_ostream &OS) const override { in writeDump()
495 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
496 OS << " if (SA->is" << getUpperName() << "Expr()) {\n"; in writeDumpChildren()
497 OS << " lastChild();\n"; in writeDumpChildren()
498 OS << " dumpStmt(SA->get" << getUpperName() << "Expr());\n"; in writeDumpChildren()
499 OS << " } else\n"; in writeDumpChildren()
500 OS << " dumpType(SA->get" << getUpperName() in writeDumpChildren()
503 void writeHasChildren(raw_ostream &OS) const override { in writeHasChildren()
504 OS << "SA->is" << getUpperName() << "Expr()"; in writeHasChildren()
518 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
523 OS << " typedef " << Type << "* " << IteratorType << ";\n"; in writeAccessors()
524 OS << " " << IteratorType << " " << BeginFn << " const {" in writeAccessors()
526 OS << " " << IteratorType << " " << EndFn << " const {" in writeAccessors()
528 OS << " unsigned " << getLowerName() << "_size() const {" in writeAccessors()
530 OS << " llvm::iterator_range<" << IteratorType << "> " << RangeName in writeAccessors()
534 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
535 OS << ArgName << ", " << ArgSizeName; in writeCloneArgs()
537 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
539 OS << "A->" << getLowerName() << "_begin(), " in writeTemplateInstantiationArgs()
542 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
543 OS << " std::copy(" << getUpperName() << ", " << getUpperName() in writeCtorBody()
546 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
547 OS << ArgSizeName << "(" << getUpperName() << "Size), " in writeCtorInitializers()
551 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
552 OS << ArgSizeName << "(0), " << ArgName << "(nullptr)"; in writeCtorDefaultInitializers()
554 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
555 OS << getType() << " *" << getUpperName() << ", unsigned " in writeCtorParameters()
558 void writeImplicitCtorArgs(raw_ostream &OS) const override { in writeImplicitCtorArgs()
559 OS << getUpperName() << ", " << getUpperName() << "Size"; in writeImplicitCtorArgs()
561 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
562 OS << " unsigned " << ArgSizeName << ";\n"; in writeDeclarations()
563 OS << " " << getType() << " *" << ArgName << ";"; in writeDeclarations()
565 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
566 OS << " unsigned " << getLowerName() << "Size = Record[Idx++];\n"; in writePCHReadDecls()
567 OS << " SmallVector<" << Type << ", 4> " << getLowerName() in writePCHReadDecls()
569 OS << " " << getLowerName() << ".reserve(" << getLowerName() in writePCHReadDecls()
571 OS << " for (unsigned i = " << getLowerName() << "Size; i; --i)\n"; in writePCHReadDecls()
574 OS << " " << getLowerName() << ".push_back(" << read << ");\n"; in writePCHReadDecls()
576 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
577 OS << getLowerName() << ".data(), " << getLowerName() << "Size"; in writePCHReadArgs()
579 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
580 OS << " Record.push_back(SA->" << getLowerName() << "_size());\n"; in writePCHWrite()
581 OS << " for (auto &Val : SA->" << RangeName << "())\n"; in writePCHWrite()
582 OS << " " << WritePCHRecord(Type, "Val"); in writePCHWrite()
584 void writeValue(raw_ostream &OS) const override { in writeValue()
585 OS << "\";\n"; in writeValue()
586 OS << " bool isFirst = true;\n" in writeValue()
592 OS << " OS << \""; in writeValue()
594 void writeDump(raw_ostream &OS) const override { in writeDump()
595 OS << " for (const auto &Val : SA->" << RangeName << "())\n"; in writeDump()
596 OS << " OS << \" \" << Val;\n"; in writeDump()
631 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
632 OS << " " << type << " get" << getUpperName() << "() const {\n"; in writeAccessors()
633 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
634 OS << " }"; in writeAccessors()
636 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
637 OS << getLowerName(); in writeCloneArgs()
639 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
640 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
642 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
643 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
645 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
646 OS << getLowerName() << "(" << type << "(0))"; in writeCtorDefaultInitializers()
648 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
649 OS << type << " " << getUpperName(); in writeCtorParameters()
651 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
657 OS << "public:\n"; in writeDeclarations()
658 OS << " enum " << type << " {\n"; in writeDeclarations()
660 OS << " " << *i << ",\n"; in writeDeclarations()
661 OS << " " << *e << "\n"; in writeDeclarations()
662 OS << " };\n"; in writeDeclarations()
663 OS << "private:\n"; in writeDeclarations()
664 OS << " " << type << " " << getLowerName() << ";"; in writeDeclarations()
666 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
667 OS << " " << getAttrName() << "Attr::" << type << " " << getLowerName() in writePCHReadDecls()
671 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
672 OS << getLowerName(); in writePCHReadArgs()
674 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
675 OS << "Record.push_back(SA->get" << getUpperName() << "());\n"; in writePCHWrite()
677 void writeValue(raw_ostream &OS) const override { in writeValue()
678 OS << "\" << get" << getUpperName() << "() << \""; in writeValue()
680 void writeDump(raw_ostream &OS) const override { in writeDump()
681 OS << " switch(SA->get" << getUpperName() << "()) {\n"; in writeDump()
683 OS << " case " << getAttrName() << "Attr::" << I << ":\n"; in writeDump()
684 OS << " OS << \" " << I << "\";\n"; in writeDump()
685 OS << " break;\n"; in writeDump()
687 OS << " }\n"; in writeDump()
690 void writeConversion(raw_ostream &OS) const { in writeConversion()
691 OS << " static bool ConvertStrTo" << type << "(StringRef Val, "; in writeConversion()
692 OS << type << " &Out) {\n"; in writeConversion()
693 OS << " Optional<" << type << "> R = llvm::StringSwitch<Optional<"; in writeConversion()
694 OS << type << ">>(Val)\n"; in writeConversion()
696 OS << " .Case(\"" << values[I] << "\", "; in writeConversion()
697 OS << getAttrName() << "Attr::" << enums[I] << ")\n"; in writeConversion()
699 OS << " .Default(Optional<" << type << ">());\n"; in writeConversion()
700 OS << " if (R) {\n"; in writeConversion()
701 OS << " Out = *R;\n return true;\n }\n"; in writeConversion()
702 OS << " return false;\n"; in writeConversion()
703 OS << " }\n"; in writeConversion()
726 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
732 OS << "public:\n"; in writeDeclarations()
733 OS << " enum " << type << " {\n"; in writeDeclarations()
735 OS << " " << *i << ",\n"; in writeDeclarations()
736 OS << " " << *e << "\n"; in writeDeclarations()
737 OS << " };\n"; in writeDeclarations()
738 OS << "private:\n"; in writeDeclarations()
740 VariadicArgument::writeDeclarations(OS); in writeDeclarations()
742 void writeDump(raw_ostream &OS) const override { in writeDump()
743 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writeDump()
746 OS << " switch(*I) {\n"; in writeDump()
748 OS << " case " << getAttrName() << "Attr::" << UI << ":\n"; in writeDump()
749 OS << " OS << \" " << UI << "\";\n"; in writeDump()
750 OS << " break;\n"; in writeDump()
752 OS << " }\n"; in writeDump()
753 OS << " }\n"; in writeDump()
755 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
756 OS << " unsigned " << getLowerName() << "Size = Record[Idx++];\n"; in writePCHReadDecls()
757 OS << " SmallVector<" << QualifiedTypeName << ", 4> " << getLowerName() in writePCHReadDecls()
759 OS << " " << getLowerName() << ".reserve(" << getLowerName() in writePCHReadDecls()
761 OS << " for (unsigned i = " << getLowerName() << "Size; i; --i)\n"; in writePCHReadDecls()
762 OS << " " << getLowerName() << ".push_back(" << "static_cast<" in writePCHReadDecls()
765 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
766 OS << " Record.push_back(SA->" << getLowerName() << "_size());\n"; in writePCHWrite()
767 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writePCHWrite()
770 OS << " " << WritePCHRecord(QualifiedTypeName, "(*i)"); in writePCHWrite()
772 void writeConversion(raw_ostream &OS) const { in writeConversion()
773 OS << " static bool ConvertStrTo" << type << "(StringRef Val, "; in writeConversion()
774 OS << type << " &Out) {\n"; in writeConversion()
775 OS << " Optional<" << type << "> R = llvm::StringSwitch<Optional<"; in writeConversion()
776 OS << type << ">>(Val)\n"; in writeConversion()
778 OS << " .Case(\"" << values[I] << "\", "; in writeConversion()
779 OS << getAttrName() << "Attr::" << enums[I] << ")\n"; in writeConversion()
781 OS << " .Default(Optional<" << type << ">());\n"; in writeConversion()
782 OS << " if (R) {\n"; in writeConversion()
783 OS << " Out = *R;\n return true;\n }\n"; in writeConversion()
784 OS << " return false;\n"; in writeConversion()
785 OS << " }\n"; in writeConversion()
795 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
796 OS << " VersionTuple get" << getUpperName() << "() const {\n"; in writeAccessors()
797 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
798 OS << " }\n"; in writeAccessors()
799 OS << " void set" << getUpperName() in writeAccessors()
801 OS << " " << getLowerName() << " = V;\n"; in writeAccessors()
802 OS << " }"; in writeAccessors()
804 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
805 OS << "get" << getUpperName() << "()"; in writeCloneArgs()
807 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
808 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
810 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
811 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
813 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
814 OS << getLowerName() << "()"; in writeCtorDefaultInitializers()
816 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
817 OS << "VersionTuple " << getUpperName(); in writeCtorParameters()
819 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
820 OS << "VersionTuple " << getLowerName() << ";\n"; in writeDeclarations()
822 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
823 OS << " VersionTuple " << getLowerName() in writePCHReadDecls()
826 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
827 OS << getLowerName(); in writePCHReadArgs()
829 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
830 OS << " AddVersionTuple(SA->get" << getUpperName() << "(), Record);\n"; in writePCHWrite()
832 void writeValue(raw_ostream &OS) const override { in writeValue()
833 OS << getLowerName() << "=\" << get" << getUpperName() << "() << \""; in writeValue()
835 void writeDump(raw_ostream &OS) const override { in writeDump()
836 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n"; in writeDump()
846 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
847 OS << " if (!" in writeASTVisitorTraversal()
849 OS << " return false;\n"; in writeASTVisitorTraversal()
852 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
853 OS << "tempInst" << getUpperName(); in writeTemplateInstantiationArgs()
856 void writeTemplateInstantiation(raw_ostream &OS) const override { in writeTemplateInstantiation()
857 OS << " " << getType() << " tempInst" << getUpperName() << ";\n"; in writeTemplateInstantiation()
858 OS << " {\n"; in writeTemplateInstantiation()
859 OS << " EnterExpressionEvaluationContext " in writeTemplateInstantiation()
861 OS << " ExprResult " << "Result = S.SubstExpr(" in writeTemplateInstantiation()
863 OS << " tempInst" << getUpperName() << " = " in writeTemplateInstantiation()
865 OS << " }\n"; in writeTemplateInstantiation()
868 void writeDump(raw_ostream &OS) const override {} in writeDump()
870 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
871 OS << " lastChild();\n"; in writeDumpChildren()
872 OS << " dumpStmt(SA->get" << getUpperName() << "());\n"; in writeDumpChildren()
874 void writeHasChildren(raw_ostream &OS) const override { OS << "true"; } in writeHasChildren()
883 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
884 OS << " {\n"; in writeASTVisitorTraversal()
885 OS << " " << getType() << " *I = A->" << getLowerName() in writeASTVisitorTraversal()
887 OS << " " << getType() << " *E = A->" << getLowerName() in writeASTVisitorTraversal()
889 OS << " for (; I != E; ++I) {\n"; in writeASTVisitorTraversal()
890 OS << " if (!getDerived().TraverseStmt(*I))\n"; in writeASTVisitorTraversal()
891 OS << " return false;\n"; in writeASTVisitorTraversal()
892 OS << " }\n"; in writeASTVisitorTraversal()
893 OS << " }\n"; in writeASTVisitorTraversal()
896 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
897 OS << "tempInst" << getUpperName() << ", " in writeTemplateInstantiationArgs()
901 void writeTemplateInstantiation(raw_ostream &OS) const override { in writeTemplateInstantiation()
902 OS << " " << getType() << " *tempInst" << getUpperName() in writeTemplateInstantiation()
905 OS << " {\n"; in writeTemplateInstantiation()
906 OS << " EnterExpressionEvaluationContext " in writeTemplateInstantiation()
908 OS << " " << getType() << " *TI = tempInst" << getUpperName() in writeTemplateInstantiation()
910 OS << " " << getType() << " *I = A->" << getLowerName() in writeTemplateInstantiation()
912 OS << " " << getType() << " *E = A->" << getLowerName() in writeTemplateInstantiation()
914 OS << " for (; I != E; ++I, ++TI) {\n"; in writeTemplateInstantiation()
915 OS << " ExprResult Result = S.SubstExpr(*I, TemplateArgs);\n"; in writeTemplateInstantiation()
916 OS << " *TI = Result.getAs<Expr>();\n"; in writeTemplateInstantiation()
917 OS << " }\n"; in writeTemplateInstantiation()
918 OS << " }\n"; in writeTemplateInstantiation()
921 void writeDump(raw_ostream &OS) const override {} in writeDump()
923 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
924 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writeDumpChildren()
927 OS << " if (I + 1 == E)\n"; in writeDumpChildren()
928 OS << " lastChild();\n"; in writeDumpChildren()
929 OS << " dumpStmt(*I);\n"; in writeDumpChildren()
930 OS << " }\n"; in writeDumpChildren()
933 void writeHasChildren(raw_ostream &OS) const override { in writeHasChildren()
934 OS << "SA->" << getLowerName() << "_begin() != " in writeHasChildren()
945 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
946 OS << " QualType get" << getUpperName() << "() const {\n"; in writeAccessors()
947 OS << " return " << getLowerName() << "->getType();\n"; in writeAccessors()
948 OS << " }"; in writeAccessors()
949 OS << " " << getType() << " get" << getUpperName() << "Loc() const {\n"; in writeAccessors()
950 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
951 OS << " }"; in writeAccessors()
953 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
954 OS << "A->get" << getUpperName() << "Loc()"; in writeTemplateInstantiationArgs()
956 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
957 OS << " " << WritePCHRecord( in writePCHWrite()
1017 static void writeAvailabilityValue(raw_ostream &OS) { in writeAvailabilityValue() argument
1018 OS << "\" << getPlatform()->getName();\n" in writeAvailabilityValue()
1026 static void writeGetSpellingFunction(Record &R, raw_ostream &OS) { in writeGetSpellingFunction() argument
1029 OS << "const char *" << R.getName() << "Attr::getSpelling() const {\n"; in writeGetSpellingFunction()
1031 OS << " return \"(No spelling)\";\n}\n\n"; in writeGetSpellingFunction()
1035 OS << " switch (SpellingListIndex) {\n" in writeGetSpellingFunction()
1041 OS << " case " << I << ":\n" in writeGetSpellingFunction()
1044 OS << " }\n"; in writeGetSpellingFunction()
1046 OS << "}\n\n"; in writeGetSpellingFunction()
1052 raw_ostream &OS) { in writePrettyPrintFunction() argument
1055 OS << "void " << R.getName() << "Attr::printPretty(" in writePrettyPrintFunction()
1059 OS << "}\n\n"; in writePrettyPrintFunction()
1063 OS << in writePrettyPrintFunction()
1109 OS << in writePrettyPrintFunction()
1114 OS << " \";\n"; in writePrettyPrintFunction()
1115 OS << " printPrettyPragma(OS, Policy);\n"; in writePrettyPrintFunction()
1116 OS << " break;\n"; in writePrettyPrintFunction()
1117 OS << " }\n"; in writePrettyPrintFunction()
1122 OS << "("; in writePrettyPrintFunction()
1124 writeAvailabilityValue(OS); in writePrettyPrintFunction()
1127 if (I != Args.begin()) OS << ", "; in writePrettyPrintFunction()
1128 (*I)->writeValue(OS); in writePrettyPrintFunction()
1133 OS << ")"; in writePrettyPrintFunction()
1134 OS << Suffix.str() + "\";\n"; in writePrettyPrintFunction()
1136 OS << in writePrettyPrintFunction()
1142 OS << "}\n"; in writePrettyPrintFunction()
1144 OS << "}\n\n"; in writePrettyPrintFunction()
1168 static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) { in writeAttrAccessorDefinition() argument
1178 OS << " bool " << Name << "() const { return SpellingListIndex == "; in writeAttrAccessorDefinition()
1180 OS << getSpellingListIndex(SpellingList, Spellings[Index]); in writeAttrAccessorDefinition()
1182 OS << " ||\n SpellingListIndex == "; in writeAttrAccessorDefinition()
1184 OS << "; }\n"; in writeAttrAccessorDefinition()
1249 raw_ostream &OS) { in WriteSemanticSpellingSwitch() argument
1250 OS << " switch (" << VarName << ") {\n default: " in WriteSemanticSpellingSwitch()
1253 OS << " case " << I.first << ": return " << I.second << ";\n"; in WriteSemanticSpellingSwitch()
1254 OS << " }\n"; in WriteSemanticSpellingSwitch()
1258 static void emitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrLateParsedList() argument
1259 OS << "#if defined(CLANG_ATTR_LATE_PARSED_LIST)\n"; in emitClangAttrLateParsedList()
1272 OS << ".Case(\"" << I.name() << "\", " << LateParsed << ")\n"; in emitClangAttrLateParsedList()
1276 OS << "#endif // CLANG_ATTR_LATE_PARSED_LIST\n\n"; in emitClangAttrLateParsedList()
1280 static void emitClangAttrTypeArgList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrTypeArgList() argument
1281 OS << "#if defined(CLANG_ATTR_TYPE_ARG_LIST)\n"; in emitClangAttrTypeArgList()
1298 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrTypeArgList()
1301 OS << "#endif // CLANG_ATTR_TYPE_ARG_LIST\n\n"; in emitClangAttrTypeArgList()
1306 static void emitClangAttrArgContextList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrArgContextList() argument
1307 OS << "#if defined(CLANG_ATTR_ARG_CONTEXT_LIST)\n"; in emitClangAttrArgContextList()
1320 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrArgContextList()
1323 OS << "#endif // CLANG_ATTR_ARG_CONTEXT_LIST\n\n"; in emitClangAttrArgContextList()
1335 static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrIdentifierArgList() argument
1336 OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n"; in emitClangAttrIdentifierArgList()
1350 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrIdentifierArgList()
1353 OS << "#endif // CLANG_ATTR_IDENTIFIER_ARG_LIST\n\n"; in emitClangAttrIdentifierArgList()
1359 void EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrClass() argument
1360 emitSourceFileHeader("Attribute classes' definitions", OS); in EmitClangAttrClass()
1362 OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n"; in EmitClangAttrClass()
1363 OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n"; in EmitClangAttrClass()
1393 OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n"; in EmitClangAttrClass()
1401 Args.back()->writeDeclarations(OS); in EmitClangAttrClass()
1402 OS << "\n\n"; in EmitClangAttrClass()
1405 OS << "\npublic:\n"; in EmitClangAttrClass()
1419 OS << CreateSemanticSpellings(Spellings, SemanticToSyntacticMap); in EmitClangAttrClass()
1421 OS << " static " << R.getName() << "Attr *CreateImplicit("; in EmitClangAttrClass()
1422 OS << "ASTContext &Ctx"; in EmitClangAttrClass()
1424 OS << ", Spelling S"; in EmitClangAttrClass()
1426 OS << ", "; in EmitClangAttrClass()
1427 ai->writeCtorParameters(OS); in EmitClangAttrClass()
1429 OS << ", SourceRange Loc = SourceRange()"; in EmitClangAttrClass()
1430 OS << ") {\n"; in EmitClangAttrClass()
1431 OS << " " << R.getName() << "Attr *A = new (Ctx) " << R.getName(); in EmitClangAttrClass()
1432 OS << "Attr(Loc, Ctx, "; in EmitClangAttrClass()
1434 ai->writeImplicitCtorArgs(OS); in EmitClangAttrClass()
1435 OS << ", "; in EmitClangAttrClass()
1437 OS << (ElideSpelling ? "0" : "S") << ");\n"; in EmitClangAttrClass()
1438 OS << " A->setImplicit(true);\n"; in EmitClangAttrClass()
1439 OS << " return A;\n }\n\n"; in EmitClangAttrClass()
1441 OS << " " << R.getName() << "Attr(SourceRange R, ASTContext &Ctx\n"; in EmitClangAttrClass()
1445 OS << " , "; in EmitClangAttrClass()
1446 ai->writeCtorParameters(OS); in EmitClangAttrClass()
1447 OS << "\n"; in EmitClangAttrClass()
1452 OS << " , "; in EmitClangAttrClass()
1453 OS << "unsigned SI\n"; in EmitClangAttrClass()
1455 OS << " )\n"; in EmitClangAttrClass()
1456 OS << " : " << SuperName << "(attr::" << R.getName() << ", R, SI)\n"; in EmitClangAttrClass()
1459 OS << " , "; in EmitClangAttrClass()
1460 ai->writeCtorInitializers(OS); in EmitClangAttrClass()
1461 OS << "\n"; in EmitClangAttrClass()
1464 OS << " {\n"; in EmitClangAttrClass()
1467 ai->writeCtorBody(OS); in EmitClangAttrClass()
1468 OS << "\n"; in EmitClangAttrClass()
1470 OS << " }\n\n"; in EmitClangAttrClass()
1475 OS << " " << R.getName() << "Attr(SourceRange R, ASTContext &Ctx\n"; in EmitClangAttrClass()
1478 OS << " , "; in EmitClangAttrClass()
1479 ai->writeCtorParameters(OS); in EmitClangAttrClass()
1480 OS << "\n"; in EmitClangAttrClass()
1484 OS << " , "; in EmitClangAttrClass()
1485 OS << "unsigned SI\n"; in EmitClangAttrClass()
1487 OS << " )\n"; in EmitClangAttrClass()
1488 OS << " : " << SuperName << "(attr::" << R.getName() << ", R, SI)\n"; in EmitClangAttrClass()
1491 OS << " , "; in EmitClangAttrClass()
1492 ai->writeCtorDefaultInitializers(OS); in EmitClangAttrClass()
1493 OS << "\n"; in EmitClangAttrClass()
1496 OS << " {\n"; in EmitClangAttrClass()
1500 ai->writeCtorBody(OS); in EmitClangAttrClass()
1501 OS << "\n"; in EmitClangAttrClass()
1504 OS << " }\n\n"; in EmitClangAttrClass()
1507 OS << " " << R.getName() << "Attr *clone(ASTContext &C) const override;\n"; in EmitClangAttrClass()
1508 OS << " void printPretty(raw_ostream &OS,\n" in EmitClangAttrClass()
1510 OS << " const char *getSpelling() const override;\n"; in EmitClangAttrClass()
1514 OS << " Spelling getSemanticSpelling() const {\n"; in EmitClangAttrClass()
1516 OS); in EmitClangAttrClass()
1517 OS << " }\n"; in EmitClangAttrClass()
1520 writeAttrAccessorDefinition(R, OS); in EmitClangAttrClass()
1523 ai->writeAccessors(OS); in EmitClangAttrClass()
1524 OS << "\n\n"; in EmitClangAttrClass()
1527 static_cast<const EnumArgument *>(ai.get())->writeConversion(OS); in EmitClangAttrClass()
1530 ->writeConversion(OS); in EmitClangAttrClass()
1533 OS << R.getValueAsString("AdditionalMembers"); in EmitClangAttrClass()
1534 OS << "\n\n"; in EmitClangAttrClass()
1536 OS << " static bool classof(const Attr *A) { return A->getKind() == " in EmitClangAttrClass()
1540 OS << " bool isLateParsed() const override { return " in EmitClangAttrClass()
1544 OS << " bool duplicatesAllowed() const override { return true; }\n\n"; in EmitClangAttrClass()
1546 OS << "};\n\n"; in EmitClangAttrClass()
1549 OS << "#endif\n"; in EmitClangAttrClass()
1553 void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrImpl() argument
1554 emitSourceFileHeader("Attribute classes' member function definitions", OS); in EmitClangAttrImpl()
1570 ai->writeAccessorDefinitions(OS); in EmitClangAttrImpl()
1572 OS << R.getName() << "Attr *" << R.getName() in EmitClangAttrImpl()
1574 OS << " auto *A = new (C) " << R.getName() << "Attr(getLocation(), C"; in EmitClangAttrImpl()
1576 OS << ", "; in EmitClangAttrImpl()
1577 ai->writeCloneArgs(OS); in EmitClangAttrImpl()
1579 OS << ", getSpellingListIndex());\n"; in EmitClangAttrImpl()
1580 OS << " A->Inherited = Inherited;\n"; in EmitClangAttrImpl()
1581 OS << " A->IsPackExpansion = IsPackExpansion;\n"; in EmitClangAttrImpl()
1582 OS << " A->Implicit = Implicit;\n"; in EmitClangAttrImpl()
1583 OS << " return A;\n}\n\n"; in EmitClangAttrImpl()
1585 writePrettyPrintFunction(R, Args, OS); in EmitClangAttrImpl()
1586 writeGetSpellingFunction(R, OS); in EmitClangAttrImpl()
1592 static void EmitAttrList(raw_ostream &OS, StringRef Class, in EmitAttrList() argument
1602 OS << Class << "(" << (*i)->getName() << ")\n"; in EmitAttrList()
1605 OS << "LAST_" << Class << "(" << (*i)->getName() << ")\n\n"; in EmitAttrList()
1612 void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrList() argument
1613 emitSourceFileHeader("List of all attributes that Clang recognizes", OS); in EmitClangAttrList()
1615 OS << "#ifndef LAST_ATTR\n"; in EmitClangAttrList()
1616 OS << "#define LAST_ATTR(NAME) ATTR(NAME)\n"; in EmitClangAttrList()
1617 OS << "#endif\n\n"; in EmitClangAttrList()
1619 OS << "#ifndef INHERITABLE_ATTR\n"; in EmitClangAttrList()
1620 OS << "#define INHERITABLE_ATTR(NAME) ATTR(NAME)\n"; in EmitClangAttrList()
1621 OS << "#endif\n\n"; in EmitClangAttrList()
1623 OS << "#ifndef LAST_INHERITABLE_ATTR\n"; in EmitClangAttrList()
1624 OS << "#define LAST_INHERITABLE_ATTR(NAME) INHERITABLE_ATTR(NAME)\n"; in EmitClangAttrList()
1625 OS << "#endif\n\n"; in EmitClangAttrList()
1627 OS << "#ifndef INHERITABLE_PARAM_ATTR\n"; in EmitClangAttrList()
1628 OS << "#define INHERITABLE_PARAM_ATTR(NAME) ATTR(NAME)\n"; in EmitClangAttrList()
1629 OS << "#endif\n\n"; in EmitClangAttrList()
1631 OS << "#ifndef LAST_INHERITABLE_PARAM_ATTR\n"; in EmitClangAttrList()
1632 OS << "#define LAST_INHERITABLE_PARAM_ATTR(NAME)" in EmitClangAttrList()
1634 OS << "#endif\n\n"; in EmitClangAttrList()
1652 EmitAttrList(OS, "INHERITABLE_PARAM_ATTR", InhParamAttrs); in EmitClangAttrList()
1653 EmitAttrList(OS, "INHERITABLE_ATTR", InhAttrs); in EmitClangAttrList()
1654 EmitAttrList(OS, "ATTR", NonInhAttrs); in EmitClangAttrList()
1656 OS << "#undef LAST_ATTR\n"; in EmitClangAttrList()
1657 OS << "#undef INHERITABLE_ATTR\n"; in EmitClangAttrList()
1658 OS << "#undef LAST_INHERITABLE_ATTR\n"; in EmitClangAttrList()
1659 OS << "#undef LAST_INHERITABLE_PARAM_ATTR\n"; in EmitClangAttrList()
1660 OS << "#undef ATTR\n"; in EmitClangAttrList()
1664 void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrPCHRead() argument
1665 emitSourceFileHeader("Attribute deserialization code", OS); in EmitClangAttrPCHRead()
1672 OS << " switch (Kind) {\n"; in EmitClangAttrPCHRead()
1673 OS << " default:\n"; in EmitClangAttrPCHRead()
1674 OS << " llvm_unreachable(\"Unknown attribute!\");\n"; in EmitClangAttrPCHRead()
1680 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrPCHRead()
1682 OS << " bool isInherited = Record[Idx++];\n"; in EmitClangAttrPCHRead()
1683 OS << " bool isImplicit = Record[Idx++];\n"; in EmitClangAttrPCHRead()
1684 OS << " unsigned Spelling = Record[Idx++];\n"; in EmitClangAttrPCHRead()
1689 Args.back()->writePCHReadDecls(OS); in EmitClangAttrPCHRead()
1691 OS << " New = new (Context) " << R.getName() << "Attr(Range, Context"; in EmitClangAttrPCHRead()
1693 OS << ", "; in EmitClangAttrPCHRead()
1694 ri->writePCHReadArgs(OS); in EmitClangAttrPCHRead()
1696 OS << ", Spelling);\n"; in EmitClangAttrPCHRead()
1698 OS << " cast<InheritableAttr>(New)->setInherited(isInherited);\n"; in EmitClangAttrPCHRead()
1699 OS << " New->setImplicit(isImplicit);\n"; in EmitClangAttrPCHRead()
1700 OS << " break;\n"; in EmitClangAttrPCHRead()
1701 OS << " }\n"; in EmitClangAttrPCHRead()
1703 OS << " }\n"; in EmitClangAttrPCHRead()
1707 void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrPCHWrite() argument
1708 emitSourceFileHeader("Attribute serialization code", OS); in EmitClangAttrPCHWrite()
1713 OS << " switch (A->getKind()) {\n"; in EmitClangAttrPCHWrite()
1714 OS << " default:\n"; in EmitClangAttrPCHWrite()
1715 OS << " llvm_unreachable(\"Unknown attribute kind!\");\n"; in EmitClangAttrPCHWrite()
1716 OS << " break;\n"; in EmitClangAttrPCHWrite()
1721 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrPCHWrite()
1724 OS << " const " << R.getName() << "Attr *SA = cast<" << R.getName() in EmitClangAttrPCHWrite()
1727 OS << " Record.push_back(SA->isInherited());\n"; in EmitClangAttrPCHWrite()
1728 OS << " Record.push_back(A->isImplicit());\n"; in EmitClangAttrPCHWrite()
1729 OS << " Record.push_back(A->getSpellingListIndex());\n"; in EmitClangAttrPCHWrite()
1732 createArgument(*Arg, R.getName())->writePCHWrite(OS); in EmitClangAttrPCHWrite()
1733 OS << " break;\n"; in EmitClangAttrPCHWrite()
1734 OS << " }\n"; in EmitClangAttrPCHWrite()
1736 OS << " }\n"; in EmitClangAttrPCHWrite()
1740 const std::vector<Record *> &Attrs, raw_ostream &OS, in GenerateHasAttrSpellingStringSwitch() argument
1788 OS << " .Case(\"" << S.name() << "\", " << Test << ")\n"; in GenerateHasAttrSpellingStringSwitch()
1790 OS << " .Default(false);\n"; in GenerateHasAttrSpellingStringSwitch()
1794 void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrHasAttrImpl() argument
1795 emitSourceFileHeader("Code to implement the __has_attribute logic", OS); in EmitClangAttrHasAttrImpl()
1820 OS << "switch (Syntax) {\n"; in EmitClangAttrHasAttrImpl()
1821 OS << "case AttrSyntax::Generic:\n"; in EmitClangAttrHasAttrImpl()
1822 OS << " return llvm::StringSwitch<bool>(Name)\n"; in EmitClangAttrHasAttrImpl()
1823 GenerateHasAttrSpellingStringSwitch(Attrs, OS); in EmitClangAttrHasAttrImpl()
1824 OS << "case AttrSyntax::GNU:\n"; in EmitClangAttrHasAttrImpl()
1825 OS << " return llvm::StringSwitch<bool>(Name)\n"; in EmitClangAttrHasAttrImpl()
1826 GenerateHasAttrSpellingStringSwitch(GNU, OS, "GNU"); in EmitClangAttrHasAttrImpl()
1827 OS << "case AttrSyntax::Declspec:\n"; in EmitClangAttrHasAttrImpl()
1828 OS << " return llvm::StringSwitch<bool>(Name)\n"; in EmitClangAttrHasAttrImpl()
1829 GenerateHasAttrSpellingStringSwitch(Declspec, OS, "Declspec"); in EmitClangAttrHasAttrImpl()
1830 OS << "case AttrSyntax::Pragma:\n"; in EmitClangAttrHasAttrImpl()
1831 OS << " return llvm::StringSwitch<bool>(Name)\n"; in EmitClangAttrHasAttrImpl()
1832 GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma"); in EmitClangAttrHasAttrImpl()
1833 OS << "case AttrSyntax::CXX: {\n"; in EmitClangAttrHasAttrImpl()
1839 OS << " else "; in EmitClangAttrHasAttrImpl()
1841 OS << "if (!Scope || Scope->getName() == \"\") {\n"; in EmitClangAttrHasAttrImpl()
1843 OS << "if (Scope->getName() == \"" << I->first << "\") {\n"; in EmitClangAttrHasAttrImpl()
1844 OS << " return llvm::StringSwitch<bool>(Name)\n"; in EmitClangAttrHasAttrImpl()
1845 GenerateHasAttrSpellingStringSwitch(I->second, OS, "CXX11", I->first); in EmitClangAttrHasAttrImpl()
1846 OS << "}"; in EmitClangAttrHasAttrImpl()
1848 OS << "\n}\n"; in EmitClangAttrHasAttrImpl()
1849 OS << "}\n"; in EmitClangAttrHasAttrImpl()
1852 void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrSpellingListIndex() argument
1854 "into internal identifiers", OS); in EmitClangAttrSpellingListIndex()
1856 OS << in EmitClangAttrSpellingListIndex()
1866 OS << " case AT_" << I.first << ": {\n"; in EmitClangAttrSpellingListIndex()
1868 OS << " if (Name == \"" << Spellings[I].name() << "\" && " in EmitClangAttrSpellingListIndex()
1881 OS << " break;\n"; in EmitClangAttrSpellingListIndex()
1882 OS << " }\n"; in EmitClangAttrSpellingListIndex()
1885 OS << " }\n"; in EmitClangAttrSpellingListIndex()
1886 OS << " return 0;\n"; in EmitClangAttrSpellingListIndex()
1890 void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrASTVisitor() argument
1891 emitSourceFileHeader("Used by RecursiveASTVisitor to visit attributes.", OS); in EmitClangAttrASTVisitor()
1898 OS << "#ifdef ATTR_VISITOR_DECLS_ONLY\n\n"; in EmitClangAttrASTVisitor()
1903 OS << " bool Traverse" in EmitClangAttrASTVisitor()
1905 OS << " bool Visit" in EmitClangAttrASTVisitor()
1910 OS << "\n#else // ATTR_VISITOR_DECLS_ONLY\n\n"; in EmitClangAttrASTVisitor()
1918 OS << "template <typename Derived>\n" in EmitClangAttrASTVisitor()
1928 createArgument(*Arg, R.getName())->writeASTVisitorTraversal(OS); in EmitClangAttrASTVisitor()
1930 OS << " return true;\n"; in EmitClangAttrASTVisitor()
1931 OS << "}\n\n"; in EmitClangAttrASTVisitor()
1935 OS << "template <typename Derived>\n" in EmitClangAttrASTVisitor()
1949 OS << " case attr::" << R.getName() << ":\n" in EmitClangAttrASTVisitor()
1953 OS << " }\n"; // end case in EmitClangAttrASTVisitor()
1954 OS << "}\n"; // end function in EmitClangAttrASTVisitor()
1955 OS << "#endif // ATTR_VISITOR_DECLS_ONLY\n"; in EmitClangAttrASTVisitor()
1959 void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrTemplateInstantiate() argument
1960 emitSourceFileHeader("Template instantiation code for attributes", OS); in EmitClangAttrTemplateInstantiate()
1964 OS << "namespace clang {\n" in EmitClangAttrTemplateInstantiate()
1978 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrTemplateInstantiate()
1982 OS << " return NULL;\n"; in EmitClangAttrTemplateInstantiate()
1983 OS << " }\n"; in EmitClangAttrTemplateInstantiate()
1987 OS << " const " << R.getName() << "Attr *A = cast<" in EmitClangAttrTemplateInstantiate()
1992 OS << " return A->clone(C);\n"; in EmitClangAttrTemplateInstantiate()
1993 OS << " }\n"; in EmitClangAttrTemplateInstantiate()
2005 ai->writeTemplateInstantiation(OS); in EmitClangAttrTemplateInstantiate()
2007 OS << " return new (C) " << R.getName() << "Attr(A->getLocation(), C"; in EmitClangAttrTemplateInstantiate()
2009 OS << ", "; in EmitClangAttrTemplateInstantiate()
2010 ai->writeTemplateInstantiationArgs(OS); in EmitClangAttrTemplateInstantiate()
2012 OS << ", A->getSpellingListIndex());\n }\n"; in EmitClangAttrTemplateInstantiate()
2014 OS << " } // end switch\n" in EmitClangAttrTemplateInstantiate()
2023 void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrList() argument
2024 emitSourceFileHeader("List of all attributes that Clang recognizes", OS); in EmitClangAttrParsedAttrList()
2026 OS << "#ifndef PARSED_ATTR\n"; in EmitClangAttrParsedAttrList()
2027 OS << "#define PARSED_ATTR(NAME) NAME\n"; in EmitClangAttrParsedAttrList()
2028 OS << "#endif\n\n"; in EmitClangAttrParsedAttrList()
2032 OS << "PARSED_ATTR(" << I.first << ")\n"; in EmitClangAttrParsedAttrList()
2036 static void emitArgInfo(const Record &R, std::stringstream &OS) { in emitArgInfo() argument
2045 OS << ArgCount << ", " << OptCount; in emitArgInfo()
2048 static void GenerateDefaultAppertainsTo(raw_ostream &OS) { in GenerateDefaultAppertainsTo() argument
2049 OS << "static bool defaultAppertainsTo(Sema &, const AttributeList &,"; in GenerateDefaultAppertainsTo()
2050 OS << "const Decl *) {\n"; in GenerateDefaultAppertainsTo()
2051 OS << " return true;\n"; in GenerateDefaultAppertainsTo()
2052 OS << "}\n\n"; in GenerateDefaultAppertainsTo()
2173 raw_ostream &OS) { in GenerateCustomAppertainsTo() argument
2192 OS << "static bool " << FnName << "(const Decl *D) {\n"; in GenerateCustomAppertainsTo()
2193 OS << " if (const " << GetSubjectWithSuffix(Base) << " *S = dyn_cast<"; in GenerateCustomAppertainsTo()
2194 OS << GetSubjectWithSuffix(Base); in GenerateCustomAppertainsTo()
2195 OS << ">(D))\n"; in GenerateCustomAppertainsTo()
2196 OS << " return " << Subject.getValueAsString("CheckCode") << ";\n"; in GenerateCustomAppertainsTo()
2197 OS << " return false;\n"; in GenerateCustomAppertainsTo()
2198 OS << "}\n\n"; in GenerateCustomAppertainsTo()
2204 static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) { in GenerateAppertainsTo() argument
2235 SS << "!" << GenerateCustomAppertainsTo(**I, OS) << "(D)"; in GenerateAppertainsTo()
2255 OS << SS.str(); in GenerateAppertainsTo()
2259 static void GenerateDefaultLangOptRequirements(raw_ostream &OS) { in GenerateDefaultLangOptRequirements() argument
2260 OS << "static bool defaultDiagnoseLangOpts(Sema &, "; in GenerateDefaultLangOptRequirements()
2261 OS << "const AttributeList &) {\n"; in GenerateDefaultLangOptRequirements()
2262 OS << " return true;\n"; in GenerateDefaultLangOptRequirements()
2263 OS << "}\n\n"; in GenerateDefaultLangOptRequirements()
2267 raw_ostream &OS) { in GenerateLangOptRequirements() argument
2295 OS << "static bool " << FnName << "(Sema &S, const AttributeList &Attr) {\n"; in GenerateLangOptRequirements()
2296 OS << " if (" << Test << ")\n"; in GenerateLangOptRequirements()
2297 OS << " return true;\n\n"; in GenerateLangOptRequirements()
2298 OS << " S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) "; in GenerateLangOptRequirements()
2299 OS << "<< Attr.getName();\n"; in GenerateLangOptRequirements()
2300 OS << " return false;\n"; in GenerateLangOptRequirements()
2301 OS << "}\n\n"; in GenerateLangOptRequirements()
2307 static void GenerateDefaultTargetRequirements(raw_ostream &OS) { in GenerateDefaultTargetRequirements() argument
2308 OS << "static bool defaultTargetRequirements(const llvm::Triple &) {\n"; in GenerateDefaultTargetRequirements()
2309 OS << " return true;\n"; in GenerateDefaultTargetRequirements()
2310 OS << "}\n\n"; in GenerateDefaultTargetRequirements()
2315 raw_ostream &OS) { in GenerateTargetRequirements() argument
2384 OS << "static bool " << FnName << "(const llvm::Triple &T) {\n"; in GenerateTargetRequirements()
2385 OS << " llvm::Triple::ArchType Arch = T.getArch();\n"; in GenerateTargetRequirements()
2387 OS << " llvm::Triple::OSType OS = T.getOS();\n"; in GenerateTargetRequirements()
2388 OS << " return " << Test << ";\n"; in GenerateTargetRequirements()
2389 OS << "}\n\n"; in GenerateTargetRequirements()
2395 static void GenerateDefaultSpellingIndexToSemanticSpelling(raw_ostream &OS) { in GenerateDefaultSpellingIndexToSemanticSpelling() argument
2396 OS << "static unsigned defaultSpellingIndexToSemanticSpelling(" in GenerateDefaultSpellingIndexToSemanticSpelling()
2398 OS << " return UINT_MAX;\n"; in GenerateDefaultSpellingIndexToSemanticSpelling()
2399 OS << "}\n\n"; in GenerateDefaultSpellingIndexToSemanticSpelling()
2403 raw_ostream &OS) { in GenerateSpellingIndexToSemanticSpelling() argument
2420 OS << "static unsigned " << Name << "(const AttributeList &Attr) {\n"; in GenerateSpellingIndexToSemanticSpelling()
2421 OS << Enum; in GenerateSpellingIndexToSemanticSpelling()
2422 OS << " unsigned Idx = Attr.getAttributeSpellingListIndex();\n"; in GenerateSpellingIndexToSemanticSpelling()
2423 WriteSemanticSpellingSwitch("Idx", SemanticToSyntacticMap, OS); in GenerateSpellingIndexToSemanticSpelling()
2424 OS << "}\n\n"; in GenerateSpellingIndexToSemanticSpelling()
2441 void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrImpl() argument
2442 emitSourceFileHeader("Parsed attribute helpers", OS); in EmitClangAttrParsedAttrImpl()
2451 GenerateDefaultAppertainsTo(OS); in EmitClangAttrParsedAttrImpl()
2452 GenerateDefaultLangOptRequirements(OS); in EmitClangAttrParsedAttrImpl()
2453 GenerateDefaultTargetRequirements(OS); in EmitClangAttrParsedAttrImpl()
2454 GenerateDefaultSpellingIndexToSemanticSpelling(OS); in EmitClangAttrParsedAttrImpl()
2476 SS << ", " << GenerateAppertainsTo(*I->second, OS); in EmitClangAttrParsedAttrImpl()
2477 SS << ", " << GenerateLangOptRequirements(*I->second, OS); in EmitClangAttrParsedAttrImpl()
2478 SS << ", " << GenerateTargetRequirements(*I->second, Dupes, OS); in EmitClangAttrParsedAttrImpl()
2479 SS << ", " << GenerateSpellingIndexToSemanticSpelling(*I->second, OS); in EmitClangAttrParsedAttrImpl()
2488 OS << "static const ParsedAttrInfo AttrInfoMap[AttributeList::UnknownAttribute + 1] = {\n"; in EmitClangAttrParsedAttrImpl()
2489 OS << SS.str(); in EmitClangAttrParsedAttrImpl()
2490 OS << "};\n\n"; in EmitClangAttrParsedAttrImpl()
2494 void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrKinds() argument
2495 emitSourceFileHeader("Attribute name matcher", OS); in EmitClangAttrParsedAttrKinds()
2557 OS << "static AttributeList::Kind getAttrKind(StringRef Name, "; in EmitClangAttrParsedAttrKinds()
2558 OS << "AttributeList::Syntax Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
2559 OS << " if (AttributeList::AS_GNU == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
2560 StringMatcher("Name", GNU, OS).Emit(); in EmitClangAttrParsedAttrKinds()
2561 OS << " } else if (AttributeList::AS_Declspec == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
2562 StringMatcher("Name", Declspec, OS).Emit(); in EmitClangAttrParsedAttrKinds()
2563 OS << " } else if (AttributeList::AS_CXX11 == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
2564 StringMatcher("Name", CXX11, OS).Emit(); in EmitClangAttrParsedAttrKinds()
2565 OS << " } else if (AttributeList::AS_Keyword == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
2566 StringMatcher("Name", Keywords, OS).Emit(); in EmitClangAttrParsedAttrKinds()
2567 OS << " } else if (AttributeList::AS_Pragma == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
2568 StringMatcher("Name", Pragma, OS).Emit(); in EmitClangAttrParsedAttrKinds()
2569 OS << " }\n"; in EmitClangAttrParsedAttrKinds()
2570 OS << " return AttributeList::UnknownAttribute;\n" in EmitClangAttrParsedAttrKinds()
2575 void EmitClangAttrDump(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrDump() argument
2576 emitSourceFileHeader("Attribute dumper", OS); in EmitClangAttrDump()
2578 OS << in EmitClangAttrDump()
2588 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrDump()
2595 OS << " OS << \" \" << A->getSpelling();\n"; in EmitClangAttrDump()
2599 OS << " const " << R.getName() << "Attr *SA = cast<" << R.getName() in EmitClangAttrDump()
2602 createArgument(*Arg, R.getName())->writeDump(OS); in EmitClangAttrDump()
2605 OS << " bool OldMoreChildren = hasMoreChildren();\n"; in EmitClangAttrDump()
2606 OS << " bool MoreChildren;\n"; in EmitClangAttrDump()
2610 OS << " MoreChildren = OldMoreChildren"; in EmitClangAttrDump()
2612 OS << " || "; in EmitClangAttrDump()
2613 createArgument(**Next, R.getName())->writeHasChildren(OS); in EmitClangAttrDump()
2615 OS << ";\n"; in EmitClangAttrDump()
2616 OS << " setMoreChildren(MoreChildren);\n"; in EmitClangAttrDump()
2618 createArgument(**AI, R.getName())->writeDumpChildren(OS); in EmitClangAttrDump()
2622 OS << " setMoreChildren(OldMoreChildren);\n"; in EmitClangAttrDump()
2624 OS << in EmitClangAttrDump()
2628 OS << " }\n"; in EmitClangAttrDump()
2632 raw_ostream &OS) { in EmitClangAttrParserStringSwitches() argument
2633 emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS); in EmitClangAttrParserStringSwitches()
2634 emitClangAttrArgContextList(Records, OS); in EmitClangAttrParserStringSwitches()
2635 emitClangAttrIdentifierArgList(Records, OS); in EmitClangAttrParserStringSwitches()
2636 emitClangAttrTypeArgList(Records, OS); in EmitClangAttrParserStringSwitches()
2637 emitClangAttrLateParsedList(Records, OS); in EmitClangAttrParserStringSwitches()
2650 raw_ostream &OS) { in WriteCategoryHeader() argument
2652 OS << Name << "\n" << std::string(Name.length(), '=') << "\n"; in WriteCategoryHeader()
2665 OS << Content; in WriteCategoryHeader()
2667 OS << "\n\n"; in WriteCategoryHeader()
2679 raw_ostream &OS) { in WriteDocumentation() argument
2750 OS << Heading << "\n" << std::string(Heading.length(), '-') << "\n"; in WriteDocumentation()
2758 OS << ".. csv-table:: Supported Syntaxes\n"; in WriteDocumentation()
2759 OS << " :header: \"GNU\", \"C++11\", \"__declspec\", \"Keyword\","; in WriteDocumentation()
2760 OS << " \"Pragma\"\n\n"; in WriteDocumentation()
2761 OS << " \""; in WriteDocumentation()
2762 if (SupportedSpellings & GNU) OS << "X"; in WriteDocumentation()
2763 OS << "\",\""; in WriteDocumentation()
2764 if (SupportedSpellings & CXX11) OS << "X"; in WriteDocumentation()
2765 OS << "\",\""; in WriteDocumentation()
2766 if (SupportedSpellings & Declspec) OS << "X"; in WriteDocumentation()
2767 OS << "\",\""; in WriteDocumentation()
2768 if (SupportedSpellings & Keyword) OS << "X"; in WriteDocumentation()
2769 OS << "\", \""; in WriteDocumentation()
2770 if (SupportedSpellings & Pragma) OS << "X"; in WriteDocumentation()
2771 OS << "\"\n\n"; in WriteDocumentation()
2776 OS << "This attribute has been deprecated, and may be removed in a future " in WriteDocumentation()
2781 OS << " This attribute has been superseded by ``" in WriteDocumentation()
2783 OS << "\n\n"; in WriteDocumentation()
2795 OS << Content; in WriteDocumentation()
2797 OS << "\n\n\n"; in WriteDocumentation()
2800 void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrDocs() argument
2809 OS << Documentation->getValueAsString("Intro") << "\n"; in EmitClangAttrDocs()
2839 WriteCategoryHeader(I.first, OS); in EmitClangAttrDocs()
2844 WriteDocumentation(Doc, OS); in EmitClangAttrDocs()