Lines Matching refs:OS
216 virtual void writeAccessors(raw_ostream &OS) const = 0;
217 virtual void writeAccessorDefinitions(raw_ostream &OS) const {} in writeAccessorDefinitions()
218 virtual void writeASTVisitorTraversal(raw_ostream &OS) const {} in writeASTVisitorTraversal()
219 virtual void writeCloneArgs(raw_ostream &OS) const = 0;
220 virtual void writeTemplateInstantiationArgs(raw_ostream &OS) const = 0;
221 virtual void writeTemplateInstantiation(raw_ostream &OS) const {} in writeTemplateInstantiation()
222 virtual void writeCtorBody(raw_ostream &OS) const {} in writeCtorBody()
223 virtual void writeCtorInitializers(raw_ostream &OS) const = 0;
224 virtual void writeCtorDefaultInitializers(raw_ostream &OS) const = 0;
225 virtual void writeCtorParameters(raw_ostream &OS) const = 0;
226 virtual void writeDeclarations(raw_ostream &OS) const = 0;
227 virtual void writePCHReadArgs(raw_ostream &OS) const = 0;
228 virtual void writePCHReadDecls(raw_ostream &OS) const = 0;
229 virtual void writePCHWrite(raw_ostream &OS) const = 0;
230 virtual void writeValue(raw_ostream &OS) const = 0;
231 virtual void writeDump(raw_ostream &OS) const = 0;
232 virtual void writeDumpChildren(raw_ostream &OS) const {} in writeDumpChildren()
233 virtual void writeHasChildren(raw_ostream &OS) const { OS << "false"; } in writeHasChildren()
239 virtual void writeImplicitCtorArgs(raw_ostream &OS) const { in writeImplicitCtorArgs()
240 OS << getUpperName(); in writeImplicitCtorArgs()
253 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
254 OS << " " << type << " get" << getUpperName() << "() const {\n"; in writeAccessors()
255 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
256 OS << " }"; in writeAccessors()
259 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
260 OS << getLowerName(); in writeCloneArgs()
263 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
264 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
267 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
268 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
271 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
272 OS << getLowerName() << "()"; in writeCtorDefaultInitializers()
275 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
276 OS << type << " " << getUpperName(); in writeCtorParameters()
279 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
280 OS << type << " " << getLowerName() << ";"; in writeDeclarations()
283 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
285 OS << " " << type << " " << getLowerName() << " = " << read << ";\n"; in writePCHReadDecls()
288 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
289 OS << getLowerName(); in writePCHReadArgs()
292 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
293 OS << " " << WritePCHRecord(type, "SA->get" + in writePCHWrite()
297 void writeValue(raw_ostream &OS) const override { in writeValue()
299 OS << "\" << get" << getUpperName() in writeValue()
302 OS << "\" << get" << getUpperName() << "()->getName() << \""; in writeValue()
304 OS << "\" << get" << getUpperName() << "().getAsString() << \""; in writeValue()
306 OS << "\" << get" << getUpperName() << "() << \""; in writeValue()
310 void writeDump(raw_ostream &OS) const override { in writeDump()
312 OS << " OS << \" \";\n"; in writeDump()
313 OS << " dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; in writeDump()
316 OS << " if (SA->get" << getUpperName() << "())\n "; in writeDump()
317 OS << " OS << \" \" << SA->get" << getUpperName() in writeDump()
320 OS << " OS << \" \" << SA->get" << getUpperName() in writeDump()
323 OS << " if (SA->get" << getUpperName() << "()) OS << \" " in writeDump()
326 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n"; in writeDump()
341 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
342 SimpleArgument::writeAccessors(OS); in writeAccessors()
344 OS << "\n\n static const " << getType() << " Default" << getUpperName() in writeAccessors()
347 OS << (Default != 0 ? "true" : "false"); in writeAccessors()
349 OS << Default; in writeAccessors()
350 OS << ";"; in writeAccessors()
360 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
361 OS << " llvm::StringRef get" << getUpperName() << "() const {\n"; in writeAccessors()
362 OS << " return llvm::StringRef(" << getLowerName() << ", " in writeAccessors()
364 OS << " }\n"; in writeAccessors()
365 OS << " unsigned get" << getUpperName() << "Length() const {\n"; in writeAccessors()
366 OS << " return " << getLowerName() << "Length;\n"; in writeAccessors()
367 OS << " }\n"; in writeAccessors()
368 OS << " void set" << getUpperName() in writeAccessors()
370 OS << " " << getLowerName() << "Length = S.size();\n"; in writeAccessors()
371 OS << " this->" << getLowerName() << " = new (C, 1) char [" in writeAccessors()
373 OS << " if (!S.empty())\n"; in writeAccessors()
374 OS << " std::memcpy(this->" << getLowerName() << ", S.data(), " in writeAccessors()
376 OS << " }"; in writeAccessors()
379 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
380 OS << "get" << getUpperName() << "()"; in writeCloneArgs()
383 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
384 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
387 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
388 OS << " if (!" << getUpperName() << ".empty())\n"; in writeCtorBody()
389 OS << " std::memcpy(" << getLowerName() << ", " << getUpperName() in writeCtorBody()
393 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
394 OS << getLowerName() << "Length(" << getUpperName() << ".size())," in writeCtorInitializers()
399 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
400 OS << getLowerName() << "Length(0)," << getLowerName() << "(nullptr)"; in writeCtorDefaultInitializers()
403 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
404 OS << "llvm::StringRef " << getUpperName(); in writeCtorParameters()
407 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
408 OS << "unsigned " << getLowerName() << "Length;\n"; in writeDeclarations()
409 OS << "char *" << getLowerName() << ";"; in writeDeclarations()
412 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
413 OS << " std::string " << getLowerName() in writePCHReadDecls()
417 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
418 OS << getLowerName(); in writePCHReadArgs()
421 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
422 OS << " Record.AddString(SA->get" << getUpperName() << "());\n"; in writePCHWrite()
425 void writeValue(raw_ostream &OS) const override { in writeValue()
426 OS << "\\\"\" << get" << getUpperName() << "() << \"\\\""; in writeValue()
429 void writeDump(raw_ostream &OS) const override { in writeDump()
430 OS << " OS << \" \\\"\" << SA->get" << getUpperName() in writeDump()
441 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
442 OS << " bool is" << getUpperName() << "Dependent() const;\n"; in writeAccessors()
444 OS << " unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n"; in writeAccessors()
446 OS << " bool is" << getUpperName() << "Expr() const {\n"; in writeAccessors()
447 OS << " return is" << getLowerName() << "Expr;\n"; in writeAccessors()
448 OS << " }\n"; in writeAccessors()
450 OS << " Expr *get" << getUpperName() << "Expr() const {\n"; in writeAccessors()
451 OS << " assert(is" << getLowerName() << "Expr);\n"; in writeAccessors()
452 OS << " return " << getLowerName() << "Expr;\n"; in writeAccessors()
453 OS << " }\n"; in writeAccessors()
455 OS << " TypeSourceInfo *get" << getUpperName() << "Type() const {\n"; in writeAccessors()
456 OS << " assert(!is" << getLowerName() << "Expr);\n"; in writeAccessors()
457 OS << " return " << getLowerName() << "Type;\n"; in writeAccessors()
458 OS << " }"; in writeAccessors()
461 void writeAccessorDefinitions(raw_ostream &OS) const override { in writeAccessorDefinitions()
462 OS << "bool " << getAttrName() << "Attr::is" << getUpperName() in writeAccessorDefinitions()
464 OS << " if (is" << getLowerName() << "Expr)\n"; in writeAccessorDefinitions()
465 OS << " return " << getLowerName() << "Expr && (" << getLowerName() in writeAccessorDefinitions()
468 OS << " else\n"; in writeAccessorDefinitions()
469 OS << " return " << getLowerName() in writeAccessorDefinitions()
471 OS << "}\n"; in writeAccessorDefinitions()
476 OS << "unsigned " << getAttrName() << "Attr::get" << getUpperName() in writeAccessorDefinitions()
478 OS << " assert(!is" << getUpperName() << "Dependent());\n"; in writeAccessorDefinitions()
479 OS << " if (is" << getLowerName() << "Expr)\n"; in writeAccessorDefinitions()
480 OS << " return " << getLowerName() << "Expr ? " << getLowerName() in writeAccessorDefinitions()
484 OS << " else\n"; in writeAccessorDefinitions()
485 OS << " return 0; // FIXME\n"; in writeAccessorDefinitions()
486 OS << "}\n"; in writeAccessorDefinitions()
489 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
490 OS << "is" << getLowerName() << "Expr, is" << getLowerName() in writeCloneArgs()
496 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
501 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
502 OS << " if (is" << getLowerName() << "Expr)\n"; in writeCtorBody()
503 OS << " " << getLowerName() << "Expr = reinterpret_cast<Expr *>(" in writeCtorBody()
505 OS << " else\n"; in writeCtorBody()
506 OS << " " << getLowerName() in writeCtorBody()
511 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
512 OS << "is" << getLowerName() << "Expr(Is" << getUpperName() << "Expr)"; in writeCtorInitializers()
515 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
516 OS << "is" << getLowerName() << "Expr(false)"; in writeCtorDefaultInitializers()
519 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
520 OS << "bool Is" << getUpperName() << "Expr, void *" << getUpperName(); in writeCtorParameters()
523 void writeImplicitCtorArgs(raw_ostream &OS) const override { in writeImplicitCtorArgs()
524 OS << "Is" << getUpperName() << "Expr, " << getUpperName(); in writeImplicitCtorArgs()
527 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
528 OS << "bool is" << getLowerName() << "Expr;\n"; in writeDeclarations()
529 OS << "union {\n"; in writeDeclarations()
530 OS << "Expr *" << getLowerName() << "Expr;\n"; in writeDeclarations()
531 OS << "TypeSourceInfo *" << getLowerName() << "Type;\n"; in writeDeclarations()
532 OS << "};"; in writeDeclarations()
535 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
536 OS << "is" << getLowerName() << "Expr, " << getLowerName() << "Ptr"; in writePCHReadArgs()
539 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
540 OS << " bool is" << getLowerName() << "Expr = Record[Idx++];\n"; in writePCHReadDecls()
541 OS << " void *" << getLowerName() << "Ptr;\n"; in writePCHReadDecls()
542 OS << " if (is" << getLowerName() << "Expr)\n"; in writePCHReadDecls()
543 OS << " " << getLowerName() << "Ptr = ReadExpr(F);\n"; in writePCHReadDecls()
544 OS << " else\n"; in writePCHReadDecls()
545 OS << " " << getLowerName() in writePCHReadDecls()
549 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
550 OS << " Record.push_back(SA->is" << getUpperName() << "Expr());\n"; in writePCHWrite()
551 OS << " if (SA->is" << getUpperName() << "Expr())\n"; in writePCHWrite()
552 OS << " Record.AddStmt(SA->get" << getUpperName() << "Expr());\n"; in writePCHWrite()
553 OS << " else\n"; in writePCHWrite()
554 OS << " Record.AddTypeSourceInfo(SA->get" << getUpperName() in writePCHWrite()
558 void writeValue(raw_ostream &OS) const override { in writeValue()
559 OS << "\";\n"; in writeValue()
561 OS << " if (is" << getLowerName() << "Expr && " in writeValue()
563 OS << " " << getLowerName() << "Expr->printPretty(OS, nullptr, Policy);\n"; in writeValue()
564 OS << " OS << \""; in writeValue()
567 void writeDump(raw_ostream &OS) const override {} in writeDump()
569 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
570 OS << " if (SA->is" << getUpperName() << "Expr())\n"; in writeDumpChildren()
571 OS << " dumpStmt(SA->get" << getUpperName() << "Expr());\n"; in writeDumpChildren()
572 OS << " else\n"; in writeDumpChildren()
573 OS << " dumpType(SA->get" << getUpperName() in writeDumpChildren()
577 void writeHasChildren(raw_ostream &OS) const override { in writeHasChildren()
578 OS << "SA->is" << getUpperName() << "Expr()"; in writeHasChildren()
587 virtual void writeValueImpl(raw_ostream &OS) const { in writeValueImpl()
588 OS << " OS << Val;\n"; in writeValueImpl()
602 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
607 OS << " typedef " << Type << "* " << IteratorType << ";\n"; in writeAccessors()
608 OS << " " << IteratorType << " " << BeginFn << " const {" in writeAccessors()
610 OS << " " << IteratorType << " " << EndFn << " const {" in writeAccessors()
612 OS << " unsigned " << getLowerName() << "_size() const {" in writeAccessors()
614 OS << " llvm::iterator_range<" << IteratorType << "> " << RangeName in writeAccessors()
619 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
620 OS << ArgName << ", " << ArgSizeName; in writeCloneArgs()
623 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
625 OS << "A->" << getLowerName() << "_begin(), " in writeTemplateInstantiationArgs()
629 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
630 OS << " std::copy(" << getUpperName() << ", " << getUpperName() in writeCtorBody()
634 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
635 OS << ArgSizeName << "(" << getUpperName() << "Size), " in writeCtorInitializers()
640 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
641 OS << ArgSizeName << "(0), " << ArgName << "(nullptr)"; in writeCtorDefaultInitializers()
644 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
645 OS << getType() << " *" << getUpperName() << ", unsigned " in writeCtorParameters()
649 void writeImplicitCtorArgs(raw_ostream &OS) const override { in writeImplicitCtorArgs()
650 OS << getUpperName() << ", " << getUpperName() << "Size"; in writeImplicitCtorArgs()
653 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
654 OS << " unsigned " << ArgSizeName << ";\n"; in writeDeclarations()
655 OS << " " << getType() << " *" << ArgName << ";"; in writeDeclarations()
658 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
659 OS << " unsigned " << getLowerName() << "Size = Record[Idx++];\n"; in writePCHReadDecls()
660 OS << " SmallVector<" << getType() << ", 4> " in writePCHReadDecls()
662 OS << " " << getLowerName() << ".reserve(" << getLowerName() in writePCHReadDecls()
672 OS << " SmallVector<" << StorageType << ", 4> " in writePCHReadDecls()
674 OS << " " << StorageName << ".reserve(" << getLowerName() in writePCHReadDecls()
678 OS << " for (unsigned i = 0; i != " << getLowerName() << "Size; ++i)\n"; in writePCHReadDecls()
680 OS << " " << StorageName << ".push_back(" << read << ");\n"; in writePCHReadDecls()
683 OS << " for (unsigned i = 0; i != " << getLowerName() << "Size; ++i)\n"; in writePCHReadDecls()
684 OS << " " << getLowerName() << ".push_back(" in writePCHReadDecls()
689 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
690 OS << getLowerName() << ".data(), " << getLowerName() << "Size"; in writePCHReadArgs()
693 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
694 OS << " Record.push_back(SA->" << getLowerName() << "_size());\n"; in writePCHWrite()
695 OS << " for (auto &Val : SA->" << RangeName << "())\n"; in writePCHWrite()
696 OS << " " << WritePCHRecord(Type, "Val"); in writePCHWrite()
699 void writeValue(raw_ostream &OS) const override { in writeValue()
700 OS << "\";\n"; in writeValue()
701 OS << " bool isFirst = true;\n" in writeValue()
705 writeValueImpl(OS); in writeValue()
706 OS << " }\n"; in writeValue()
707 OS << " OS << \""; in writeValue()
710 void writeDump(raw_ostream &OS) const override { in writeDump()
711 OS << " for (const auto &Val : SA->" << RangeName << "())\n"; in writeDump()
712 OS << " OS << \" \" << Val;\n"; in writeDump()
747 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
748 OS << " " << type << " get" << getUpperName() << "() const {\n"; in writeAccessors()
749 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
750 OS << " }"; in writeAccessors()
753 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
754 OS << getLowerName(); in writeCloneArgs()
757 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
758 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
760 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
761 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
763 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
764 OS << getLowerName() << "(" << type << "(0))"; in writeCtorDefaultInitializers()
766 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
767 OS << type << " " << getUpperName(); in writeCtorParameters()
769 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
774 OS << "public:\n"; in writeDeclarations()
775 OS << " enum " << type << " {\n"; in writeDeclarations()
777 OS << " " << *i << ",\n"; in writeDeclarations()
778 OS << " " << *e << "\n"; in writeDeclarations()
779 OS << " };\n"; in writeDeclarations()
780 OS << "private:\n"; in writeDeclarations()
781 OS << " " << type << " " << getLowerName() << ";"; in writeDeclarations()
784 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
785 OS << " " << getAttrName() << "Attr::" << type << " " << getLowerName() in writePCHReadDecls()
790 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
791 OS << getLowerName(); in writePCHReadArgs()
794 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
795 OS << "Record.push_back(SA->get" << getUpperName() << "());\n"; in writePCHWrite()
798 void writeValue(raw_ostream &OS) const override { in writeValue()
802 OS << "\\\"\" << " << getAttrName() << "Attr::Convert" << type << "ToStr(get" in writeValue()
806 void writeDump(raw_ostream &OS) const override { in writeDump()
807 OS << " switch(SA->get" << getUpperName() << "()) {\n"; in writeDump()
809 OS << " case " << getAttrName() << "Attr::" << I << ":\n"; in writeDump()
810 OS << " OS << \" " << I << "\";\n"; in writeDump()
811 OS << " break;\n"; in writeDump()
813 OS << " }\n"; in writeDump()
816 void writeConversion(raw_ostream &OS) const { in writeConversion()
817 OS << " static bool ConvertStrTo" << type << "(StringRef Val, "; in writeConversion()
818 OS << type << " &Out) {\n"; in writeConversion()
819 OS << " Optional<" << type << "> R = llvm::StringSwitch<Optional<"; in writeConversion()
820 OS << type << ">>(Val)\n"; in writeConversion()
822 OS << " .Case(\"" << values[I] << "\", "; in writeConversion()
823 OS << getAttrName() << "Attr::" << enums[I] << ")\n"; in writeConversion()
825 OS << " .Default(Optional<" << type << ">());\n"; in writeConversion()
826 OS << " if (R) {\n"; in writeConversion()
827 OS << " Out = *R;\n return true;\n }\n"; in writeConversion()
828 OS << " return false;\n"; in writeConversion()
829 OS << " }\n\n"; in writeConversion()
835 OS << " static const char *Convert" << type << "ToStr(" in writeConversion()
841 OS << " case " << getAttrName() << "Attr::" << enums[I] in writeConversion()
844 OS << " }\n" in writeConversion()
855 void writeValueImpl(raw_ostream &OS) const override { in writeValueImpl()
859 OS << " OS << \"\\\"\" << " << getAttrName() << "Attr::Convert" << type in writeValueImpl()
879 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
884 OS << "public:\n"; in writeDeclarations()
885 OS << " enum " << type << " {\n"; in writeDeclarations()
887 OS << " " << *i << ",\n"; in writeDeclarations()
888 OS << " " << *e << "\n"; in writeDeclarations()
889 OS << " };\n"; in writeDeclarations()
890 OS << "private:\n"; in writeDeclarations()
892 VariadicArgument::writeDeclarations(OS); in writeDeclarations()
895 void writeDump(raw_ostream &OS) const override { in writeDump()
896 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writeDump()
899 OS << " switch(*I) {\n"; in writeDump()
901 OS << " case " << getAttrName() << "Attr::" << UI << ":\n"; in writeDump()
902 OS << " OS << \" " << UI << "\";\n"; in writeDump()
903 OS << " break;\n"; in writeDump()
905 OS << " }\n"; in writeDump()
906 OS << " }\n"; in writeDump()
909 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
910 OS << " unsigned " << getLowerName() << "Size = Record[Idx++];\n"; in writePCHReadDecls()
911 OS << " SmallVector<" << QualifiedTypeName << ", 4> " << getLowerName() in writePCHReadDecls()
913 OS << " " << getLowerName() << ".reserve(" << getLowerName() in writePCHReadDecls()
915 OS << " for (unsigned i = " << getLowerName() << "Size; i; --i)\n"; in writePCHReadDecls()
916 OS << " " << getLowerName() << ".push_back(" << "static_cast<" in writePCHReadDecls()
920 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
921 OS << " Record.push_back(SA->" << getLowerName() << "_size());\n"; in writePCHWrite()
922 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writePCHWrite()
925 OS << " " << WritePCHRecord(QualifiedTypeName, "(*i)"); in writePCHWrite()
928 void writeConversion(raw_ostream &OS) const { in writeConversion()
929 OS << " static bool ConvertStrTo" << type << "(StringRef Val, "; in writeConversion()
930 OS << type << " &Out) {\n"; in writeConversion()
931 OS << " Optional<" << type << "> R = llvm::StringSwitch<Optional<"; in writeConversion()
932 OS << type << ">>(Val)\n"; in writeConversion()
934 OS << " .Case(\"" << values[I] << "\", "; in writeConversion()
935 OS << getAttrName() << "Attr::" << enums[I] << ")\n"; in writeConversion()
937 OS << " .Default(Optional<" << type << ">());\n"; in writeConversion()
938 OS << " if (R) {\n"; in writeConversion()
939 OS << " Out = *R;\n return true;\n }\n"; in writeConversion()
940 OS << " return false;\n"; in writeConversion()
941 OS << " }\n\n"; in writeConversion()
943 OS << " static const char *Convert" << type << "ToStr(" in writeConversion()
949 OS << " case " << getAttrName() << "Attr::" << enums[I] in writeConversion()
952 OS << " }\n" in writeConversion()
964 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
965 OS << " VersionTuple get" << getUpperName() << "() const {\n"; in writeAccessors()
966 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
967 OS << " }\n"; in writeAccessors()
968 OS << " void set" << getUpperName() in writeAccessors()
970 OS << " " << getLowerName() << " = V;\n"; in writeAccessors()
971 OS << " }"; in writeAccessors()
974 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
975 OS << "get" << getUpperName() << "()"; in writeCloneArgs()
978 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
979 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
982 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
983 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
986 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
987 OS << getLowerName() << "()"; in writeCtorDefaultInitializers()
990 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
991 OS << "VersionTuple " << getUpperName(); in writeCtorParameters()
994 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
995 OS << "VersionTuple " << getLowerName() << ";\n"; in writeDeclarations()
998 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
999 OS << " VersionTuple " << getLowerName() in writePCHReadDecls()
1003 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
1004 OS << getLowerName(); in writePCHReadArgs()
1007 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
1008 OS << " Record.AddVersionTuple(SA->get" << getUpperName() << "());\n"; in writePCHWrite()
1011 void writeValue(raw_ostream &OS) const override { in writeValue()
1012 OS << getLowerName() << "=\" << get" << getUpperName() << "() << \""; in writeValue()
1015 void writeDump(raw_ostream &OS) const override { in writeDump()
1016 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n"; in writeDump()
1026 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
1027 OS << " if (!" in writeASTVisitorTraversal()
1029 OS << " return false;\n"; in writeASTVisitorTraversal()
1032 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
1033 OS << "tempInst" << getUpperName(); in writeTemplateInstantiationArgs()
1036 void writeTemplateInstantiation(raw_ostream &OS) const override { in writeTemplateInstantiation()
1037 OS << " " << getType() << " tempInst" << getUpperName() << ";\n"; in writeTemplateInstantiation()
1038 OS << " {\n"; in writeTemplateInstantiation()
1039 OS << " EnterExpressionEvaluationContext " in writeTemplateInstantiation()
1041 OS << " ExprResult " << "Result = S.SubstExpr(" in writeTemplateInstantiation()
1043 OS << " tempInst" << getUpperName() << " = " in writeTemplateInstantiation()
1045 OS << " }\n"; in writeTemplateInstantiation()
1048 void writeDump(raw_ostream &OS) const override {} in writeDump()
1050 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
1051 OS << " dumpStmt(SA->get" << getUpperName() << "());\n"; in writeDumpChildren()
1054 void writeHasChildren(raw_ostream &OS) const override { OS << "true"; } in writeHasChildren()
1063 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
1064 OS << " {\n"; in writeASTVisitorTraversal()
1065 OS << " " << getType() << " *I = A->" << getLowerName() in writeASTVisitorTraversal()
1067 OS << " " << getType() << " *E = A->" << getLowerName() in writeASTVisitorTraversal()
1069 OS << " for (; I != E; ++I) {\n"; in writeASTVisitorTraversal()
1070 OS << " if (!getDerived().TraverseStmt(*I))\n"; in writeASTVisitorTraversal()
1071 OS << " return false;\n"; in writeASTVisitorTraversal()
1072 OS << " }\n"; in writeASTVisitorTraversal()
1073 OS << " }\n"; in writeASTVisitorTraversal()
1076 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
1077 OS << "tempInst" << getUpperName() << ", " in writeTemplateInstantiationArgs()
1081 void writeTemplateInstantiation(raw_ostream &OS) const override { in writeTemplateInstantiation()
1082 OS << " auto *tempInst" << getUpperName() in writeTemplateInstantiation()
1085 OS << " {\n"; in writeTemplateInstantiation()
1086 OS << " EnterExpressionEvaluationContext " in writeTemplateInstantiation()
1088 OS << " " << getType() << " *TI = tempInst" << getUpperName() in writeTemplateInstantiation()
1090 OS << " " << getType() << " *I = A->" << getLowerName() in writeTemplateInstantiation()
1092 OS << " " << getType() << " *E = A->" << getLowerName() in writeTemplateInstantiation()
1094 OS << " for (; I != E; ++I, ++TI) {\n"; in writeTemplateInstantiation()
1095 OS << " ExprResult Result = S.SubstExpr(*I, TemplateArgs);\n"; in writeTemplateInstantiation()
1096 OS << " *TI = Result.getAs<Expr>();\n"; in writeTemplateInstantiation()
1097 OS << " }\n"; in writeTemplateInstantiation()
1098 OS << " }\n"; in writeTemplateInstantiation()
1101 void writeDump(raw_ostream &OS) const override {} in writeDump()
1103 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
1104 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writeDumpChildren()
1107 OS << " dumpStmt(*I);\n"; in writeDumpChildren()
1110 void writeHasChildren(raw_ostream &OS) const override { in writeHasChildren()
1111 OS << "SA->" << getLowerName() << "_begin() != " in writeHasChildren()
1122 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
1123 OS << " for (size_t I = 0, E = " << getArgSizeName() << "; I != E;\n" in writeCtorBody()
1134 void writeValueImpl(raw_ostream &OS) const override { in writeValueImpl()
1135 OS << " OS << \"\\\"\" << Val << \"\\\"\";\n"; in writeValueImpl()
1145 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
1146 OS << " QualType get" << getUpperName() << "() const {\n"; in writeAccessors()
1147 OS << " return " << getLowerName() << "->getType();\n"; in writeAccessors()
1148 OS << " }"; in writeAccessors()
1149 OS << " " << getType() << " get" << getUpperName() << "Loc() const {\n"; in writeAccessors()
1150 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
1151 OS << " }"; in writeAccessors()
1154 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
1155 OS << "A->get" << getUpperName() << "Loc()"; in writeTemplateInstantiationArgs()
1158 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
1159 OS << " " << WritePCHRecord( in writePCHWrite()
1230 static void writeAvailabilityValue(raw_ostream &OS) { in writeAvailabilityValue() argument
1231 OS << "\" << getPlatform()->getName();\n" in writeAvailabilityValue()
1240 static void writeDeprecatedAttrValue(raw_ostream &OS, std::string &Variety) { in writeDeprecatedAttrValue() argument
1241 OS << "\\\"\" << getMessage() << \"\\\"\";\n"; in writeDeprecatedAttrValue()
1244 OS << " if (!getReplacement().empty()) OS << \", \\\"\"" in writeDeprecatedAttrValue()
1246 OS << " OS << \""; in writeDeprecatedAttrValue()
1249 static void writeGetSpellingFunction(Record &R, raw_ostream &OS) { in writeGetSpellingFunction() argument
1252 OS << "const char *" << R.getName() << "Attr::getSpelling() const {\n"; in writeGetSpellingFunction()
1254 OS << " return \"(No spelling)\";\n}\n\n"; in writeGetSpellingFunction()
1258 OS << " switch (SpellingListIndex) {\n" in writeGetSpellingFunction()
1264 OS << " case " << I << ":\n" in writeGetSpellingFunction()
1267 OS << " }\n"; in writeGetSpellingFunction()
1269 OS << "}\n\n"; in writeGetSpellingFunction()
1275 raw_ostream &OS) { in writePrettyPrintFunction() argument
1278 OS << "void " << R.getName() << "Attr::printPretty(" in writePrettyPrintFunction()
1282 OS << "}\n\n"; in writePrettyPrintFunction()
1286 OS << in writePrettyPrintFunction()
1332 OS << in writePrettyPrintFunction()
1337 OS << " \";\n"; in writePrettyPrintFunction()
1338 OS << " printPrettyPragma(OS, Policy);\n"; in writePrettyPrintFunction()
1339 OS << " OS << \"\\n\";"; in writePrettyPrintFunction()
1340 OS << " break;\n"; in writePrettyPrintFunction()
1341 OS << " }\n"; in writePrettyPrintFunction()
1359 OS << "("; in writePrettyPrintFunction()
1361 writeAvailabilityValue(OS); in writePrettyPrintFunction()
1363 writeDeprecatedAttrValue(OS, Variety); in writePrettyPrintFunction()
1368 if (index++) OS << ", "; in writePrettyPrintFunction()
1369 arg->writeValue(OS); in writePrettyPrintFunction()
1374 OS << ")"; in writePrettyPrintFunction()
1375 OS << Suffix + "\";\n"; in writePrettyPrintFunction()
1377 OS << in writePrettyPrintFunction()
1383 OS << "}\n"; in writePrettyPrintFunction()
1385 OS << "}\n\n"; in writePrettyPrintFunction()
1409 static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) { in writeAttrAccessorDefinition() argument
1419 OS << " bool " << Name << "() const { return SpellingListIndex == "; in writeAttrAccessorDefinition()
1421 OS << getSpellingListIndex(SpellingList, Spellings[Index]); in writeAttrAccessorDefinition()
1423 OS << " ||\n SpellingListIndex == "; in writeAttrAccessorDefinition()
1425 OS << "; }\n"; in writeAttrAccessorDefinition()
1494 raw_ostream &OS) { in WriteSemanticSpellingSwitch() argument
1495 OS << " switch (" << VarName << ") {\n default: " in WriteSemanticSpellingSwitch()
1498 OS << " case " << I.first << ": return " << I.second << ";\n"; in WriteSemanticSpellingSwitch()
1499 OS << " }\n"; in WriteSemanticSpellingSwitch()
1503 static void emitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrLateParsedList() argument
1504 OS << "#if defined(CLANG_ATTR_LATE_PARSED_LIST)\n"; in emitClangAttrLateParsedList()
1517 OS << ".Case(\"" << I.name() << "\", " << LateParsed << ")\n"; in emitClangAttrLateParsedList()
1521 OS << "#endif // CLANG_ATTR_LATE_PARSED_LIST\n\n"; in emitClangAttrLateParsedList()
1525 static void emitClangAttrTypeArgList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrTypeArgList() argument
1526 OS << "#if defined(CLANG_ATTR_TYPE_ARG_LIST)\n"; in emitClangAttrTypeArgList()
1543 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrTypeArgList()
1546 OS << "#endif // CLANG_ATTR_TYPE_ARG_LIST\n\n"; in emitClangAttrTypeArgList()
1551 static void emitClangAttrArgContextList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrArgContextList() argument
1552 OS << "#if defined(CLANG_ATTR_ARG_CONTEXT_LIST)\n"; in emitClangAttrArgContextList()
1565 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrArgContextList()
1568 OS << "#endif // CLANG_ATTR_ARG_CONTEXT_LIST\n\n"; in emitClangAttrArgContextList()
1581 static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrIdentifierArgList() argument
1582 OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n"; in emitClangAttrIdentifierArgList()
1596 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrIdentifierArgList()
1599 OS << "#endif // CLANG_ATTR_IDENTIFIER_ARG_LIST\n\n"; in emitClangAttrIdentifierArgList()
1605 void EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrClass() argument
1606 emitSourceFileHeader("Attribute classes' definitions", OS); in EmitClangAttrClass()
1608 OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n"; in EmitClangAttrClass()
1609 OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n"; in EmitClangAttrClass()
1639 OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n"; in EmitClangAttrClass()
1649 Args.back()->writeDeclarations(OS); in EmitClangAttrClass()
1650 OS << "\n\n"; in EmitClangAttrClass()
1660 OS << "public:\n"; in EmitClangAttrClass()
1674 OS << CreateSemanticSpellings(Spellings, SemanticToSyntacticMap); in EmitClangAttrClass()
1678 OS << " static " << R.getName() << "Attr *CreateImplicit("; in EmitClangAttrClass()
1679 OS << "ASTContext &Ctx"; in EmitClangAttrClass()
1681 OS << ", Spelling S"; in EmitClangAttrClass()
1684 OS << ", "; in EmitClangAttrClass()
1685 ai->writeCtorParameters(OS); in EmitClangAttrClass()
1687 OS << ", SourceRange Loc = SourceRange()"; in EmitClangAttrClass()
1688 OS << ") {\n"; in EmitClangAttrClass()
1689 OS << " auto *A = new (Ctx) " << R.getName(); in EmitClangAttrClass()
1690 OS << "Attr(Loc, Ctx, "; in EmitClangAttrClass()
1693 ai->writeImplicitCtorArgs(OS); in EmitClangAttrClass()
1694 OS << ", "; in EmitClangAttrClass()
1696 OS << (ElideSpelling ? "0" : "S") << ");\n"; in EmitClangAttrClass()
1697 OS << " A->setImplicit(true);\n"; in EmitClangAttrClass()
1698 OS << " return A;\n }\n\n"; in EmitClangAttrClass()
1717 OS << " " << R.getName() << "Attr(SourceRange R, ASTContext &Ctx\n"; in EmitClangAttrClass()
1720 OS << " , "; in EmitClangAttrClass()
1721 ai->writeCtorParameters(OS); in EmitClangAttrClass()
1722 OS << "\n"; in EmitClangAttrClass()
1725 OS << " , "; in EmitClangAttrClass()
1726 OS << "unsigned SI\n"; in EmitClangAttrClass()
1728 OS << " )\n"; in EmitClangAttrClass()
1729 OS << " : " << SuperName << "(attr::" << R.getName() << ", R, SI, " in EmitClangAttrClass()
1734 OS << " , "; in EmitClangAttrClass()
1736 ai->writeCtorDefaultInitializers(OS); in EmitClangAttrClass()
1738 ai->writeCtorInitializers(OS); in EmitClangAttrClass()
1740 OS << "\n"; in EmitClangAttrClass()
1743 OS << " {\n"; in EmitClangAttrClass()
1747 ai->writeCtorBody(OS); in EmitClangAttrClass()
1749 OS << " }\n\n"; in EmitClangAttrClass()
1766 OS << " " << R.getName() << "Attr *clone(ASTContext &C) const;\n"; in EmitClangAttrClass()
1767 OS << " void printPretty(raw_ostream &OS,\n" in EmitClangAttrClass()
1769 OS << " const char *getSpelling() const;\n"; in EmitClangAttrClass()
1773 OS << " Spelling getSemanticSpelling() const {\n"; in EmitClangAttrClass()
1775 OS); in EmitClangAttrClass()
1776 OS << " }\n"; in EmitClangAttrClass()
1779 writeAttrAccessorDefinition(R, OS); in EmitClangAttrClass()
1782 ai->writeAccessors(OS); in EmitClangAttrClass()
1783 OS << "\n\n"; in EmitClangAttrClass()
1789 static_cast<const EnumArgument *>(ai.get())->writeConversion(OS); in EmitClangAttrClass()
1792 ->writeConversion(OS); in EmitClangAttrClass()
1795 OS << R.getValueAsString("AdditionalMembers"); in EmitClangAttrClass()
1796 OS << "\n\n"; in EmitClangAttrClass()
1798 OS << " static bool classof(const Attr *A) { return A->getKind() == " in EmitClangAttrClass()
1801 OS << "};\n\n"; in EmitClangAttrClass()
1804 OS << "#endif // LLVM_CLANG_ATTR_CLASSES_INC\n"; in EmitClangAttrClass()
1808 void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrImpl() argument
1809 emitSourceFileHeader("Attribute classes' member function definitions", OS); in EmitClangAttrImpl()
1825 ai->writeAccessorDefinitions(OS); in EmitClangAttrImpl()
1827 OS << R.getName() << "Attr *" << R.getName() in EmitClangAttrImpl()
1829 OS << " auto *A = new (C) " << R.getName() << "Attr(getLocation(), C"; in EmitClangAttrImpl()
1831 OS << ", "; in EmitClangAttrImpl()
1832 ai->writeCloneArgs(OS); in EmitClangAttrImpl()
1834 OS << ", getSpellingListIndex());\n"; in EmitClangAttrImpl()
1835 OS << " A->Inherited = Inherited;\n"; in EmitClangAttrImpl()
1836 OS << " A->IsPackExpansion = IsPackExpansion;\n"; in EmitClangAttrImpl()
1837 OS << " A->Implicit = Implicit;\n"; in EmitClangAttrImpl()
1838 OS << " return A;\n}\n\n"; in EmitClangAttrImpl()
1840 writePrettyPrintFunction(R, Args, OS); in EmitClangAttrImpl()
1841 writeGetSpellingFunction(R, OS); in EmitClangAttrImpl()
1847 OS << " switch (getKind()) {\n"; in EmitClangAttrImpl()
1853 OS << " case attr::" << R.getName() << ":\n"; in EmitClangAttrImpl()
1854 OS << " return cast<" << R.getName() << "Attr>(this)->" << Method in EmitClangAttrImpl()
1857 OS << " }\n"; in EmitClangAttrImpl()
1858 OS << " llvm_unreachable(\"Unexpected attribute kind!\");\n"; in EmitClangAttrImpl()
1859 OS << "}\n\n"; in EmitClangAttrImpl()
1862 OS << "const char *Attr::getSpelling() const {\n"; in EmitClangAttrImpl()
1865 OS << "Attr *Attr::clone(ASTContext &C) const {\n"; in EmitClangAttrImpl()
1868 OS << "void Attr::printPretty(raw_ostream &OS, " in EmitClangAttrImpl()
1875 static void emitAttrList(raw_ostream &OS, StringRef Class, in emitAttrList() argument
1878 OS << Class << "(" << Cur->getName() << ")\n"; in emitAttrList()
1908 static void emitDefaultDefine(raw_ostream &OS, StringRef name, in emitDefaultDefine() argument
1910 OS << "#ifndef " << name << "\n"; in emitDefaultDefine()
1911 OS << "#define " << name << "(NAME) "; in emitDefaultDefine()
1912 if (superName) OS << superName << "(NAME)"; in emitDefaultDefine()
1913 OS << "\n#endif\n\n"; in emitDefaultDefine()
1929 void emitDefaultDefines(raw_ostream &OS) const { in emitDefaultDefines()
1932 emitDefaultDefine(OS, Descriptor.MacroName, in emitDefaultDefines()
1937 void emitUndefs(raw_ostream &OS) const { in emitUndefs()
1938 OS << "#undef " << Descriptor.MacroName << "\n"; in emitUndefs()
1941 void emitAttrList(raw_ostream &OS) const { in emitAttrList()
1943 SubClass->emitAttrList(OS); in emitAttrList()
1946 ::emitAttrList(OS, Descriptor.MacroName, Attrs); in emitAttrList()
1954 void emitAttrRange(raw_ostream &OS) const { in emitAttrRange()
1955 OS << "ATTR_RANGE(" << Descriptor.TableGenName in emitAttrRange()
2019 void emitDefaultDefines(raw_ostream &OS) const { in emitDefaultDefines()
2021 Class->emitDefaultDefines(OS); in emitDefaultDefines()
2025 void emitUndefs(raw_ostream &OS) const { in emitUndefs()
2027 Class->emitUndefs(OS); in emitUndefs()
2031 void emitAttrLists(raw_ostream &OS) const { in emitAttrLists()
2033 Classes[0]->emitAttrList(OS); in emitAttrLists()
2036 void emitAttrRanges(raw_ostream &OS) const { in emitAttrRanges()
2038 Class->emitAttrRange(OS); in emitAttrRanges()
2072 void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrList() argument
2073 emitSourceFileHeader("List of all attributes that Clang recognizes", OS); in EmitClangAttrList()
2078 Hierarchy.emitDefaultDefines(OS); in EmitClangAttrList()
2079 emitDefaultDefine(OS, "PRAGMA_SPELLING_ATTR", nullptr); in EmitClangAttrList()
2096 Hierarchy.emitAttrLists(OS); in EmitClangAttrList()
2099 emitAttrList(OS, "PRAGMA_SPELLING_ATTR", PragmaAttrs); in EmitClangAttrList()
2102 OS << "#ifdef ATTR_RANGE\n"; in EmitClangAttrList()
2103 Hierarchy.emitAttrRanges(OS); in EmitClangAttrList()
2104 OS << "#undef ATTR_RANGE\n"; in EmitClangAttrList()
2105 OS << "#endif\n"; in EmitClangAttrList()
2107 Hierarchy.emitUndefs(OS); in EmitClangAttrList()
2108 OS << "#undef PRAGMA_SPELLING_ATTR\n"; in EmitClangAttrList()
2112 void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrPCHRead() argument
2113 emitSourceFileHeader("Attribute deserialization code", OS); in EmitClangAttrPCHRead()
2120 OS << " switch (Kind) {\n"; in EmitClangAttrPCHRead()
2126 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrPCHRead()
2128 OS << " bool isInherited = Record[Idx++];\n"; in EmitClangAttrPCHRead()
2129 OS << " bool isImplicit = Record[Idx++];\n"; in EmitClangAttrPCHRead()
2130 OS << " unsigned Spelling = Record[Idx++];\n"; in EmitClangAttrPCHRead()
2135 Args.back()->writePCHReadDecls(OS); in EmitClangAttrPCHRead()
2137 OS << " New = new (Context) " << R.getName() << "Attr(Range, Context"; in EmitClangAttrPCHRead()
2139 OS << ", "; in EmitClangAttrPCHRead()
2140 ri->writePCHReadArgs(OS); in EmitClangAttrPCHRead()
2142 OS << ", Spelling);\n"; in EmitClangAttrPCHRead()
2144 OS << " cast<InheritableAttr>(New)->setInherited(isInherited);\n"; in EmitClangAttrPCHRead()
2145 OS << " New->setImplicit(isImplicit);\n"; in EmitClangAttrPCHRead()
2146 OS << " break;\n"; in EmitClangAttrPCHRead()
2147 OS << " }\n"; in EmitClangAttrPCHRead()
2149 OS << " }\n"; in EmitClangAttrPCHRead()
2153 void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrPCHWrite() argument
2154 emitSourceFileHeader("Attribute serialization code", OS); in EmitClangAttrPCHWrite()
2159 OS << " switch (A->getKind()) {\n"; in EmitClangAttrPCHWrite()
2164 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrPCHWrite()
2167 OS << " const auto *SA = cast<" << R.getName() in EmitClangAttrPCHWrite()
2170 OS << " Record.push_back(SA->isInherited());\n"; in EmitClangAttrPCHWrite()
2171 OS << " Record.push_back(A->isImplicit());\n"; in EmitClangAttrPCHWrite()
2172 OS << " Record.push_back(A->getSpellingListIndex());\n"; in EmitClangAttrPCHWrite()
2175 createArgument(*Arg, R.getName())->writePCHWrite(OS); in EmitClangAttrPCHWrite()
2176 OS << " break;\n"; in EmitClangAttrPCHWrite()
2177 OS << " }\n"; in EmitClangAttrPCHWrite()
2179 OS << " }\n"; in EmitClangAttrPCHWrite()
2242 const std::vector<Record *> &Attrs, raw_ostream &OS, in GenerateHasAttrSpellingStringSwitch() argument
2286 OS << " .Case(\"" << S.name() << "\", " << TestStr << ")\n"; in GenerateHasAttrSpellingStringSwitch()
2288 OS << " .Default(0);\n"; in GenerateHasAttrSpellingStringSwitch()
2292 void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrHasAttrImpl() argument
2293 emitSourceFileHeader("Code to implement the __has_attribute logic", OS); in EmitClangAttrHasAttrImpl()
2318 OS << "const llvm::Triple &T = Target.getTriple();\n"; in EmitClangAttrHasAttrImpl()
2319 OS << "switch (Syntax) {\n"; in EmitClangAttrHasAttrImpl()
2320 OS << "case AttrSyntax::GNU:\n"; in EmitClangAttrHasAttrImpl()
2321 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
2322 GenerateHasAttrSpellingStringSwitch(GNU, OS, "GNU"); in EmitClangAttrHasAttrImpl()
2323 OS << "case AttrSyntax::Declspec:\n"; in EmitClangAttrHasAttrImpl()
2324 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
2325 GenerateHasAttrSpellingStringSwitch(Declspec, OS, "Declspec"); in EmitClangAttrHasAttrImpl()
2326 OS << "case AttrSyntax::Pragma:\n"; in EmitClangAttrHasAttrImpl()
2327 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
2328 GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma"); in EmitClangAttrHasAttrImpl()
2329 OS << "case AttrSyntax::CXX: {\n"; in EmitClangAttrHasAttrImpl()
2333 OS << " else "; in EmitClangAttrHasAttrImpl()
2335 OS << "if (!Scope || Scope->getName() == \"\") {\n"; in EmitClangAttrHasAttrImpl()
2337 OS << "if (Scope->getName() == \"" << I->first << "\") {\n"; in EmitClangAttrHasAttrImpl()
2338 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
2339 GenerateHasAttrSpellingStringSwitch(I->second, OS, "CXX11", I->first); in EmitClangAttrHasAttrImpl()
2340 OS << "}"; in EmitClangAttrHasAttrImpl()
2342 OS << "\n}\n"; in EmitClangAttrHasAttrImpl()
2343 OS << "}\n"; in EmitClangAttrHasAttrImpl()
2346 void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrSpellingListIndex() argument
2348 "into internal identifiers", OS); in EmitClangAttrSpellingListIndex()
2350 OS << " switch (AttrKind) {\n"; in EmitClangAttrSpellingListIndex()
2356 OS << " case AT_" << I.first << ": {\n"; in EmitClangAttrSpellingListIndex()
2358 OS << " if (Name == \"" << Spellings[I].name() << "\" && " in EmitClangAttrSpellingListIndex()
2371 OS << " break;\n"; in EmitClangAttrSpellingListIndex()
2372 OS << " }\n"; in EmitClangAttrSpellingListIndex()
2375 OS << " }\n"; in EmitClangAttrSpellingListIndex()
2376 OS << " return 0;\n"; in EmitClangAttrSpellingListIndex()
2380 void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrASTVisitor() argument
2381 emitSourceFileHeader("Used by RecursiveASTVisitor to visit attributes.", OS); in EmitClangAttrASTVisitor()
2388 OS << "#ifdef ATTR_VISITOR_DECLS_ONLY\n\n"; in EmitClangAttrASTVisitor()
2393 OS << " bool Traverse" in EmitClangAttrASTVisitor()
2395 OS << " bool Visit" in EmitClangAttrASTVisitor()
2400 OS << "\n#else // ATTR_VISITOR_DECLS_ONLY\n\n"; in EmitClangAttrASTVisitor()
2408 OS << "template <typename Derived>\n" in EmitClangAttrASTVisitor()
2418 createArgument(*Arg, R.getName())->writeASTVisitorTraversal(OS); in EmitClangAttrASTVisitor()
2420 OS << " return true;\n"; in EmitClangAttrASTVisitor()
2421 OS << "}\n\n"; in EmitClangAttrASTVisitor()
2425 OS << "template <typename Derived>\n" in EmitClangAttrASTVisitor()
2437 OS << " case attr::" << R.getName() << ":\n" in EmitClangAttrASTVisitor()
2441 OS << " }\n"; // end switch in EmitClangAttrASTVisitor()
2442 OS << " llvm_unreachable(\"bad attribute kind\");\n"; in EmitClangAttrASTVisitor()
2443 OS << "}\n"; // end function in EmitClangAttrASTVisitor()
2444 OS << "#endif // ATTR_VISITOR_DECLS_ONLY\n"; in EmitClangAttrASTVisitor()
2448 void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrTemplateInstantiate() argument
2449 emitSourceFileHeader("Template instantiation code for attributes", OS); in EmitClangAttrTemplateInstantiate()
2453 OS << "namespace clang {\n" in EmitClangAttrTemplateInstantiate()
2465 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrTemplateInstantiate()
2469 OS << " return nullptr;\n"; in EmitClangAttrTemplateInstantiate()
2470 OS << " }\n"; in EmitClangAttrTemplateInstantiate()
2474 OS << " const auto *A = cast<" in EmitClangAttrTemplateInstantiate()
2479 OS << " return A->clone(C);\n"; in EmitClangAttrTemplateInstantiate()
2480 OS << " }\n"; in EmitClangAttrTemplateInstantiate()
2492 ai->writeTemplateInstantiation(OS); in EmitClangAttrTemplateInstantiate()
2494 OS << " return new (C) " << R.getName() << "Attr(A->getLocation(), C"; in EmitClangAttrTemplateInstantiate()
2496 OS << ", "; in EmitClangAttrTemplateInstantiate()
2497 ai->writeTemplateInstantiationArgs(OS); in EmitClangAttrTemplateInstantiate()
2499 OS << ", A->getSpellingListIndex());\n }\n"; in EmitClangAttrTemplateInstantiate()
2501 OS << " } // end switch\n" in EmitClangAttrTemplateInstantiate()
2510 void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrList() argument
2511 emitSourceFileHeader("List of all attributes that Clang recognizes", OS); in EmitClangAttrParsedAttrList()
2513 OS << "#ifndef PARSED_ATTR\n"; in EmitClangAttrParsedAttrList()
2514 OS << "#define PARSED_ATTR(NAME) NAME\n"; in EmitClangAttrParsedAttrList()
2515 OS << "#endif\n\n"; in EmitClangAttrParsedAttrList()
2519 OS << "PARSED_ATTR(" << I.first << ")\n"; in EmitClangAttrParsedAttrList()
2527 static void emitArgInfo(const Record &R, std::stringstream &OS) { in emitArgInfo() argument
2542 OS << ArgCount << ", " << (HasVariadic ? 15 : OptCount); in emitArgInfo()
2545 static void GenerateDefaultAppertainsTo(raw_ostream &OS) { in GenerateDefaultAppertainsTo() argument
2546 OS << "static bool defaultAppertainsTo(Sema &, const AttributeList &,"; in GenerateDefaultAppertainsTo()
2547 OS << "const Decl *) {\n"; in GenerateDefaultAppertainsTo()
2548 OS << " return true;\n"; in GenerateDefaultAppertainsTo()
2549 OS << "}\n\n"; in GenerateDefaultAppertainsTo()
2676 raw_ostream &OS) { in GenerateCustomAppertainsTo() argument
2695 OS << "static bool " << FnName << "(const Decl *D) {\n"; in GenerateCustomAppertainsTo()
2696 OS << " if (const auto *S = dyn_cast<"; in GenerateCustomAppertainsTo()
2697 OS << GetSubjectWithSuffix(Base); in GenerateCustomAppertainsTo()
2698 OS << ">(D))\n"; in GenerateCustomAppertainsTo()
2699 OS << " return " << Subject.getValueAsString("CheckCode") << ";\n"; in GenerateCustomAppertainsTo()
2700 OS << " return false;\n"; in GenerateCustomAppertainsTo()
2701 OS << "}\n\n"; in GenerateCustomAppertainsTo()
2707 static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) { in GenerateAppertainsTo() argument
2738 SS << "!" << GenerateCustomAppertainsTo(**I, OS) << "(D)"; in GenerateAppertainsTo()
2758 OS << SS.str(); in GenerateAppertainsTo()
2762 static void GenerateDefaultLangOptRequirements(raw_ostream &OS) { in GenerateDefaultLangOptRequirements() argument
2763 OS << "static bool defaultDiagnoseLangOpts(Sema &, "; in GenerateDefaultLangOptRequirements()
2764 OS << "const AttributeList &) {\n"; in GenerateDefaultLangOptRequirements()
2765 OS << " return true;\n"; in GenerateDefaultLangOptRequirements()
2766 OS << "}\n\n"; in GenerateDefaultLangOptRequirements()
2770 raw_ostream &OS) { in GenerateLangOptRequirements() argument
2800 OS << "static bool " << FnName << "(Sema &S, const AttributeList &Attr) {\n"; in GenerateLangOptRequirements()
2801 OS << " if (" << Test << ")\n"; in GenerateLangOptRequirements()
2802 OS << " return true;\n\n"; in GenerateLangOptRequirements()
2803 OS << " S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) "; in GenerateLangOptRequirements()
2804 OS << "<< Attr.getName();\n"; in GenerateLangOptRequirements()
2805 OS << " return false;\n"; in GenerateLangOptRequirements()
2806 OS << "}\n\n"; in GenerateLangOptRequirements()
2812 static void GenerateDefaultTargetRequirements(raw_ostream &OS) { in GenerateDefaultTargetRequirements() argument
2813 OS << "static bool defaultTargetRequirements(const TargetInfo &) {\n"; in GenerateDefaultTargetRequirements()
2814 OS << " return true;\n"; in GenerateDefaultTargetRequirements()
2815 OS << "}\n\n"; in GenerateDefaultTargetRequirements()
2820 raw_ostream &OS) { in GenerateTargetRequirements() argument
2863 OS << "static bool " << FnName << "(const TargetInfo &Target) {\n"; in GenerateTargetRequirements()
2864 OS << " const llvm::Triple &T = Target.getTriple();\n"; in GenerateTargetRequirements()
2865 OS << " return " << Test << ";\n"; in GenerateTargetRequirements()
2866 OS << "}\n\n"; in GenerateTargetRequirements()
2872 static void GenerateDefaultSpellingIndexToSemanticSpelling(raw_ostream &OS) { in GenerateDefaultSpellingIndexToSemanticSpelling() argument
2873 OS << "static unsigned defaultSpellingIndexToSemanticSpelling(" in GenerateDefaultSpellingIndexToSemanticSpelling()
2875 OS << " return UINT_MAX;\n"; in GenerateDefaultSpellingIndexToSemanticSpelling()
2876 OS << "}\n\n"; in GenerateDefaultSpellingIndexToSemanticSpelling()
2880 raw_ostream &OS) { in GenerateSpellingIndexToSemanticSpelling() argument
2897 OS << "static unsigned " << Name << "(const AttributeList &Attr) {\n"; in GenerateSpellingIndexToSemanticSpelling()
2898 OS << Enum; in GenerateSpellingIndexToSemanticSpelling()
2899 OS << " unsigned Idx = Attr.getAttributeSpellingListIndex();\n"; in GenerateSpellingIndexToSemanticSpelling()
2900 WriteSemanticSpellingSwitch("Idx", SemanticToSyntacticMap, OS); in GenerateSpellingIndexToSemanticSpelling()
2901 OS << "}\n\n"; in GenerateSpellingIndexToSemanticSpelling()
2918 void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrImpl() argument
2919 emitSourceFileHeader("Parsed attribute helpers", OS); in EmitClangAttrParsedAttrImpl()
2928 GenerateDefaultAppertainsTo(OS); in EmitClangAttrParsedAttrImpl()
2929 GenerateDefaultLangOptRequirements(OS); in EmitClangAttrParsedAttrImpl()
2930 GenerateDefaultTargetRequirements(OS); in EmitClangAttrParsedAttrImpl()
2931 GenerateDefaultSpellingIndexToSemanticSpelling(OS); in EmitClangAttrParsedAttrImpl()
2954 SS << ", " << GenerateAppertainsTo(*I->second, OS); in EmitClangAttrParsedAttrImpl()
2955 SS << ", " << GenerateLangOptRequirements(*I->second, OS); in EmitClangAttrParsedAttrImpl()
2956 SS << ", " << GenerateTargetRequirements(*I->second, Dupes, OS); in EmitClangAttrParsedAttrImpl()
2957 SS << ", " << GenerateSpellingIndexToSemanticSpelling(*I->second, OS); in EmitClangAttrParsedAttrImpl()
2966 OS << "static const ParsedAttrInfo AttrInfoMap[AttributeList::UnknownAttribute + 1] = {\n"; in EmitClangAttrParsedAttrImpl()
2967 OS << SS.str(); in EmitClangAttrParsedAttrImpl()
2968 OS << "};\n\n"; in EmitClangAttrParsedAttrImpl()
2972 void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrKinds() argument
2973 emitSourceFileHeader("Attribute name matcher", OS); in EmitClangAttrParsedAttrKinds()
3036 OS << "static AttributeList::Kind getAttrKind(StringRef Name, "; in EmitClangAttrParsedAttrKinds()
3037 OS << "AttributeList::Syntax Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3038 OS << " if (AttributeList::AS_GNU == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3039 StringMatcher("Name", GNU, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3040 OS << " } else if (AttributeList::AS_Declspec == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3041 StringMatcher("Name", Declspec, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3042 OS << " } else if (AttributeList::AS_CXX11 == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3043 StringMatcher("Name", CXX11, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3044 OS << " } else if (AttributeList::AS_Keyword == Syntax || "; in EmitClangAttrParsedAttrKinds()
3045 OS << "AttributeList::AS_ContextSensitiveKeyword == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3046 StringMatcher("Name", Keywords, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3047 OS << " } else if (AttributeList::AS_Pragma == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3048 StringMatcher("Name", Pragma, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3049 OS << " }\n"; in EmitClangAttrParsedAttrKinds()
3050 OS << " return AttributeList::UnknownAttribute;\n" in EmitClangAttrParsedAttrKinds()
3055 void EmitClangAttrDump(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrDump() argument
3056 emitSourceFileHeader("Attribute dumper", OS); in EmitClangAttrDump()
3058 OS << " switch (A->getKind()) {\n"; in EmitClangAttrDump()
3064 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrDump()
3071 OS << " OS << \" \" << A->getSpelling();\n"; in EmitClangAttrDump()
3075 OS << " const auto *SA = cast<" << R.getName() in EmitClangAttrDump()
3078 createArgument(*Arg, R.getName())->writeDump(OS); in EmitClangAttrDump()
3081 createArgument(*AI, R.getName())->writeDumpChildren(OS); in EmitClangAttrDump()
3083 OS << in EmitClangAttrDump()
3087 OS << " }\n"; in EmitClangAttrDump()
3091 raw_ostream &OS) { in EmitClangAttrParserStringSwitches() argument
3092 emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS); in EmitClangAttrParserStringSwitches()
3093 emitClangAttrArgContextList(Records, OS); in EmitClangAttrParserStringSwitches()
3094 emitClangAttrIdentifierArgList(Records, OS); in EmitClangAttrParserStringSwitches()
3095 emitClangAttrTypeArgList(Records, OS); in EmitClangAttrParserStringSwitches()
3096 emitClangAttrLateParsedList(Records, OS); in EmitClangAttrParserStringSwitches()
3109 raw_ostream &OS) { in WriteCategoryHeader() argument
3111 OS << Name << "\n" << std::string(Name.length(), '=') << "\n"; in WriteCategoryHeader()
3116 OS << StringRef(ContentStr).trim(); in WriteCategoryHeader()
3118 OS << "\n\n"; in WriteCategoryHeader()
3130 raw_ostream &OS) { in WriteDocumentation() argument
3201 OS << Heading << "\n" << std::string(Heading.length(), '-') << "\n"; in WriteDocumentation()
3209 OS << ".. csv-table:: Supported Syntaxes\n"; in WriteDocumentation()
3210 OS << " :header: \"GNU\", \"C++11\", \"__declspec\", \"Keyword\","; in WriteDocumentation()
3211 OS << " \"Pragma\"\n\n"; in WriteDocumentation()
3212 OS << " \""; in WriteDocumentation()
3213 if (SupportedSpellings & GNU) OS << "X"; in WriteDocumentation()
3214 OS << "\",\""; in WriteDocumentation()
3215 if (SupportedSpellings & CXX11) OS << "X"; in WriteDocumentation()
3216 OS << "\",\""; in WriteDocumentation()
3217 if (SupportedSpellings & Declspec) OS << "X"; in WriteDocumentation()
3218 OS << "\",\""; in WriteDocumentation()
3219 if (SupportedSpellings & Keyword) OS << "X"; in WriteDocumentation()
3220 OS << "\", \""; in WriteDocumentation()
3221 if (SupportedSpellings & Pragma) OS << "X"; in WriteDocumentation()
3222 OS << "\"\n\n"; in WriteDocumentation()
3227 OS << "This attribute has been deprecated, and may be removed in a future " in WriteDocumentation()
3232 OS << " This attribute has been superseded by ``" in WriteDocumentation()
3234 OS << "\n\n"; in WriteDocumentation()
3239 OS << StringRef(ContentStr).trim(); in WriteDocumentation()
3241 OS << "\n\n\n"; in WriteDocumentation()
3244 void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrDocs() argument
3253 OS << Documentation->getValueAsString("Intro") << "\n"; in EmitClangAttrDocs()
3283 WriteCategoryHeader(I.first, OS); in EmitClangAttrDocs()
3288 WriteDocumentation(Doc, OS); in EmitClangAttrDocs()