Lines Matching full:os
230 virtual void writeAccessors(raw_ostream &OS) const = 0;
231 virtual void writeAccessorDefinitions(raw_ostream &OS) const {} in writeAccessorDefinitions()
232 virtual void writeASTVisitorTraversal(raw_ostream &OS) const {} in writeASTVisitorTraversal()
233 virtual void writeCloneArgs(raw_ostream &OS) const = 0;
234 virtual void writeTemplateInstantiationArgs(raw_ostream &OS) const = 0;
235 virtual void writeTemplateInstantiation(raw_ostream &OS) const {} in writeTemplateInstantiation()
236 virtual void writeCtorBody(raw_ostream &OS) const {} in writeCtorBody()
237 virtual void writeCtorInitializers(raw_ostream &OS) const = 0;
238 virtual void writeCtorDefaultInitializers(raw_ostream &OS) const = 0;
239 virtual void writeCtorParameters(raw_ostream &OS) const = 0;
240 virtual void writeDeclarations(raw_ostream &OS) const = 0;
241 virtual void writePCHReadArgs(raw_ostream &OS) const = 0;
242 virtual void writePCHReadDecls(raw_ostream &OS) const = 0;
243 virtual void writePCHWrite(raw_ostream &OS) const = 0;
245 virtual void writeValue(raw_ostream &OS) const = 0;
246 virtual void writeDump(raw_ostream &OS) const = 0;
247 virtual void writeDumpChildren(raw_ostream &OS) const {} in writeDumpChildren()
248 virtual void writeHasChildren(raw_ostream &OS) const { OS << "false"; } in writeHasChildren()
254 virtual void writeImplicitCtorArgs(raw_ostream &OS) const { in writeImplicitCtorArgs()
255 OS << getUpperName(); in writeImplicitCtorArgs()
268 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
269 OS << " " << type << " get" << getUpperName() << "() const {\n"; in writeAccessors()
270 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
271 OS << " }"; in writeAccessors()
274 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
275 OS << getLowerName(); in writeCloneArgs()
278 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
279 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
282 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
283 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
286 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
287 OS << getLowerName() << "()"; in writeCtorDefaultInitializers()
290 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
291 OS << type << " " << getUpperName(); in writeCtorParameters()
294 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
295 OS << type << " " << getLowerName() << ";"; in writeDeclarations()
298 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
300 OS << " " << type << " " << getLowerName() << " = " << read << ";\n"; in writePCHReadDecls()
303 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
304 OS << getLowerName(); in writePCHReadArgs()
307 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
308 OS << " " in writePCHWrite()
323 void writeValue(raw_ostream &OS) const override { in writeValue()
325 OS << "\" << get" << getUpperName() in writeValue()
330 OS << "\" << (get" << getUpperName() << "() ? get" << getUpperName() in writeValue()
333 OS << "\" << get" << getUpperName() << "()->getName() << \""; in writeValue()
335 OS << "\" << get" << getUpperName() << "().getAsString() << \""; in writeValue()
337 OS << "\" << get" << getUpperName() << "().getSourceIndex() << \""; in writeValue()
339 OS << "\" << get" << getUpperName() << "() << \""; in writeValue()
342 void writeDump(raw_ostream &OS) const override { in writeDump()
344 OS << " OS << \" \";\n"; in writeDump()
345 OS << " dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; in writeDump()
349 OS << " if (SA->get" << getUpperName() << "())\n" in writeDump()
350 << " OS << \" \" << SA->get" << getUpperName() in writeDump()
354 OS << " if (SA->get" << getUpperName() << "Loc())"; in writeDump()
355 OS << " OS << \" \" << SA->get" << getUpperName() in writeDump()
358 OS << " if (SA->get" << getUpperName() << "()) OS << \" " in writeDump()
361 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n"; in writeDump()
364 OS << " if (SA->get" << getUpperName() << "().isValid())\n "; in writeDump()
365 OS << " OS << \" \" << SA->get" << getUpperName() in writeDump()
368 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n"; in writeDump()
383 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
384 SimpleArgument::writeAccessors(OS); in writeAccessors()
386 OS << "\n\n static const " << getType() << " Default" << getUpperName() in writeAccessors()
389 OS << (Default != 0 ? "true" : "false"); in writeAccessors()
391 OS << Default; in writeAccessors()
392 OS << ";"; in writeAccessors()
402 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
403 OS << " llvm::StringRef get" << getUpperName() << "() const {\n"; in writeAccessors()
404 OS << " return llvm::StringRef(" << getLowerName() << ", " in writeAccessors()
406 OS << " }\n"; in writeAccessors()
407 OS << " unsigned get" << getUpperName() << "Length() const {\n"; in writeAccessors()
408 OS << " return " << getLowerName() << "Length;\n"; in writeAccessors()
409 OS << " }\n"; in writeAccessors()
410 OS << " void set" << getUpperName() in writeAccessors()
412 OS << " " << getLowerName() << "Length = S.size();\n"; in writeAccessors()
413 OS << " this->" << getLowerName() << " = new (C, 1) char [" in writeAccessors()
415 OS << " if (!S.empty())\n"; in writeAccessors()
416 OS << " std::memcpy(this->" << getLowerName() << ", S.data(), " in writeAccessors()
418 OS << " }"; in writeAccessors()
421 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
422 OS << "get" << getUpperName() << "()"; in writeCloneArgs()
425 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
426 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
429 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
430 OS << " if (!" << getUpperName() << ".empty())\n"; in writeCtorBody()
431 OS << " std::memcpy(" << getLowerName() << ", " << getUpperName() in writeCtorBody()
435 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
436 OS << getLowerName() << "Length(" << getUpperName() << ".size())," in writeCtorInitializers()
441 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
442 OS << getLowerName() << "Length(0)," << getLowerName() << "(nullptr)"; in writeCtorDefaultInitializers()
445 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
446 OS << "llvm::StringRef " << getUpperName(); in writeCtorParameters()
449 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
450 OS << "unsigned " << getLowerName() << "Length;\n"; in writeDeclarations()
451 OS << "char *" << getLowerName() << ";"; in writeDeclarations()
454 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
455 OS << " std::string " << getLowerName() in writePCHReadDecls()
459 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
460 OS << getLowerName(); in writePCHReadArgs()
463 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
464 OS << " Record.AddString(SA->get" << getUpperName() << "());\n"; in writePCHWrite()
467 void writeValue(raw_ostream &OS) const override { in writeValue()
468 OS << "\\\"\" << get" << getUpperName() << "() << \"\\\""; in writeValue()
471 void writeDump(raw_ostream &OS) const override { in writeDump()
472 OS << " OS << \" \\\"\" << SA->get" << getUpperName() in writeDump()
483 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
484 OS << " bool is" << getUpperName() << "Dependent() const;\n"; in writeAccessors()
485 OS << " bool is" << getUpperName() << "ErrorDependent() const;\n"; in writeAccessors()
487 OS << " unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n"; in writeAccessors()
489 OS << " bool is" << getUpperName() << "Expr() const {\n"; in writeAccessors()
490 OS << " return is" << getLowerName() << "Expr;\n"; in writeAccessors()
491 OS << " }\n"; in writeAccessors()
493 OS << " Expr *get" << getUpperName() << "Expr() const {\n"; in writeAccessors()
494 OS << " assert(is" << getLowerName() << "Expr);\n"; in writeAccessors()
495 OS << " return " << getLowerName() << "Expr;\n"; in writeAccessors()
496 OS << " }\n"; in writeAccessors()
498 OS << " TypeSourceInfo *get" << getUpperName() << "Type() const {\n"; in writeAccessors()
499 OS << " assert(!is" << getLowerName() << "Expr);\n"; in writeAccessors()
500 OS << " return " << getLowerName() << "Type;\n"; in writeAccessors()
501 OS << " }"; in writeAccessors()
504 void writeAccessorDefinitions(raw_ostream &OS) const override { in writeAccessorDefinitions()
505 OS << "bool " << getAttrName() << "Attr::is" << getUpperName() in writeAccessorDefinitions()
507 OS << " if (is" << getLowerName() << "Expr)\n"; in writeAccessorDefinitions()
508 OS << " return " << getLowerName() << "Expr && (" << getLowerName() in writeAccessorDefinitions()
511 OS << " else\n"; in writeAccessorDefinitions()
512 OS << " return " << getLowerName() in writeAccessorDefinitions()
514 OS << "}\n"; in writeAccessorDefinitions()
516 OS << "bool " << getAttrName() << "Attr::is" << getUpperName() in writeAccessorDefinitions()
518 OS << " if (is" << getLowerName() << "Expr)\n"; in writeAccessorDefinitions()
519 OS << " return " << getLowerName() << "Expr && " << getLowerName() in writeAccessorDefinitions()
521 OS << " return " << getLowerName() in writeAccessorDefinitions()
523 OS << "}\n"; in writeAccessorDefinitions()
528 OS << "unsigned " << getAttrName() << "Attr::get" << getUpperName() in writeAccessorDefinitions()
530 OS << " assert(!is" << getUpperName() << "Dependent());\n"; in writeAccessorDefinitions()
531 OS << " if (is" << getLowerName() << "Expr)\n"; in writeAccessorDefinitions()
532 OS << " return " << getLowerName() << "Expr ? " << getLowerName() in writeAccessorDefinitions()
536 OS << " else\n"; in writeAccessorDefinitions()
537 OS << " return 0; // FIXME\n"; in writeAccessorDefinitions()
538 OS << "}\n"; in writeAccessorDefinitions()
541 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
543 OS << " if (A->is" << Name << "Expr()) {\n" in writeASTVisitorTraversal()
552 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
553 OS << "is" << getLowerName() << "Expr, is" << getLowerName() in writeCloneArgs()
559 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
564 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
565 OS << " if (is" << getLowerName() << "Expr)\n"; in writeCtorBody()
566 OS << " " << getLowerName() << "Expr = reinterpret_cast<Expr *>(" in writeCtorBody()
568 OS << " else\n"; in writeCtorBody()
569 OS << " " << getLowerName() in writeCtorBody()
574 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
575 OS << "is" << getLowerName() << "Expr(Is" << getUpperName() << "Expr)"; in writeCtorInitializers()
578 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
579 OS << "is" << getLowerName() << "Expr(false)"; in writeCtorDefaultInitializers()
582 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
583 OS << "bool Is" << getUpperName() << "Expr, void *" << getUpperName(); in writeCtorParameters()
586 void writeImplicitCtorArgs(raw_ostream &OS) const override { in writeImplicitCtorArgs()
587 OS << "Is" << getUpperName() << "Expr, " << getUpperName(); in writeImplicitCtorArgs()
590 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
591 OS << "bool is" << getLowerName() << "Expr;\n"; in writeDeclarations()
592 OS << "union {\n"; in writeDeclarations()
593 OS << "Expr *" << getLowerName() << "Expr;\n"; in writeDeclarations()
594 OS << "TypeSourceInfo *" << getLowerName() << "Type;\n"; in writeDeclarations()
595 OS << "};"; in writeDeclarations()
598 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
599 OS << "is" << getLowerName() << "Expr, " << getLowerName() << "Ptr"; in writePCHReadArgs()
602 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
603 OS << " bool is" << getLowerName() << "Expr = Record.readInt();\n"; in writePCHReadDecls()
604 OS << " void *" << getLowerName() << "Ptr;\n"; in writePCHReadDecls()
605 OS << " if (is" << getLowerName() << "Expr)\n"; in writePCHReadDecls()
606 OS << " " << getLowerName() << "Ptr = Record.readExpr();\n"; in writePCHReadDecls()
607 OS << " else\n"; in writePCHReadDecls()
608 OS << " " << getLowerName() in writePCHReadDecls()
612 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
613 OS << " Record.push_back(SA->is" << getUpperName() << "Expr());\n"; in writePCHWrite()
614 OS << " if (SA->is" << getUpperName() << "Expr())\n"; in writePCHWrite()
615 OS << " Record.AddStmt(SA->get" << getUpperName() << "Expr());\n"; in writePCHWrite()
616 OS << " else\n"; in writePCHWrite()
617 OS << " Record.AddTypeSourceInfo(SA->get" << getUpperName() in writePCHWrite()
626 void writeValue(raw_ostream &OS) const override { in writeValue()
627 OS << "\";\n"; in writeValue()
628 OS << " " << getLowerName() in writeValue()
629 << "Expr->printPretty(OS, nullptr, Policy);\n"; in writeValue()
630 OS << " OS << \""; in writeValue()
633 void writeDump(raw_ostream &OS) const override { in writeDump()
634 OS << " if (!SA->is" << getUpperName() << "Expr())\n"; in writeDump()
635 OS << " dumpType(SA->get" << getUpperName() in writeDump()
639 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
640 OS << " if (SA->is" << getUpperName() << "Expr())\n"; in writeDumpChildren()
641 OS << " Visit(SA->get" << getUpperName() << "Expr());\n"; in writeDumpChildren()
644 void writeHasChildren(raw_ostream &OS) const override { in writeHasChildren()
645 OS << "SA->is" << getUpperName() << "Expr()"; in writeHasChildren()
653 // Assumed to receive a parameter: raw_ostream OS.
654 virtual void writeValueImpl(raw_ostream &OS) const { in writeValueImpl()
655 OS << " OS << Val;\n"; in writeValueImpl()
657 // Assumed to receive a parameter: raw_ostream OS.
658 virtual void writeDumpImpl(raw_ostream &OS) const { in writeDumpImpl()
659 OS << " OS << \" \" << Val;\n"; in writeDumpImpl()
673 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
678 OS << " typedef " << Type << "* " << IteratorType << ";\n"; in writeAccessors()
679 OS << " " << IteratorType << " " << BeginFn << " const {" in writeAccessors()
681 OS << " " << IteratorType << " " << EndFn << " const {" in writeAccessors()
683 OS << " unsigned " << getLowerName() << "_size() const {" in writeAccessors()
685 OS << " llvm::iterator_range<" << IteratorType << "> " << RangeName in writeAccessors()
690 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
691 OS << ArgName << ", " << ArgSizeName; in writeCloneArgs()
694 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
696 OS << "A->" << getLowerName() << "_begin(), " in writeTemplateInstantiationArgs()
700 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
704 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
705 OS << " std::copy(" << getUpperName() << ", " << getUpperName() << " + " in writeCtorBody()
709 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
710 OS << ArgSizeName << "(" << getUpperName() << "Size), " in writeCtorInitializers()
715 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
716 OS << ArgSizeName << "(0), " << ArgName << "(nullptr)"; in writeCtorDefaultInitializers()
719 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
720 OS << getType() << " *" << getUpperName() << ", unsigned " in writeCtorParameters()
724 void writeImplicitCtorArgs(raw_ostream &OS) const override { in writeImplicitCtorArgs()
725 OS << getUpperName() << ", " << getUpperName() << "Size"; in writeImplicitCtorArgs()
728 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
729 OS << " unsigned " << ArgSizeName << ";\n"; in writeDeclarations()
730 OS << " " << getType() << " *" << ArgName << ";"; in writeDeclarations()
733 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
734 OS << " unsigned " << getLowerName() << "Size = Record.readInt();\n"; in writePCHReadDecls()
735 OS << " SmallVector<" << getType() << ", 4> " in writePCHReadDecls()
737 OS << " " << getLowerName() << ".reserve(" << getLowerName() in writePCHReadDecls()
747 OS << " SmallVector<" << StorageType << ", 4> " in writePCHReadDecls()
749 OS << " " << StorageName << ".reserve(" << getLowerName() in writePCHReadDecls()
753 OS << " for (unsigned i = 0; i != " << getLowerName() << "Size; ++i)\n"; in writePCHReadDecls()
755 OS << " " << StorageName << ".push_back(" << read << ");\n"; in writePCHReadDecls()
758 OS << " for (unsigned i = 0; i != " << getLowerName() << "Size; ++i)\n"; in writePCHReadDecls()
759 OS << " " << getLowerName() << ".push_back(" in writePCHReadDecls()
764 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
765 OS << getLowerName() << ".data(), " << getLowerName() << "Size"; in writePCHReadArgs()
768 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
769 OS << " Record.push_back(SA->" << getLowerName() << "_size());\n"; in writePCHWrite()
770 OS << " for (auto &Val : SA->" << RangeName << "())\n"; in writePCHWrite()
771 OS << " " << WritePCHRecord(Type, "Val"); in writePCHWrite()
774 void writeValue(raw_ostream &OS) const override { in writeValue()
775 OS << "\";\n"; in writeValue()
776 OS << " bool isFirst = true;\n" in writeValue()
779 << " else OS << \", \";\n"; in writeValue()
780 writeValueImpl(OS); in writeValue()
781 OS << " }\n"; in writeValue()
782 OS << " OS << \""; in writeValue()
785 void writeDump(raw_ostream &OS) const override { in writeDump()
786 OS << " for (const auto &Val : SA->" << RangeName << "())\n"; in writeDump()
787 writeDumpImpl(OS); in writeDump()
797 void writeValueImpl(raw_ostream &OS) const override { in writeValueImpl()
798 OS << " OS << Val.getSourceIndex();\n"; in writeValueImpl()
801 void writeDumpImpl(raw_ostream &OS) const override { in writeDumpImpl()
802 OS << " OS << \" \" << Val.getSourceIndex();\n"; in writeDumpImpl()
839 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
840 OS << " " << type << " get" << getUpperName() << "() const {\n"; in writeAccessors()
841 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
842 OS << " }"; in writeAccessors()
845 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
846 OS << getLowerName(); in writeCloneArgs()
849 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
850 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
852 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
853 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
855 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
856 OS << getLowerName() << "(" << type << "(0))"; in writeCtorDefaultInitializers()
858 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
859 OS << type << " " << getUpperName(); in writeCtorParameters()
861 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
866 OS << "public:\n"; in writeDeclarations()
867 OS << " enum " << type << " {\n"; in writeDeclarations()
869 OS << " " << *i << ",\n"; in writeDeclarations()
870 OS << " " << *e << "\n"; in writeDeclarations()
871 OS << " };\n"; in writeDeclarations()
872 OS << "private:\n"; in writeDeclarations()
873 OS << " " << type << " " << getLowerName() << ";"; in writeDeclarations()
876 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
877 OS << " " << getAttrName() << "Attr::" << type << " " << getLowerName() in writePCHReadDecls()
882 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
883 OS << getLowerName(); in writePCHReadArgs()
886 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
887 OS << "Record.push_back(SA->get" << getUpperName() << "());\n"; in writePCHWrite()
890 void writeValue(raw_ostream &OS) const override { in writeValue()
894 OS << "\\\"\" << " << getAttrName() << "Attr::Convert" << type << "ToStr(get" in writeValue()
898 void writeDump(raw_ostream &OS) const override { in writeDump()
899 OS << " switch(SA->get" << getUpperName() << "()) {\n"; in writeDump()
901 OS << " case " << getAttrName() << "Attr::" << I << ":\n"; in writeDump()
902 OS << " OS << \" " << I << "\";\n"; in writeDump()
903 OS << " break;\n"; in writeDump()
905 OS << " }\n"; in writeDump()
908 void writeConversion(raw_ostream &OS, bool Header) const { in writeConversion() argument
910 OS << " static bool ConvertStrTo" << type << "(StringRef Val, " << type in writeConversion()
912 OS << " static const char *Convert" << type << "ToStr(" << type in writeConversion()
917 OS << "bool " << getAttrName() << "Attr::ConvertStrTo" << type in writeConversion()
919 OS << " Optional<" << type << "> R = llvm::StringSwitch<Optional<"; in writeConversion()
920 OS << type << ">>(Val)\n"; in writeConversion()
922 OS << " .Case(\"" << values[I] << "\", "; in writeConversion()
923 OS << getAttrName() << "Attr::" << enums[I] << ")\n"; in writeConversion()
925 OS << " .Default(Optional<" << type << ">());\n"; in writeConversion()
926 OS << " if (R) {\n"; in writeConversion()
927 OS << " Out = *R;\n return true;\n }\n"; in writeConversion()
928 OS << " return false;\n"; in writeConversion()
929 OS << "}\n\n"; in writeConversion()
935 OS << "const char *" << getAttrName() << "Attr::Convert" << type in writeConversion()
941 OS << " case " << getAttrName() << "Attr::" << enums[I] in writeConversion()
944 OS << " }\n" in writeConversion()
955 void writeValueImpl(raw_ostream &OS) const override { in writeValueImpl()
959 OS << " OS << \"\\\"\" << " << getAttrName() << "Attr::Convert" << type in writeValueImpl()
979 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
984 OS << "public:\n"; in writeDeclarations()
985 OS << " enum " << type << " {\n"; in writeDeclarations()
987 OS << " " << *i << ",\n"; in writeDeclarations()
988 OS << " " << *e << "\n"; in writeDeclarations()
989 OS << " };\n"; in writeDeclarations()
990 OS << "private:\n"; in writeDeclarations()
992 VariadicArgument::writeDeclarations(OS); in writeDeclarations()
995 void writeDump(raw_ostream &OS) const override { in writeDump()
996 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writeDump()
999 OS << " switch(*I) {\n"; in writeDump()
1001 OS << " case " << getAttrName() << "Attr::" << UI << ":\n"; in writeDump()
1002 OS << " OS << \" " << UI << "\";\n"; in writeDump()
1003 OS << " break;\n"; in writeDump()
1005 OS << " }\n"; in writeDump()
1006 OS << " }\n"; in writeDump()
1009 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
1010 OS << " unsigned " << getLowerName() << "Size = Record.readInt();\n"; in writePCHReadDecls()
1011 OS << " SmallVector<" << QualifiedTypeName << ", 4> " << getLowerName() in writePCHReadDecls()
1013 OS << " " << getLowerName() << ".reserve(" << getLowerName() in writePCHReadDecls()
1015 OS << " for (unsigned i = " << getLowerName() << "Size; i; --i)\n"; in writePCHReadDecls()
1016 OS << " " << getLowerName() << ".push_back(" << "static_cast<" in writePCHReadDecls()
1020 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
1021 OS << " Record.push_back(SA->" << getLowerName() << "_size());\n"; in writePCHWrite()
1022 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writePCHWrite()
1025 OS << " " << WritePCHRecord(QualifiedTypeName, "(*i)"); in writePCHWrite()
1028 void writeConversion(raw_ostream &OS, bool Header) const { in writeConversion() argument
1030 OS << " static bool ConvertStrTo" << type << "(StringRef Val, " << type in writeConversion()
1032 OS << " static const char *Convert" << type << "ToStr(" << type in writeConversion()
1037 OS << "bool " << getAttrName() << "Attr::ConvertStrTo" << type in writeConversion()
1039 OS << type << " &Out) {\n"; in writeConversion()
1040 OS << " Optional<" << type << "> R = llvm::StringSwitch<Optional<"; in writeConversion()
1041 OS << type << ">>(Val)\n"; in writeConversion()
1043 OS << " .Case(\"" << values[I] << "\", "; in writeConversion()
1044 OS << getAttrName() << "Attr::" << enums[I] << ")\n"; in writeConversion()
1046 OS << " .Default(Optional<" << type << ">());\n"; in writeConversion()
1047 OS << " if (R) {\n"; in writeConversion()
1048 OS << " Out = *R;\n return true;\n }\n"; in writeConversion()
1049 OS << " return false;\n"; in writeConversion()
1050 OS << "}\n\n"; in writeConversion()
1052 OS << "const char *" << getAttrName() << "Attr::Convert" << type in writeConversion()
1058 OS << " case " << getAttrName() << "Attr::" << enums[I] in writeConversion()
1061 OS << " }\n" in writeConversion()
1073 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
1074 OS << " VersionTuple get" << getUpperName() << "() const {\n"; in writeAccessors()
1075 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
1076 OS << " }\n"; in writeAccessors()
1077 OS << " void set" << getUpperName() in writeAccessors()
1079 OS << " " << getLowerName() << " = V;\n"; in writeAccessors()
1080 OS << " }"; in writeAccessors()
1083 void writeCloneArgs(raw_ostream &OS) const override { in writeCloneArgs()
1084 OS << "get" << getUpperName() << "()"; in writeCloneArgs()
1087 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
1088 OS << "A->get" << getUpperName() << "()"; in writeTemplateInstantiationArgs()
1091 void writeCtorInitializers(raw_ostream &OS) const override { in writeCtorInitializers()
1092 OS << getLowerName() << "(" << getUpperName() << ")"; in writeCtorInitializers()
1095 void writeCtorDefaultInitializers(raw_ostream &OS) const override { in writeCtorDefaultInitializers()
1096 OS << getLowerName() << "()"; in writeCtorDefaultInitializers()
1099 void writeCtorParameters(raw_ostream &OS) const override { in writeCtorParameters()
1100 OS << "VersionTuple " << getUpperName(); in writeCtorParameters()
1103 void writeDeclarations(raw_ostream &OS) const override { in writeDeclarations()
1104 OS << "VersionTuple " << getLowerName() << ";\n"; in writeDeclarations()
1107 void writePCHReadDecls(raw_ostream &OS) const override { in writePCHReadDecls()
1108 OS << " VersionTuple " << getLowerName() in writePCHReadDecls()
1112 void writePCHReadArgs(raw_ostream &OS) const override { in writePCHReadArgs()
1113 OS << getLowerName(); in writePCHReadArgs()
1116 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
1117 OS << " Record.AddVersionTuple(SA->get" << getUpperName() << "());\n"; in writePCHWrite()
1120 void writeValue(raw_ostream &OS) const override { in writeValue()
1121 OS << getLowerName() << "=\" << get" << getUpperName() << "() << \""; in writeValue()
1124 void writeDump(raw_ostream &OS) const override { in writeDump()
1125 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n"; in writeDump()
1135 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
1136 OS << " if (!" in writeASTVisitorTraversal()
1138 OS << " return false;\n"; in writeASTVisitorTraversal()
1141 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
1142 OS << "tempInst" << getUpperName(); in writeTemplateInstantiationArgs()
1145 void writeTemplateInstantiation(raw_ostream &OS) const override { in writeTemplateInstantiation()
1146 OS << " " << getType() << " tempInst" << getUpperName() << ";\n"; in writeTemplateInstantiation()
1147 OS << " {\n"; in writeTemplateInstantiation()
1148 OS << " EnterExpressionEvaluationContext " in writeTemplateInstantiation()
1150 OS << " ExprResult " << "Result = S.SubstExpr(" in writeTemplateInstantiation()
1152 OS << " tempInst" << getUpperName() << " = " in writeTemplateInstantiation()
1154 OS << " }\n"; in writeTemplateInstantiation()
1157 void writeDump(raw_ostream &OS) const override {} in writeDump()
1159 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
1160 OS << " Visit(SA->get" << getUpperName() << "());\n"; in writeDumpChildren()
1163 void writeHasChildren(raw_ostream &OS) const override { OS << "true"; } in writeHasChildren()
1172 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
1173 OS << " {\n"; in writeASTVisitorTraversal()
1174 OS << " " << getType() << " *I = A->" << getLowerName() in writeASTVisitorTraversal()
1176 OS << " " << getType() << " *E = A->" << getLowerName() in writeASTVisitorTraversal()
1178 OS << " for (; I != E; ++I) {\n"; in writeASTVisitorTraversal()
1179 OS << " if (!getDerived().TraverseStmt(*I))\n"; in writeASTVisitorTraversal()
1180 OS << " return false;\n"; in writeASTVisitorTraversal()
1181 OS << " }\n"; in writeASTVisitorTraversal()
1182 OS << " }\n"; in writeASTVisitorTraversal()
1185 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
1186 OS << "tempInst" << getUpperName() << ", " in writeTemplateInstantiationArgs()
1190 void writeTemplateInstantiation(raw_ostream &OS) const override { in writeTemplateInstantiation()
1191 OS << " auto *tempInst" << getUpperName() in writeTemplateInstantiation()
1194 OS << " {\n"; in writeTemplateInstantiation()
1195 OS << " EnterExpressionEvaluationContext " in writeTemplateInstantiation()
1197 OS << " " << getType() << " *TI = tempInst" << getUpperName() in writeTemplateInstantiation()
1199 OS << " " << getType() << " *I = A->" << getLowerName() in writeTemplateInstantiation()
1201 OS << " " << getType() << " *E = A->" << getLowerName() in writeTemplateInstantiation()
1203 OS << " for (; I != E; ++I, ++TI) {\n"; in writeTemplateInstantiation()
1204 OS << " ExprResult Result = S.SubstExpr(*I, TemplateArgs);\n"; in writeTemplateInstantiation()
1205 OS << " *TI = Result.getAs<Expr>();\n"; in writeTemplateInstantiation()
1206 OS << " }\n"; in writeTemplateInstantiation()
1207 OS << " }\n"; in writeTemplateInstantiation()
1210 void writeDump(raw_ostream &OS) const override {} in writeDump()
1212 void writeDumpChildren(raw_ostream &OS) const override { in writeDumpChildren()
1213 OS << " for (" << getAttrName() << "Attr::" << getLowerName() in writeDumpChildren()
1216 OS << " Visit(*I);\n"; in writeDumpChildren()
1219 void writeHasChildren(raw_ostream &OS) const override { in writeHasChildren()
1220 OS << "SA->" << getLowerName() << "_begin() != " in writeHasChildren()
1238 void writeCtorBody(raw_ostream &OS) const override { in writeCtorBody()
1239 OS << " for (size_t I = 0, E = " << getArgSizeName() << "; I != E;\n" in writeCtorBody()
1250 void writeValueImpl(raw_ostream &OS) const override { in writeValueImpl()
1251 OS << " OS << \"\\\"\" << Val << \"\\\"\";\n"; in writeValueImpl()
1261 void writeAccessors(raw_ostream &OS) const override { in writeAccessors()
1262 OS << " QualType get" << getUpperName() << "() const {\n"; in writeAccessors()
1263 OS << " return " << getLowerName() << "->getType();\n"; in writeAccessors()
1264 OS << " }"; in writeAccessors()
1265 OS << " " << getType() << " get" << getUpperName() << "Loc() const {\n"; in writeAccessors()
1266 OS << " return " << getLowerName() << ";\n"; in writeAccessors()
1267 OS << " }"; in writeAccessors()
1270 void writeASTVisitorTraversal(raw_ostream &OS) const override { in writeASTVisitorTraversal()
1271 OS << " if (auto *TSI = A->get" << getUpperName() << "Loc())\n"; in writeASTVisitorTraversal()
1272 OS << " if (!getDerived().TraverseTypeLoc(TSI->getTypeLoc()))\n"; in writeASTVisitorTraversal()
1273 OS << " return false;\n"; in writeASTVisitorTraversal()
1276 void writeTemplateInstantiationArgs(raw_ostream &OS) const override { in writeTemplateInstantiationArgs()
1277 OS << "A->get" << getUpperName() << "Loc()"; in writeTemplateInstantiationArgs()
1280 void writePCHWrite(raw_ostream &OS) const override { in writePCHWrite()
1281 OS << " " in writePCHWrite()
1364 static void writeAvailabilityValue(raw_ostream &OS) { in writeAvailabilityValue() argument
1365 OS << "\" << getPlatform()->getName();\n" in writeAvailabilityValue()
1366 << " if (getStrict()) OS << \", strict\";\n" in writeAvailabilityValue()
1367 << " if (!getIntroduced().empty()) OS << \", introduced=\" << getIntroduced();\n" in writeAvailabilityValue()
1368 << " if (!getDeprecated().empty()) OS << \", deprecated=\" << getDeprecated();\n" in writeAvailabilityValue()
1369 << " if (!getObsoleted().empty()) OS << \", obsoleted=\" << getObsoleted();\n" in writeAvailabilityValue()
1370 << " if (getUnavailable()) OS << \", unavailable\";\n" in writeAvailabilityValue()
1371 << " OS << \""; in writeAvailabilityValue()
1374 static void writeDeprecatedAttrValue(raw_ostream &OS, std::string &Variety) { in writeDeprecatedAttrValue() argument
1375 OS << "\\\"\" << getMessage() << \"\\\"\";\n"; in writeDeprecatedAttrValue()
1378 OS << " if (!getReplacement().empty()) OS << \", \\\"\"" in writeDeprecatedAttrValue()
1380 OS << " OS << \""; in writeDeprecatedAttrValue()
1383 static void writeGetSpellingFunction(const Record &R, raw_ostream &OS) { in writeGetSpellingFunction() argument
1386 OS << "const char *" << R.getName() << "Attr::getSpelling() const {\n"; in writeGetSpellingFunction()
1388 OS << " return \"(No spelling)\";\n}\n\n"; in writeGetSpellingFunction()
1392 OS << " switch (getAttributeSpellingListIndex()) {\n" in writeGetSpellingFunction()
1398 OS << " case " << I << ":\n" in writeGetSpellingFunction()
1401 OS << " }\n"; in writeGetSpellingFunction()
1403 OS << "}\n\n"; in writeGetSpellingFunction()
1409 raw_ostream &OS) { in writePrettyPrintFunction() argument
1412 OS << "void " << R.getName() << "Attr::printPretty(" in writePrettyPrintFunction()
1413 << "raw_ostream &OS, const PrintingPolicy &Policy) const {\n"; in writePrettyPrintFunction()
1416 OS << "}\n\n"; in writePrettyPrintFunction()
1420 OS << " switch (getAttributeSpellingListIndex()) {\n" in writePrettyPrintFunction()
1468 OS << in writePrettyPrintFunction()
1470 " OS << \"" << Prefix << Spelling; in writePrettyPrintFunction()
1473 OS << "\";\n"; in writePrettyPrintFunction()
1474 OS << " printPrettyPragma(OS, Policy);\n"; in writePrettyPrintFunction()
1475 OS << " OS << \"\\n\";"; in writePrettyPrintFunction()
1476 OS << " break;\n"; in writePrettyPrintFunction()
1477 OS << " }\n"; in writePrettyPrintFunction()
1482 OS << "("; in writePrettyPrintFunction()
1483 writeAvailabilityValue(OS); in writePrettyPrintFunction()
1484 OS << ")"; in writePrettyPrintFunction()
1486 OS << "("; in writePrettyPrintFunction()
1487 writeDeprecatedAttrValue(OS, Variety); in writePrettyPrintFunction()
1488 OS << ")"; in writePrettyPrintFunction()
1509 OS << "\";\n" in writePrettyPrintFunction()
1511 OS << " if (" << arg->getIsOmitted() << ")\n" in writePrettyPrintFunction()
1515 OS << " OS << \""; in writePrettyPrintFunction()
1517 OS << "("; in writePrettyPrintFunction()
1519 OS << "\";\n" in writePrettyPrintFunction()
1521 << " OS << \"(\";\n" in writePrettyPrintFunction()
1522 << " OS << \""; in writePrettyPrintFunction()
1529 OS << "\";\n" in writePrettyPrintFunction()
1532 << " OS << \", \";\n" in writePrettyPrintFunction()
1533 << " OS << \""; in writePrettyPrintFunction()
1535 OS << ", "; in writePrettyPrintFunction()
1539 OS << "\";\n" in writePrettyPrintFunction()
1541 << " OS << \""; in writePrettyPrintFunction()
1542 arg->writeValue(OS); in writePrettyPrintFunction()
1544 OS << "\";\n" in writePrettyPrintFunction()
1546 << " OS << \""; in writePrettyPrintFunction()
1550 OS << ")"; in writePrettyPrintFunction()
1552 OS << "\";\n" in writePrettyPrintFunction()
1554 << " OS << \")\";\n" in writePrettyPrintFunction()
1555 << " OS << \""; in writePrettyPrintFunction()
1558 OS << Suffix + "\";\n"; in writePrettyPrintFunction()
1560 OS << in writePrettyPrintFunction()
1566 OS << "}\n"; in writePrettyPrintFunction()
1568 OS << "}\n\n"; in writePrettyPrintFunction()
1592 static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) { in writeAttrAccessorDefinition() argument
1604 OS << " bool " << Name in writeAttrAccessorDefinition()
1607 OS << getSpellingListIndex(SpellingList, Spellings[Index]); in writeAttrAccessorDefinition()
1609 OS << " ||\n getAttributeSpellingListIndex() == "; in writeAttrAccessorDefinition()
1611 OS << "; }\n"; in writeAttrAccessorDefinition()
1689 raw_ostream &OS) { in WriteSemanticSpellingSwitch() argument
1690 OS << " switch (" << VarName << ") {\n default: " in WriteSemanticSpellingSwitch()
1693 OS << " case " << I.first << ": return " << I.second << ";\n"; in WriteSemanticSpellingSwitch()
1694 OS << " }\n"; in WriteSemanticSpellingSwitch()
1698 static void emitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrLateParsedList() argument
1699 OS << "#if defined(CLANG_ATTR_LATE_PARSED_LIST)\n"; in emitClangAttrLateParsedList()
1712 OS << ".Case(\"" << I.name() << "\", " << LateParsed << ")\n"; in emitClangAttrLateParsedList()
1716 OS << "#endif // CLANG_ATTR_LATE_PARSED_LIST\n\n"; in emitClangAttrLateParsedList()
1842 void emitMatchRuleList(raw_ostream &OS);
1844 void generateStrictConformsTo(const Record &Attr, raw_ostream &OS);
1846 void generateParsingHelpers(raw_ostream &OS);
1930 void PragmaClangAttributeSupport::emitMatchRuleList(raw_ostream &OS) { in emitMatchRuleList() argument
1931 OS << "#ifndef ATTR_MATCH_SUB_RULE\n"; in emitMatchRuleList()
1932 OS << "#define ATTR_MATCH_SUB_RULE(Value, Spelling, IsAbstract, Parent, " in emitMatchRuleList()
1935 OS << "#endif\n"; in emitMatchRuleList()
1937 OS << (Rule.isSubRule() ? "ATTR_MATCH_SUB_RULE" : "ATTR_MATCH_RULE") << '('; in emitMatchRuleList()
1938 OS << Rule.getEnumValueName() << ", \"" << Rule.getSpelling() << "\", " in emitMatchRuleList()
1941 OS << ", " in emitMatchRuleList()
1944 OS << ")\n"; in emitMatchRuleList()
1946 OS << "#undef ATTR_MATCH_SUB_RULE\n"; in emitMatchRuleList()
2012 raw_ostream &OS) { in generateStrictConformsTo() argument
2017 OS << "void getPragmaAttributeMatchRules(" in generateStrictConformsTo()
2031 OS << " MatchRules.push_back(std::make_pair(" << Rule.getEnumValue() in generateStrictConformsTo()
2036 OS << "}\n\n"; in generateStrictConformsTo()
2039 void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) { in generateParsingHelpers() argument
2041 OS << "Optional<attr::SubjectMatchRule> " in generateParsingHelpers()
2043 OS << " return None;\n"; in generateParsingHelpers()
2044 OS << "}\n\n"; in generateParsingHelpers()
2055 OS << "Optional<attr::SubjectMatchRule> isAttributeSubjectMatchSubRuleFor_" in generateParsingHelpers()
2058 OS << " if (IsUnless)\n"; in generateParsingHelpers()
2059 OS << " return " in generateParsingHelpers()
2063 OS << " Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue() in generateParsingHelpers()
2066 OS << " Default(None);\n"; in generateParsingHelpers()
2067 OS << " return " in generateParsingHelpers()
2071 OS << " Case(\"" << Rule.getName() << "\", " << Rule.getEnumValue() in generateParsingHelpers()
2074 OS << " Default(None);\n"; in generateParsingHelpers()
2075 OS << "}\n\n"; in generateParsingHelpers()
2079 OS << "std::pair<Optional<attr::SubjectMatchRule>, " in generateParsingHelpers()
2082 OS << " return " in generateParsingHelpers()
2095 OS << " Case(\"" << Rule.getName() << "\", std::make_pair(" in generateParsingHelpers()
2098 OS << " Default(std::make_pair(None, " in generateParsingHelpers()
2100 OS << "}\n\n"; in generateParsingHelpers()
2103 OS << "const char *validAttributeSubjectMatchSubRules(" in generateParsingHelpers()
2105 OS << " switch (Rule) {\n"; in generateParsingHelpers()
2107 OS << " case " in generateParsingHelpers()
2110 OS << " return \"'"; in generateParsingHelpers()
2114 OS << ", '"; in generateParsingHelpers()
2117 OS << "unless("; in generateParsingHelpers()
2118 OS << Rule.getName(); in generateParsingHelpers()
2120 OS << ')'; in generateParsingHelpers()
2121 OS << "'"; in generateParsingHelpers()
2123 OS << "\";\n"; in generateParsingHelpers()
2125 OS << " default: return nullptr;\n"; in generateParsingHelpers()
2126 OS << " }\n"; in generateParsingHelpers()
2127 OS << "}\n\n"; in generateParsingHelpers()
2141 static void emitClangAttrTypeArgList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrTypeArgList() argument
2142 OS << "#if defined(CLANG_ATTR_TYPE_ARG_LIST)\n"; in emitClangAttrTypeArgList()
2156 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrTypeArgList()
2159 OS << "#endif // CLANG_ATTR_TYPE_ARG_LIST\n\n"; in emitClangAttrTypeArgList()
2164 static void emitClangAttrArgContextList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrArgContextList() argument
2165 OS << "#if defined(CLANG_ATTR_ARG_CONTEXT_LIST)\n"; in emitClangAttrArgContextList()
2175 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrArgContextList()
2178 OS << "#endif // CLANG_ATTR_ARG_CONTEXT_LIST\n\n"; in emitClangAttrArgContextList()
2200 raw_ostream &OS) { in emitClangAttrVariadicIdentifierArgList() argument
2201 OS << "#if defined(CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST)\n"; in emitClangAttrVariadicIdentifierArgList()
2211 OS << ".Case(\"" << S.name() << "\", " in emitClangAttrVariadicIdentifierArgList()
2216 OS << "#endif // CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST\n\n"; in emitClangAttrVariadicIdentifierArgList()
2220 static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &OS) { in emitClangAttrIdentifierArgList() argument
2221 OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n"; in emitClangAttrIdentifierArgList()
2232 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n"; in emitClangAttrIdentifierArgList()
2235 OS << "#endif // CLANG_ATTR_IDENTIFIER_ARG_LIST\n\n"; in emitClangAttrIdentifierArgList()
2247 raw_ostream &OS) { in emitClangAttrThisIsaIdentifierArgList() argument
2248 OS << "#if defined(CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST)\n"; in emitClangAttrThisIsaIdentifierArgList()
2258 OS << ".Case(\"" << S.name() << "\", " in emitClangAttrThisIsaIdentifierArgList()
2263 OS << "#endif // CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST\n\n"; in emitClangAttrThisIsaIdentifierArgList()
2266 static void emitAttributes(RecordKeeper &Records, raw_ostream &OS, in emitAttributes() argument
2302 OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n"; in emitAttributes()
2304 OS << "\n// " << R.getName() << "Attr implementation\n\n"; in emitAttributes()
2315 Args.back()->writeDeclarations(OS); in emitAttributes()
2316 OS << "\n\n"; in emitAttributes()
2328 OS << "public:\n"; in emitAttributes()
2345 OS << SpellingEnum; in emitAttributes()
2355 OS << " static "; in emitAttributes()
2356 OS << R.getName() << "Attr *"; in emitAttributes()
2358 OS << R.getName() << "Attr::"; in emitAttributes()
2359 OS << "Create"; in emitAttributes()
2361 OS << "Implicit"; in emitAttributes()
2362 OS << "("; in emitAttributes()
2363 OS << "ASTContext &Ctx"; in emitAttributes()
2366 OS << ", "; in emitAttributes()
2367 ai->writeCtorParameters(OS); in emitAttributes()
2369 OS << ", const AttributeCommonInfo &CommonInfo"; in emitAttributes()
2371 OS << " = {SourceRange{}}"; in emitAttributes()
2372 OS << ")"; in emitAttributes()
2374 OS << ";\n"; in emitAttributes()
2378 OS << " {\n"; in emitAttributes()
2379 OS << " auto *A = new (Ctx) " << R.getName(); in emitAttributes()
2380 OS << "Attr(Ctx, CommonInfo"; in emitAttributes()
2383 OS << ", "; in emitAttributes()
2384 ai->writeImplicitCtorArgs(OS); in emitAttributes()
2386 OS << ");\n"; in emitAttributes()
2388 OS << " A->setImplicit(true);\n"; in emitAttributes()
2391 OS << " if (!A->isAttributeSpellingListCalculated() && " in emitAttributes()
2393 OS << " A->setAttributeSpellingListIndex(0);\n"; in emitAttributes()
2395 OS << " return A;\n}\n\n"; in emitAttributes()
2400 OS << " static "; in emitAttributes()
2401 OS << R.getName() << "Attr *"; in emitAttributes()
2403 OS << R.getName() << "Attr::"; in emitAttributes()
2404 OS << "Create"; in emitAttributes()
2406 OS << "Implicit"; in emitAttributes()
2407 OS << "("; in emitAttributes()
2408 OS << "ASTContext &Ctx"; in emitAttributes()
2411 OS << ", "; in emitAttributes()
2412 ai->writeCtorParameters(OS); in emitAttributes()
2414 OS << ", SourceRange Range, AttributeCommonInfo::Syntax Syntax"; in emitAttributes()
2416 OS << ", " << R.getName() << "Attr::Spelling S"; in emitAttributes()
2418 OS << " = static_cast<Spelling>(SpellingNotCalculated)"; in emitAttributes()
2420 OS << ")"; in emitAttributes()
2422 OS << ";\n"; in emitAttributes()
2426 OS << " {\n"; in emitAttributes()
2427 OS << " AttributeCommonInfo I(Range, "; in emitAttributes()
2430 OS << "AT_" << ParsedAttrSpellingItr->first; in emitAttributes()
2432 OS << "NoSemaHandlerAttribute"; in emitAttributes()
2434 OS << ", Syntax"; in emitAttributes()
2436 OS << ", S"; in emitAttributes()
2437 OS << ");\n"; in emitAttributes()
2438 OS << " return Create"; in emitAttributes()
2440 OS << "Implicit"; in emitAttributes()
2441 OS << "(Ctx"; in emitAttributes()
2444 OS << ", "; in emitAttributes()
2445 ai->writeImplicitCtorArgs(OS); in emitAttributes()
2447 OS << ", I);\n"; in emitAttributes()
2448 OS << "}\n\n"; in emitAttributes()
2459 OS << " // Factory methods\n"; in emitAttributes()
2476 OS << " "; in emitAttributes()
2478 OS << R.getName() << "Attr::"; in emitAttributes()
2479 OS << R.getName() in emitAttributes()
2481 OS << '\n'; in emitAttributes()
2484 OS << " , "; in emitAttributes()
2485 ai->writeCtorParameters(OS); in emitAttributes()
2486 OS << "\n"; in emitAttributes()
2489 OS << " )"; in emitAttributes()
2491 OS << ";\n"; in emitAttributes()
2494 OS << "\n : " << SuperName << "(Ctx, CommonInfo, "; in emitAttributes()
2495 OS << "attr::" << R.getName() << ", " in emitAttributes()
2498 OS << ", " in emitAttributes()
2502 OS << ")\n"; in emitAttributes()
2505 OS << " , "; in emitAttributes()
2507 ai->writeCtorDefaultInitializers(OS); in emitAttributes()
2509 ai->writeCtorInitializers(OS); in emitAttributes()
2511 OS << "\n"; in emitAttributes()
2514 OS << " {\n"; in emitAttributes()
2518 ai->writeCtorBody(OS); in emitAttributes()
2520 OS << "}\n\n"; in emitAttributes()
2524 OS << "\n // Constructors\n"; in emitAttributes()
2539 OS << '\n'; in emitAttributes()
2540 OS << " " << R.getName() << "Attr *clone(ASTContext &C) const;\n"; in emitAttributes()
2541 OS << " void printPretty(raw_ostream &OS,\n" in emitAttributes()
2543 OS << " const char *getSpelling() const;\n"; in emitAttributes()
2549 OS << " Spelling getSemanticSpelling() const;\n"; in emitAttributes()
2551 OS << R.getName() << "Attr::Spelling " << R.getName() in emitAttributes()
2554 SemanticToSyntacticMap, OS); in emitAttributes()
2555 OS << "}\n"; in emitAttributes()
2560 writeAttrAccessorDefinition(R, OS); in emitAttributes()
2564 ai->writeAccessors(OS); in emitAttributes()
2566 ai->writeAccessorDefinitions(OS); in emitAttributes()
2568 OS << "\n\n"; in emitAttributes()
2574 static_cast<const EnumArgument *>(ai.get())->writeConversion(OS, in emitAttributes()
2578 OS, Header); in emitAttributes()
2582 OS << R.getValueAsString("AdditionalMembers"); in emitAttributes()
2583 OS << "\n\n"; in emitAttributes()
2585 OS << " static bool classof(const Attr *A) { return A->getKind() == " in emitAttributes()
2588 OS << "};\n\n"; in emitAttributes()
2590 OS << R.getName() << "Attr *" << R.getName() in emitAttributes()
2592 OS << " auto *A = new (C) " << R.getName() << "Attr(C, *this"; in emitAttributes()
2594 OS << ", "; in emitAttributes()
2595 ai->writeCloneArgs(OS); in emitAttributes()
2597 OS << ");\n"; in emitAttributes()
2598 OS << " A->Inherited = Inherited;\n"; in emitAttributes()
2599 OS << " A->IsPackExpansion = IsPackExpansion;\n"; in emitAttributes()
2600 OS << " A->setImplicit(Implicit);\n"; in emitAttributes()
2601 OS << " return A;\n}\n\n"; in emitAttributes()
2603 writePrettyPrintFunction(R, Args, OS); in emitAttributes()
2604 writeGetSpellingFunction(R, OS); in emitAttributes()
2609 void clang::EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrClass() argument
2610 emitSourceFileHeader("Attribute classes' definitions", OS); in EmitClangAttrClass()
2612 OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n"; in EmitClangAttrClass()
2613 OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n"; in EmitClangAttrClass()
2615 emitAttributes(Records, OS, true); in EmitClangAttrClass()
2617 OS << "#endif // LLVM_CLANG_ATTR_CLASSES_INC\n"; in EmitClangAttrClass()
2621 void clang::EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrImpl() argument
2622 emitSourceFileHeader("Attribute classes' member function definitions", OS); in EmitClangAttrImpl()
2624 emitAttributes(Records, OS, false); in EmitClangAttrImpl()
2631 OS << " switch (getKind()) {\n"; in EmitClangAttrImpl()
2637 OS << " case attr::" << R.getName() << ":\n"; in EmitClangAttrImpl()
2638 OS << " return cast<" << R.getName() << "Attr>(this)->" << Method in EmitClangAttrImpl()
2641 OS << " }\n"; in EmitClangAttrImpl()
2642 OS << " llvm_unreachable(\"Unexpected attribute kind!\");\n"; in EmitClangAttrImpl()
2643 OS << "}\n\n"; in EmitClangAttrImpl()
2646 OS << "const char *Attr::getSpelling() const {\n"; in EmitClangAttrImpl()
2649 OS << "Attr *Attr::clone(ASTContext &C) const {\n"; in EmitClangAttrImpl()
2652 OS << "void Attr::printPretty(raw_ostream &OS, " in EmitClangAttrImpl()
2654 EmitFunc("printPretty(OS, Policy)"); in EmitClangAttrImpl()
2657 static void emitAttrList(raw_ostream &OS, StringRef Class, in emitAttrList() argument
2660 OS << Class << "(" << Cur->getName() << ")\n"; in emitAttrList()
2691 static void emitDefaultDefine(raw_ostream &OS, StringRef name, in emitDefaultDefine() argument
2693 OS << "#ifndef " << name << "\n"; in emitDefaultDefine()
2694 OS << "#define " << name << "(NAME) "; in emitDefaultDefine()
2695 if (superName) OS << superName << "(NAME)"; in emitDefaultDefine()
2696 OS << "\n#endif\n\n"; in emitDefaultDefine()
2712 void emitDefaultDefines(raw_ostream &OS) const { in emitDefaultDefines()
2715 emitDefaultDefine(OS, Descriptor.MacroName, in emitDefaultDefines()
2720 void emitUndefs(raw_ostream &OS) const { in emitUndefs()
2721 OS << "#undef " << Descriptor.MacroName << "\n"; in emitUndefs()
2724 void emitAttrList(raw_ostream &OS) const { in emitAttrList()
2726 SubClass->emitAttrList(OS); in emitAttrList()
2729 ::emitAttrList(OS, Descriptor.MacroName, Attrs); in emitAttrList()
2737 void emitAttrRange(raw_ostream &OS) const { in emitAttrRange()
2738 OS << "ATTR_RANGE(" << Descriptor.TableGenName in emitAttrRange()
2802 void emitDefaultDefines(raw_ostream &OS) const { in emitDefaultDefines()
2804 Class->emitDefaultDefines(OS); in emitDefaultDefines()
2808 void emitUndefs(raw_ostream &OS) const { in emitUndefs()
2810 Class->emitUndefs(OS); in emitUndefs()
2814 void emitAttrLists(raw_ostream &OS) const { in emitAttrLists()
2816 Classes[0]->emitAttrList(OS); in emitAttrLists()
2819 void emitAttrRanges(raw_ostream &OS) const { in emitAttrRanges()
2821 Class->emitAttrRange(OS); in emitAttrRanges()
2855 void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrList() argument
2856 emitSourceFileHeader("List of all attributes that Clang recognizes", OS); in EmitClangAttrList()
2861 Hierarchy.emitDefaultDefines(OS); in EmitClangAttrList()
2862 emitDefaultDefine(OS, "PRAGMA_SPELLING_ATTR", nullptr); in EmitClangAttrList()
2879 Hierarchy.emitAttrLists(OS); in EmitClangAttrList()
2882 emitAttrList(OS, "PRAGMA_SPELLING_ATTR", PragmaAttrs); in EmitClangAttrList()
2885 OS << "#ifdef ATTR_RANGE\n"; in EmitClangAttrList()
2886 Hierarchy.emitAttrRanges(OS); in EmitClangAttrList()
2887 OS << "#undef ATTR_RANGE\n"; in EmitClangAttrList()
2888 OS << "#endif\n"; in EmitClangAttrList()
2890 Hierarchy.emitUndefs(OS); in EmitClangAttrList()
2891 OS << "#undef PRAGMA_SPELLING_ATTR\n"; in EmitClangAttrList()
2895 void EmitClangAttrSubjectMatchRuleList(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrSubjectMatchRuleList() argument
2897 "List of all attribute subject matching rules that Clang recognizes", OS); in EmitClangAttrSubjectMatchRuleList()
2900 emitDefaultDefine(OS, "ATTR_MATCH_RULE", nullptr); in EmitClangAttrSubjectMatchRuleList()
2901 PragmaAttributeSupport.emitMatchRuleList(OS); in EmitClangAttrSubjectMatchRuleList()
2902 OS << "#undef ATTR_MATCH_RULE\n"; in EmitClangAttrSubjectMatchRuleList()
2906 void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrPCHRead() argument
2907 emitSourceFileHeader("Attribute deserialization code", OS); in EmitClangAttrPCHRead()
2914 OS << " switch (Kind) {\n"; in EmitClangAttrPCHRead()
2920 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrPCHRead()
2922 OS << " bool isInherited = Record.readInt();\n"; in EmitClangAttrPCHRead()
2923 OS << " bool isImplicit = Record.readInt();\n"; in EmitClangAttrPCHRead()
2924 OS << " bool isPackExpansion = Record.readInt();\n"; in EmitClangAttrPCHRead()
2929 Args.back()->writePCHReadDecls(OS); in EmitClangAttrPCHRead()
2931 OS << " New = new (Context) " << R.getName() << "Attr(Context, Info"; in EmitClangAttrPCHRead()
2933 OS << ", "; in EmitClangAttrPCHRead()
2934 ri->writePCHReadArgs(OS); in EmitClangAttrPCHRead()
2936 OS << ");\n"; in EmitClangAttrPCHRead()
2938 OS << " cast<InheritableAttr>(New)->setInherited(isInherited);\n"; in EmitClangAttrPCHRead()
2939 OS << " New->setImplicit(isImplicit);\n"; in EmitClangAttrPCHRead()
2940 OS << " New->setPackExpansion(isPackExpansion);\n"; in EmitClangAttrPCHRead()
2941 OS << " break;\n"; in EmitClangAttrPCHRead()
2942 OS << " }\n"; in EmitClangAttrPCHRead()
2944 OS << " }\n"; in EmitClangAttrPCHRead()
2948 void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrPCHWrite() argument
2949 emitSourceFileHeader("Attribute serialization code", OS); in EmitClangAttrPCHWrite()
2954 OS << " switch (A->getKind()) {\n"; in EmitClangAttrPCHWrite()
2959 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrPCHWrite()
2962 OS << " const auto *SA = cast<" << R.getName() in EmitClangAttrPCHWrite()
2965 OS << " Record.push_back(SA->isInherited());\n"; in EmitClangAttrPCHWrite()
2966 OS << " Record.push_back(A->isImplicit());\n"; in EmitClangAttrPCHWrite()
2967 OS << " Record.push_back(A->isPackExpansion());\n"; in EmitClangAttrPCHWrite()
2970 createArgument(*Arg, R.getName())->writePCHWrite(OS); in EmitClangAttrPCHWrite()
2971 OS << " break;\n"; in EmitClangAttrPCHWrite()
2972 OS << " }\n"; in EmitClangAttrPCHWrite()
2974 OS << " }\n"; in EmitClangAttrPCHWrite()
3060 const std::vector<Record *> &Attrs, raw_ostream &OS, in GenerateHasAttrSpellingStringSwitch() argument
3112 OS << " .Case(\"" << S.name() << "\", " << TestStr << ")\n"; in GenerateHasAttrSpellingStringSwitch()
3114 OS << " .Default(0);\n"; in GenerateHasAttrSpellingStringSwitch()
3118 void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrHasAttrImpl() argument
3119 emitSourceFileHeader("Code to implement the __has_attribute logic", OS); in EmitClangAttrHasAttrImpl()
3148 OS << "const llvm::Triple &T = Target.getTriple();\n"; in EmitClangAttrHasAttrImpl()
3149 OS << "switch (Syntax) {\n"; in EmitClangAttrHasAttrImpl()
3150 OS << "case AttrSyntax::GNU:\n"; in EmitClangAttrHasAttrImpl()
3151 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
3152 GenerateHasAttrSpellingStringSwitch(GNU, OS, "GNU"); in EmitClangAttrHasAttrImpl()
3153 OS << "case AttrSyntax::Declspec:\n"; in EmitClangAttrHasAttrImpl()
3154 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
3155 GenerateHasAttrSpellingStringSwitch(Declspec, OS, "Declspec"); in EmitClangAttrHasAttrImpl()
3156 OS << "case AttrSyntax::Microsoft:\n"; in EmitClangAttrHasAttrImpl()
3157 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
3158 GenerateHasAttrSpellingStringSwitch(Microsoft, OS, "Microsoft"); in EmitClangAttrHasAttrImpl()
3159 OS << "case AttrSyntax::Pragma:\n"; in EmitClangAttrHasAttrImpl()
3160 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
3161 GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma"); in EmitClangAttrHasAttrImpl()
3162 auto fn = [&OS](const char *Spelling, const char *Variety, in EmitClangAttrHasAttrImpl()
3164 OS << "case AttrSyntax::" << Variety << ": {\n"; in EmitClangAttrHasAttrImpl()
3168 OS << " else "; in EmitClangAttrHasAttrImpl()
3170 OS << "if (ScopeName == \"\") {\n"; in EmitClangAttrHasAttrImpl()
3172 OS << "if (ScopeName == \"" << I->first << "\") {\n"; in EmitClangAttrHasAttrImpl()
3173 OS << " return llvm::StringSwitch<int>(Name)\n"; in EmitClangAttrHasAttrImpl()
3174 GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first); in EmitClangAttrHasAttrImpl()
3175 OS << "}"; in EmitClangAttrHasAttrImpl()
3177 OS << "\n} break;\n"; in EmitClangAttrHasAttrImpl()
3181 OS << "}\n"; in EmitClangAttrHasAttrImpl()
3184 void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrSpellingListIndex() argument
3186 "into internal identifiers", OS); in EmitClangAttrSpellingListIndex()
3188 OS << " switch (getParsedKind()) {\n"; in EmitClangAttrSpellingListIndex()
3189 OS << " case IgnoredAttribute:\n"; in EmitClangAttrSpellingListIndex()
3190 OS << " case UnknownAttribute:\n"; in EmitClangAttrSpellingListIndex()
3191 OS << " case NoSemaHandlerAttribute:\n"; in EmitClangAttrSpellingListIndex()
3192 OS << " llvm_unreachable(\"Ignored/unknown shouldn't get here\");\n"; in EmitClangAttrSpellingListIndex()
3198 OS << " case AT_" << I.first << ": {\n"; in EmitClangAttrSpellingListIndex()
3200 OS << " if (Name == \"" << Spellings[I].name() << "\" && " in EmitClangAttrSpellingListIndex()
3206 OS << " break;\n"; in EmitClangAttrSpellingListIndex()
3207 OS << " }\n"; in EmitClangAttrSpellingListIndex()
3210 OS << " }\n"; in EmitClangAttrSpellingListIndex()
3211 OS << " return 0;\n"; in EmitClangAttrSpellingListIndex()
3215 void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrASTVisitor() argument
3216 emitSourceFileHeader("Used by RecursiveASTVisitor to visit attributes.", OS); in EmitClangAttrASTVisitor()
3223 OS << "#ifdef ATTR_VISITOR_DECLS_ONLY\n\n"; in EmitClangAttrASTVisitor()
3228 OS << " bool Traverse" in EmitClangAttrASTVisitor()
3230 OS << " bool Visit" in EmitClangAttrASTVisitor()
3235 OS << "\n#else // ATTR_VISITOR_DECLS_ONLY\n\n"; in EmitClangAttrASTVisitor()
3243 OS << "template <typename Derived>\n" in EmitClangAttrASTVisitor()
3253 createArgument(*Arg, R.getName())->writeASTVisitorTraversal(OS); in EmitClangAttrASTVisitor()
3255 OS << " return true;\n"; in EmitClangAttrASTVisitor()
3256 OS << "}\n\n"; in EmitClangAttrASTVisitor()
3260 OS << "template <typename Derived>\n" in EmitClangAttrASTVisitor()
3272 OS << " case attr::" << R.getName() << ":\n" in EmitClangAttrASTVisitor()
3276 OS << " }\n"; // end switch in EmitClangAttrASTVisitor()
3277 OS << " llvm_unreachable(\"bad attribute kind\");\n"; in EmitClangAttrASTVisitor()
3278 OS << "}\n"; // end function in EmitClangAttrASTVisitor()
3279 OS << "#endif // ATTR_VISITOR_DECLS_ONLY\n"; in EmitClangAttrASTVisitor()
3283 raw_ostream &OS, in EmitClangAttrTemplateInstantiateHelper() argument
3286 OS << " switch (At->getKind()) {\n"; in EmitClangAttrTemplateInstantiateHelper()
3291 OS << " case attr::" << R.getName() << ": {\n"; in EmitClangAttrTemplateInstantiateHelper()
3297 OS << " return nullptr;\n"; in EmitClangAttrTemplateInstantiateHelper()
3298 OS << " }\n"; in EmitClangAttrTemplateInstantiateHelper()
3302 OS << " const auto *A = cast<" in EmitClangAttrTemplateInstantiateHelper()
3307 OS << " return A->clone(C);\n"; in EmitClangAttrTemplateInstantiateHelper()
3308 OS << " }\n"; in EmitClangAttrTemplateInstantiateHelper()
3320 ai->writeTemplateInstantiation(OS); in EmitClangAttrTemplateInstantiateHelper()
3322 OS << " return new (C) " << R.getName() << "Attr(C, *A"; in EmitClangAttrTemplateInstantiateHelper()
3324 OS << ", "; in EmitClangAttrTemplateInstantiateHelper()
3325 ai->writeTemplateInstantiationArgs(OS); in EmitClangAttrTemplateInstantiateHelper()
3327 OS << ");\n }\n"; in EmitClangAttrTemplateInstantiateHelper()
3329 OS << " } // end switch\n" in EmitClangAttrTemplateInstantiateHelper()
3335 void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrTemplateInstantiate() argument
3336 emitSourceFileHeader("Template instantiation code for attributes", OS); in EmitClangAttrTemplateInstantiate()
3340 OS << "namespace clang {\n" in EmitClangAttrTemplateInstantiate()
3345 EmitClangAttrTemplateInstantiateHelper(Attrs, OS, /*AppliesToDecl*/false); in EmitClangAttrTemplateInstantiate()
3346 OS << "}\n\n" in EmitClangAttrTemplateInstantiate()
3350 EmitClangAttrTemplateInstantiateHelper(Attrs, OS, /*AppliesToDecl*/true); in EmitClangAttrTemplateInstantiate()
3351 OS << "}\n\n" in EmitClangAttrTemplateInstantiate()
3357 void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrList() argument
3358 emitSourceFileHeader("List of all attributes that Clang recognizes", OS); in EmitClangAttrParsedAttrList()
3360 OS << "#ifndef PARSED_ATTR\n"; in EmitClangAttrParsedAttrList()
3361 OS << "#define PARSED_ATTR(NAME) NAME\n"; in EmitClangAttrParsedAttrList()
3362 OS << "#endif\n\n"; in EmitClangAttrParsedAttrList()
3366 OS << "PARSED_ATTR(" << I.first << ")\n"; in EmitClangAttrParsedAttrList()
3374 static void emitArgInfo(const Record &R, raw_ostream &OS) { in emitArgInfo() argument
3393 OS << " NumArgs = " << ArgCount << ";\n"; in emitArgInfo()
3394 OS << " OptArgs = " << (HasVariadic ? 15 : OptCount) << ";\n"; in emitArgInfo()
3475 static void GenerateCustomAppertainsTo(const Record &Subject, raw_ostream &OS) { in GenerateCustomAppertainsTo() argument
3494 OS << "static bool " << FnName << "(const Decl *D) {\n"; in GenerateCustomAppertainsTo()
3495 OS << " if (const auto *S = dyn_cast<"; in GenerateCustomAppertainsTo()
3496 OS << GetSubjectWithSuffix(Base); in GenerateCustomAppertainsTo()
3497 OS << ">(D))\n"; in GenerateCustomAppertainsTo()
3498 OS << " return " << Subject.getValueAsString("CheckCode") << ";\n"; in GenerateCustomAppertainsTo()
3499 OS << " return false;\n"; in GenerateCustomAppertainsTo()
3500 OS << "}\n\n"; in GenerateCustomAppertainsTo()
3505 static void GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) { in GenerateAppertainsTo() argument
3528 OS << "bool diagAppertainsToDecl(Sema &S, "; in GenerateAppertainsTo()
3529 OS << "const ParsedAttr &Attr, const Decl *D) const override {\n"; in GenerateAppertainsTo()
3530 OS << " if ("; in GenerateAppertainsTo()
3538 OS << "!" << functionNameForCustomAppertainsTo(**I) << "(D)"; in GenerateAppertainsTo()
3540 OS << "!isa<" << GetSubjectWithSuffix(*I) << ">(D)"; in GenerateAppertainsTo()
3544 OS << " && "; in GenerateAppertainsTo()
3546 OS << ") {\n"; in GenerateAppertainsTo()
3547 OS << " S.Diag(Attr.getLoc(), diag::"; in GenerateAppertainsTo()
3548 OS << (Warn ? "warn_attribute_wrong_decl_type_str" : in GenerateAppertainsTo()
3550 OS << ")\n"; in GenerateAppertainsTo()
3551 OS << " << Attr << "; in GenerateAppertainsTo()
3552 OS << CalculateDiagnostic(*SubjectObj) << ";\n"; in GenerateAppertainsTo()
3553 OS << " return false;\n"; in GenerateAppertainsTo()
3554 OS << " }\n"; in GenerateAppertainsTo()
3555 OS << " return true;\n"; in GenerateAppertainsTo()
3556 OS << "}\n\n"; in GenerateAppertainsTo()
3561 raw_ostream &OS) { in emitAttributeMatchRules() argument
3562 OS << "static bool checkAttributeMatchRuleAppliesTo(const Decl *D, " in emitAttributeMatchRules()
3564 OS << " switch (rule) {\n"; in emitAttributeMatchRules()
3567 OS << " case " << Rule.getEnumValue() << ":\n"; in emitAttributeMatchRules()
3568 OS << " assert(false && \"Abstract matcher rule isn't allowed\");\n"; in emitAttributeMatchRules()
3569 OS << " return false;\n"; in emitAttributeMatchRules()
3574 OS << " case " << Rule.getEnumValue() << ":\n"; in emitAttributeMatchRules()
3575 OS << " return "; in emitAttributeMatchRules()
3581 OS << functionNameForCustomAppertainsTo(**I) << "(D)"; in emitAttributeMatchRules()
3583 OS << "isa<" << GetSubjectWithSuffix(*I) << ">(D)"; in emitAttributeMatchRules()
3586 OS << " || "; in emitAttributeMatchRules()
3588 OS << ";\n"; in emitAttributeMatchRules()
3590 OS << " }\n"; in emitAttributeMatchRules()
3591 OS << " llvm_unreachable(\"Invalid match rule\");\nreturn false;\n"; in emitAttributeMatchRules()
3592 OS << "}\n\n"; in emitAttributeMatchRules()
3596 raw_ostream &OS) { in GenerateLangOptRequirements() argument
3603 OS << "bool diagLangOpts(Sema &S, const ParsedAttr &Attr) "; in GenerateLangOptRequirements()
3604 OS << "const override {\n"; in GenerateLangOptRequirements()
3605 OS << " auto &LangOpts = S.LangOpts;\n"; in GenerateLangOptRequirements()
3606 OS << " if (" << GenerateTestExpression(LangOpts) << ")\n"; in GenerateLangOptRequirements()
3607 OS << " return true;\n\n"; in GenerateLangOptRequirements()
3608 OS << " S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) "; in GenerateLangOptRequirements()
3609 OS << "<< Attr;\n"; in GenerateLangOptRequirements()
3610 OS << " return false;\n"; in GenerateLangOptRequirements()
3611 OS << "}\n\n"; in GenerateLangOptRequirements()
3616 raw_ostream &OS) { in GenerateTargetRequirements() argument
3648 OS << "bool existsInTarget(const TargetInfo &Target) const override {\n"; in GenerateTargetRequirements()
3650 OS << " const llvm::Triple &T = Target.getTriple(); (void)T;\n"; in GenerateTargetRequirements()
3651 OS << " return " << Test << ";\n"; in GenerateTargetRequirements()
3652 OS << "}\n\n"; in GenerateTargetRequirements()
3656 raw_ostream &OS) { in GenerateSpellingIndexToSemanticSpelling() argument
3673 OS << "unsigned spellingIndexToSemanticSpelling("; in GenerateSpellingIndexToSemanticSpelling()
3674 OS << "const ParsedAttr &Attr) const override {\n"; in GenerateSpellingIndexToSemanticSpelling()
3675 OS << Enum; in GenerateSpellingIndexToSemanticSpelling()
3676 OS << " unsigned Idx = Attr.getAttributeSpellingListIndex();\n"; in GenerateSpellingIndexToSemanticSpelling()
3677 WriteSemanticSpellingSwitch("Idx", SemanticToSyntacticMap, OS); in GenerateSpellingIndexToSemanticSpelling()
3678 OS << "}\n\n"; in GenerateSpellingIndexToSemanticSpelling()
3681 static void GenerateHandleDeclAttribute(const Record &Attr, raw_ostream &OS) { in GenerateHandleDeclAttribute() argument
3687 OS << "AttrHandling handleDeclAttribute(Sema &S, Decl *D,"; in GenerateHandleDeclAttribute()
3688 OS << "const ParsedAttr &Attr) const override {\n"; in GenerateHandleDeclAttribute()
3689 OS << " D->addAttr(::new (S.Context) " << Attr.getName(); in GenerateHandleDeclAttribute()
3690 OS << "Attr(S.Context, Attr));\n"; in GenerateHandleDeclAttribute()
3691 OS << " return AttributeApplied;\n"; in GenerateHandleDeclAttribute()
3692 OS << "}\n\n"; in GenerateHandleDeclAttribute()
3704 void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrImpl() argument
3705 emitSourceFileHeader("Parsed attribute helpers", OS); in EmitClangAttrParsedAttrImpl()
3724 GenerateCustomAppertainsTo(*Subject, OS); in EmitClangAttrParsedAttrImpl()
3741 OS << "static constexpr ParsedAttrInfo::Spelling " << I->first in EmitClangAttrParsedAttrImpl()
3752 OS << " {AttributeCommonInfo::AS_" << S.variety(); in EmitClangAttrParsedAttrImpl()
3753 OS << ", \"" << Spelling << "\"},\n"; in EmitClangAttrParsedAttrImpl()
3755 OS << "};\n"; in EmitClangAttrParsedAttrImpl()
3757 OS << "struct ParsedAttrInfo" << I->first in EmitClangAttrParsedAttrImpl()
3759 OS << " ParsedAttrInfo" << I->first << "() {\n"; in EmitClangAttrParsedAttrImpl()
3760 OS << " AttrKind = ParsedAttr::AT_" << AttrName << ";\n"; in EmitClangAttrParsedAttrImpl()
3761 emitArgInfo(Attr, OS); in EmitClangAttrParsedAttrImpl()
3762 OS << " HasCustomParsing = "; in EmitClangAttrParsedAttrImpl()
3763 OS << Attr.getValueAsBit("HasCustomParsing") << ";\n"; in EmitClangAttrParsedAttrImpl()
3764 OS << " IsTargetSpecific = "; in EmitClangAttrParsedAttrImpl()
3765 OS << Attr.isSubClassOf("TargetSpecificAttr") << ";\n"; in EmitClangAttrParsedAttrImpl()
3766 OS << " IsType = "; in EmitClangAttrParsedAttrImpl()
3767 OS << (Attr.isSubClassOf("TypeAttr") || in EmitClangAttrParsedAttrImpl()
3769 OS << " IsStmt = "; in EmitClangAttrParsedAttrImpl()
3770 OS << Attr.isSubClassOf("StmtAttr") << ";\n"; in EmitClangAttrParsedAttrImpl()
3771 OS << " IsKnownToGCC = "; in EmitClangAttrParsedAttrImpl()
3772 OS << IsKnownToGCC(Attr) << ";\n"; in EmitClangAttrParsedAttrImpl()
3773 OS << " IsSupportedByPragmaAttribute = "; in EmitClangAttrParsedAttrImpl()
3774 OS << PragmaAttributeSupport.isAttributedSupported(*I->second) << ";\n"; in EmitClangAttrParsedAttrImpl()
3776 OS << " Spellings = " << I->first << "Spellings;\n"; in EmitClangAttrParsedAttrImpl()
3777 OS << " }\n"; in EmitClangAttrParsedAttrImpl()
3778 GenerateAppertainsTo(Attr, OS); in EmitClangAttrParsedAttrImpl()
3779 GenerateLangOptRequirements(Attr, OS); in EmitClangAttrParsedAttrImpl()
3780 GenerateTargetRequirements(Attr, Dupes, OS); in EmitClangAttrParsedAttrImpl()
3781 GenerateSpellingIndexToSemanticSpelling(Attr, OS); in EmitClangAttrParsedAttrImpl()
3782 PragmaAttributeSupport.generateStrictConformsTo(*I->second, OS); in EmitClangAttrParsedAttrImpl()
3783 GenerateHandleDeclAttribute(Attr, OS); in EmitClangAttrParsedAttrImpl()
3784 OS << "static const ParsedAttrInfo" << I->first << " Instance;\n"; in EmitClangAttrParsedAttrImpl()
3785 OS << "};\n"; in EmitClangAttrParsedAttrImpl()
3786 OS << "const ParsedAttrInfo" << I->first << " ParsedAttrInfo" << I->first in EmitClangAttrParsedAttrImpl()
3790 OS << "static const ParsedAttrInfo *AttrInfoMap[] = {\n"; in EmitClangAttrParsedAttrImpl()
3792 OS << "&ParsedAttrInfo" << I->first << "::Instance,\n"; in EmitClangAttrParsedAttrImpl()
3794 OS << "};\n\n"; in EmitClangAttrParsedAttrImpl()
3797 emitAttributeMatchRules(PragmaAttributeSupport, OS); in EmitClangAttrParsedAttrImpl()
3801 void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrParsedAttrKinds() argument
3802 emitSourceFileHeader("Attribute name matcher", OS); in EmitClangAttrParsedAttrKinds()
3876 OS << "static AttributeCommonInfo::Kind getAttrKind(StringRef Name, "; in EmitClangAttrParsedAttrKinds()
3877 OS << "AttributeCommonInfo::Syntax Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3878 OS << " if (AttributeCommonInfo::AS_GNU == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3879 StringMatcher("Name", GNU, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3880 OS << " } else if (AttributeCommonInfo::AS_Declspec == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3881 StringMatcher("Name", Declspec, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3882 OS << " } else if (AttributeCommonInfo::AS_Microsoft == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3883 StringMatcher("Name", Microsoft, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3884 OS << " } else if (AttributeCommonInfo::AS_CXX11 == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3885 StringMatcher("Name", CXX11, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3886 OS << " } else if (AttributeCommonInfo::AS_C2x == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3887 StringMatcher("Name", C2x, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3888 OS << " } else if (AttributeCommonInfo::AS_Keyword == Syntax || "; in EmitClangAttrParsedAttrKinds()
3889 OS << "AttributeCommonInfo::AS_ContextSensitiveKeyword == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3890 StringMatcher("Name", Keywords, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3891 OS << " } else if (AttributeCommonInfo::AS_Pragma == Syntax) {\n"; in EmitClangAttrParsedAttrKinds()
3892 StringMatcher("Name", Pragma, OS).Emit(); in EmitClangAttrParsedAttrKinds()
3893 OS << " }\n"; in EmitClangAttrParsedAttrKinds()
3894 OS << " return AttributeCommonInfo::UnknownAttribute;\n" in EmitClangAttrParsedAttrKinds()
3899 void EmitClangAttrTextNodeDump(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrTextNodeDump() argument
3900 emitSourceFileHeader("Attribute text node dumper", OS); in EmitClangAttrTextNodeDump()
3917 SS << " OS << \" \" << A->getSpelling();\n"; in EmitClangAttrTextNodeDump()
3924 OS << " void Visit" << R.getName() << "Attr(const " << R.getName() in EmitClangAttrTextNodeDump()
3927 OS << " const auto *SA = cast<" << R.getName() in EmitClangAttrTextNodeDump()
3929 OS << SS.str(); in EmitClangAttrTextNodeDump()
3930 OS << " }\n"; in EmitClangAttrTextNodeDump()
3935 void EmitClangAttrNodeTraverse(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrNodeTraverse() argument
3936 emitSourceFileHeader("Attribute text node traverser", OS); in EmitClangAttrNodeTraverse()
3951 OS << " void Visit" << R.getName() << "Attr(const " << R.getName() in EmitClangAttrNodeTraverse()
3954 OS << " const auto *SA = cast<" << R.getName() in EmitClangAttrNodeTraverse()
3956 OS << SS.str(); in EmitClangAttrNodeTraverse()
3957 OS << " }\n"; in EmitClangAttrNodeTraverse()
3963 raw_ostream &OS) { in EmitClangAttrParserStringSwitches() argument
3964 emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS); in EmitClangAttrParserStringSwitches()
3965 emitClangAttrArgContextList(Records, OS); in EmitClangAttrParserStringSwitches()
3966 emitClangAttrIdentifierArgList(Records, OS); in EmitClangAttrParserStringSwitches()
3967 emitClangAttrVariadicIdentifierArgList(Records, OS); in EmitClangAttrParserStringSwitches()
3968 emitClangAttrThisIsaIdentifierArgList(Records, OS); in EmitClangAttrParserStringSwitches()
3969 emitClangAttrTypeArgList(Records, OS); in EmitClangAttrParserStringSwitches()
3970 emitClangAttrLateParsedList(Records, OS); in EmitClangAttrParserStringSwitches()
3974 raw_ostream &OS) { in EmitClangAttrSubjectMatchRulesParserStringSwitches() argument
3975 getPragmaAttributeSupport(Records).generateParsingHelpers(OS); in EmitClangAttrSubjectMatchRulesParserStringSwitches()
4041 raw_ostream &OS) { in WriteCategoryHeader() argument
4043 OS << Name << "\n" << std::string(Name.size(), '=') << "\n"; in WriteCategoryHeader()
4048 OS << ContentStr.trim(); in WriteCategoryHeader()
4050 OS << "\n\n"; in WriteCategoryHeader()
4100 const DocumentationData &Doc, raw_ostream &OS) { in WriteDocumentation() argument
4101 OS << Doc.Heading << "\n" << std::string(Doc.Heading.length(), '-') << "\n"; in WriteDocumentation()
4104 OS << ".. csv-table:: Supported Syntaxes\n"; in WriteDocumentation()
4105 OS << " :header: \"GNU\", \"C++11\", \"C2x\", \"``__declspec``\","; in WriteDocumentation()
4106 OS << " \"Keyword\", \"``#pragma``\", \"``#pragma clang attribute``\"\n\n"; in WriteDocumentation()
4107 OS << " \""; in WriteDocumentation()
4118 OS << " |br| "; in WriteDocumentation()
4119 OS << "``" << Spelling << "``"; in WriteDocumentation()
4123 OS << "\",\""; in WriteDocumentation()
4128 OS << "Yes"; in WriteDocumentation()
4129 OS << "\"\n\n"; in WriteDocumentation()
4134 OS << "This attribute has been deprecated, and may be removed in a future " in WriteDocumentation()
4139 OS << " This attribute has been superseded by ``" << Replacement in WriteDocumentation()
4141 OS << "\n\n"; in WriteDocumentation()
4146 OS << ContentStr.trim(); in WriteDocumentation()
4148 OS << "\n\n\n"; in WriteDocumentation()
4151 void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) { in EmitClangAttrDocs() argument
4160 OS << Documentation->getValueAsString("Intro") << "\n"; in EmitClangAttrDocs()
4191 WriteCategoryHeader(I.first, OS); in EmitClangAttrDocs()
4201 WriteDocumentation(Records, Doc, OS); in EmitClangAttrDocs()
4206 raw_ostream &OS) { in EmitTestPragmaAttributeSupportedAttributes() argument
4209 OS << "#pragma clang attribute supports the following attributes:\n"; in EmitTestPragmaAttributeSupportedAttributes()
4213 OS << I.first; in EmitTestPragmaAttributeSupportedAttributes()
4215 OS << " ()\n"; in EmitTestPragmaAttributeSupportedAttributes()
4221 OS << " ("; in EmitTestPragmaAttributeSupportedAttributes()
4224 OS << ", "; in EmitTestPragmaAttributeSupportedAttributes()
4228 OS << RuleSet.getRule().getEnumValueName(); in EmitTestPragmaAttributeSupportedAttributes()
4231 OS << "("; in EmitTestPragmaAttributeSupportedAttributes()
4234 OS << ", "; in EmitTestPragmaAttributeSupportedAttributes()
4235 OS << Rule.value().getEnumValueName(); in EmitTestPragmaAttributeSupportedAttributes()
4237 OS << ")"; in EmitTestPragmaAttributeSupportedAttributes()
4239 OS << ")\n"; in EmitTestPragmaAttributeSupportedAttributes()
4241 OS << "End of supported attributes.\n"; in EmitTestPragmaAttributeSupportedAttributes()