Lines Matching refs:OS
193 virtual void writeAccessors(raw_ostream &OS) const = 0;
194 virtual void writeAccessorDefinitions(raw_ostream &OS) const {}
195 virtual void writeASTVisitorTraversal(raw_ostream &OS) const {}
196 virtual void writeCloneArgs(raw_ostream &OS) const = 0;
197 virtual void writeTemplateInstantiationArgs(raw_ostream &OS) const = 0;
198 virtual void writeTemplateInstantiation(raw_ostream &OS) const {}
199 virtual void writeCtorBody(raw_ostream &OS) const {}
200 virtual void writeCtorInitializers(raw_ostream &OS) const = 0;
201 virtual void writeCtorDefaultInitializers(raw_ostream &OS) const = 0;
202 virtual void writeCtorParameters(raw_ostream &OS) const = 0;
203 virtual void writeDeclarations(raw_ostream &OS) const = 0;
204 virtual void writePCHReadArgs(raw_ostream &OS) const = 0;
205 virtual void writePCHReadDecls(raw_ostream &OS) const = 0;
206 virtual void writePCHWrite(raw_ostream &OS) const = 0;
207 virtual void writeValue(raw_ostream &OS) const = 0;
208 virtual void writeDump(raw_ostream &OS) const = 0;
209 virtual void writeDumpChildren(raw_ostream &OS) const {}
210 virtual void writeHasChildren(raw_ostream &OS) const { OS << "false"; }
216 virtual void writeImplicitCtorArgs(raw_ostream &OS) const {
217 OS << getUpperName();
231 void writeAccessors(raw_ostream &OS) const override {
232 OS << " " << type << " get" << getUpperName() << "() const {\n";
233 OS << " return " << getLowerName() << ";\n";
234 OS << " }";
236 void writeCloneArgs(raw_ostream &OS) const override {
237 OS << getLowerName();
239 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
240 OS << "A->get" << getUpperName() << "()";
242 void writeCtorInitializers(raw_ostream &OS) const override {
243 OS << getLowerName() << "(" << getUpperName() << ")";
245 void writeCtorDefaultInitializers(raw_ostream &OS) const override {
246 OS << getLowerName() << "()";
248 void writeCtorParameters(raw_ostream &OS) const override {
249 OS << type << " " << getUpperName();
251 void writeDeclarations(raw_ostream &OS) const override {
252 OS << type << " " << getLowerName() << ";";
254 void writePCHReadDecls(raw_ostream &OS) const override {
256 OS << " " << type << " " << getLowerName() << " = " << read << ";\n";
258 void writePCHReadArgs(raw_ostream &OS) const override {
259 OS << getLowerName();
261 void writePCHWrite(raw_ostream &OS) const override {
262 OS << " " << WritePCHRecord(type, "SA->get" +
265 void writeValue(raw_ostream &OS) const override {
267 OS << "\" << get" << getUpperName()
270 OS << "\" << get" << getUpperName() << "()->getName() << \"";
272 OS << "\" << get" << getUpperName() << "().getAsString() << \"";
274 OS << "\" << get" << getUpperName() << "() << \"";
277 void writeDump(raw_ostream &OS) const override {
279 OS << " OS << \" \";\n";
280 OS << " dumpBareDeclRef(SA->get" << getUpperName() << "());\n";
283 OS << " if (SA->get" << getUpperName() << "())\n ";
284 OS << " OS << \" \" << SA->get" << getUpperName()
287 OS << " OS << \" \" << SA->get" << getUpperName()
290 OS << " if (SA->get" << getUpperName() << "()) OS << \" "
293 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n";
308 void writeAccessors(raw_ostream &OS) const override {
309 SimpleArgument::writeAccessors(OS);
311 OS << "\n\n static const " << getType() << " Default" << getUpperName()
322 void writeAccessors(raw_ostream &OS) const override {
323 OS << " llvm::StringRef get" << getUpperName() << "() const {\n";
324 OS << " return llvm::StringRef(" << getLowerName() << ", "
326 OS << " }\n";
327 OS << " unsigned get" << getUpperName() << "Length() const {\n";
328 OS << " return " << getLowerName() << "Length;\n";
329 OS << " }\n";
330 OS << " void set" << getUpperName()
332 OS << " " << getLowerName() << "Length = S.size();\n";
333 OS << " this->" << getLowerName() << " = new (C, 1) char ["
335 OS << " if (!S.empty())\n";
336 OS << " std::memcpy(this->" << getLowerName() << ", S.data(), "
338 OS << " }";
340 void writeCloneArgs(raw_ostream &OS) const override {
341 OS << "get" << getUpperName() << "()";
343 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
344 OS << "A->get" << getUpperName() << "()";
346 void writeCtorBody(raw_ostream &OS) const override {
347 OS << " if (!" << getUpperName() << ".empty())\n";
348 OS << " std::memcpy(" << getLowerName() << ", " << getUpperName()
351 void writeCtorInitializers(raw_ostream &OS) const override {
352 OS << getLowerName() << "Length(" << getUpperName() << ".size()),"
356 void writeCtorDefaultInitializers(raw_ostream &OS) const override {
357 OS << getLowerName() << "Length(0)," << getLowerName() << "(nullptr)";
359 void writeCtorParameters(raw_ostream &OS) const override {
360 OS << "llvm::StringRef " << getUpperName();
362 void writeDeclarations(raw_ostream &OS) const override {
363 OS << "unsigned " << getLowerName() << "Length;\n";
364 OS << "char *" << getLowerName() << ";";
366 void writePCHReadDecls(raw_ostream &OS) const override {
367 OS << " std::string " << getLowerName()
370 void writePCHReadArgs(raw_ostream &OS) const override {
371 OS << getLowerName();
373 void writePCHWrite(raw_ostream &OS) const override {
374 OS << " AddString(SA->get" << getUpperName() << "(), Record);\n";
376 void writeValue(raw_ostream &OS) const override {
377 OS << "\\\"\" << get" << getUpperName() << "() << \"\\\"";
379 void writeDump(raw_ostream &OS) const override {
380 OS << " OS << \" \\\"\" << SA->get" << getUpperName()
391 void writeAccessors(raw_ostream &OS) const override {
392 OS << " bool is" << getUpperName() << "Dependent() const;\n";
394 OS << " unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n";
396 OS << " bool is" << getUpperName() << "Expr() const {\n";
397 OS << " return is" << getLowerName() << "Expr;\n";
398 OS << " }\n";
400 OS << " Expr *get" << getUpperName() << "Expr() const {\n";
401 OS << " assert(is" << getLowerName() << "Expr);\n";
402 OS << " return " << getLowerName() << "Expr;\n";
403 OS << " }\n";
405 OS << " TypeSourceInfo *get" << getUpperName() << "Type() const {\n";
406 OS << " assert(!is" << getLowerName() << "Expr);\n";
407 OS << " return " << getLowerName() << "Type;\n";
408 OS << " }";
410 void writeAccessorDefinitions(raw_ostream &OS) const override {
411 OS << "bool " << getAttrName() << "Attr::is" << getUpperName()
413 OS << " if (is" << getLowerName() << "Expr)\n";
414 OS << " return " << getLowerName() << "Expr && (" << getLowerName()
417 OS << " else\n";
418 OS << " return " << getLowerName()
420 OS << "}\n";
425 OS << "unsigned " << getAttrName() << "Attr::get" << getUpperName()
427 OS << " assert(!is" << getUpperName() << "Dependent());\n";
428 OS
429 OS << " return " << getLowerName() << "Expr ? " << getLowerName()
433 OS << " else\n";
434 OS << " return 0; // FIXME\n";
435 OS << "}\n";
437 void writeCloneArgs(raw_ostream &OS) const override {
438 OS << "is" << getLowerName() << "Expr, is" << getLowerName()
443 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
447 void writeCtorBody(raw_ostream &OS) const override {
448 OS << " if (is" << getLowerName() << "Expr)\n";
449 OS << " " << getLowerName() << "Expr = reinterpret_cast<Expr *>("
451 OS << " else\n";
452 OS << " " << getLowerName()
456 void writeCtorInitializers(raw_ostream &OS) const override {
457 OS << "is" << getLowerName() << "Expr(Is" << getUpperName() << "Expr)";
459 void writeCtorDefaultInitializers(raw_ostream &OS) const override {
460 OS << "is" << getLowerName() << "Expr(false)";
462 void writeCtorParameters(raw_ostream &OS) const override {
463 OS << "bool Is" << getUpperName() << "Expr, void *" << getUpperName();
465 void writeImplicitCtorArgs(raw_ostream &OS) const override {
466 OS << "Is" << getUpperName() << "Expr, " << getUpperName();
468 void writeDeclarations(raw_ostream &OS) const override {
469 OS << "bool is" << getLowerName() << "Expr;\n";
470 OS << "union {\n";
471 OS << "Expr *" << getLowerName() << "Expr;\n";
472 OS << "TypeSourceInfo *" << getLowerName() << "Type;\n";
473 OS << "};";
475 void writePCHReadArgs(raw_ostream &OS) const override {
476 OS << "is" << getLowerName() << "Expr, " << getLowerName() << "Ptr";
478 void writePCHReadDecls(raw_ostream &OS) const override {
479 OS << " bool is" << getLowerName() << "Expr = Record[Idx++];\n";
480 OS << " void *" << getLowerName() << "Ptr;\n";
481 OS << " if (is" << getLowerName() << "Expr)\n";
482 OS << " " << getLowerName() << "Ptr = ReadExpr(F);\n";
483 OS << " else\n";
484 OS << " " << getLowerName()
487 void writePCHWrite(raw_ostream &OS) const override {
488 OS << " Record.push_back(SA->is" << getUpperName() << "Expr());\n";
489 OS << " if (SA->is" << getUpperName() << "Expr())\n";
490 OS << " AddStmt(SA->get" << getUpperName() << "Expr());\n";
491 OS << " else\n";
492 OS << " AddTypeSourceInfo(SA->get" << getUpperName()
495 void writeValue(raw_ostream &OS) const override {
496 OS << "\";\n";
498 OS << " if (is" << getLowerName() << "Expr && "
500 OS << " " << getLowerName() << "Expr->printPretty(OS, nullptr, Policy);\n";
501 OS << " OS << \"";
503 void writeDump(raw_ostream &OS) const override {
505 void writeDumpChildren(raw_ostream &OS) const override {
506 OS << " if (SA->is" << getUpperName() << "Expr())\n";
507 OS << " dumpStmt(SA->get" << getUpperName() << "Expr());\n";
508 OS << " else\n";
509 OS << " dumpType(SA->get" << getUpperName()
512 void writeHasChildren(raw_ostream &OS) const override {
513 OS << "SA->is" << getUpperName() << "Expr()";
521 // Assumed to receive a parameter: raw_ostream OS.
522 virtual void writeValueImpl(raw_ostream &OS) const {
523 OS << " OS << Val;\n";
534 void writeAccessors(raw_ostream &OS) const override {
539 OS << " typedef " << Type << "* " << IteratorType << ";\n";
540 OS << " " << IteratorType << " " << BeginFn << " const {"
542 OS << " " << IteratorType << " " << EndFn << " const {"
544 OS << " unsigned " << getLowerName() << "_size() const {"
546 OS << " llvm::iterator_range<" << IteratorType << "> " << RangeName
550 void writeCloneArgs(raw_ostream &OS) const override {
551 OS << ArgName << ", " << ArgSizeName;
553 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
555 OS << "A->" << getLowerName() << "_begin(), "
558 void writeCtorBody(raw_ostream &OS) const override {
559 OS << " std::copy(" << getUpperName() << ", " << getUpperName()
562 void writeCtorInitializers(raw_ostream &OS) const override {
563 OS << ArgSizeName << "(" << getUpperName() << "Size), "
567 void writeCtorDefaultInitializers(raw_ostream &OS) const override {
568 OS << ArgSizeName << "(0), " << ArgName << "(nullptr)";
570 void writeCtorParameters(raw_ostream &OS) const override {
571 OS << getType() << " *" << getUpperName() << ", unsigned "
574 void writeImplicitCtorArgs(raw_ostream &OS) const override {
575 OS << getUpperName() << ", " << getUpperName() << "Size";
577 void writeDeclarations(raw_ostream &OS) const override {
578 OS << " unsigned " << ArgSizeName << ";\n";
579 OS << " " << getType() << " *" << ArgName << ";";
581 void writePCHReadDecls(raw_ostream &OS) const override {
582 OS << " unsigned " << getLowerName() << "Size = Record[Idx++];\n";
583 OS << " SmallVector<" << Type << ", 4> " << getLowerName()
585 OS << " " << getLowerName() << ".reserve(" << getLowerName()
587 OS << " for (unsigned i = " << getLowerName() << "Size; i; --i)\n";
590 OS << " " << getLowerName() << ".push_back(" << read << ");\n";
592 void writePCHReadArgs(raw_ostream &OS) const override {
593 OS << getLowerName() << ".data(), " << getLowerName() << "Size";
595 void writePCHWrite(raw_ostream &OS) const override {
596 OS << " Record.push_back(SA->" << getLowerName() << "_size());\n";
597 OS << " for (auto &Val : SA->" << RangeName << "())\n";
598 OS << " " << WritePCHRecord(Type, "Val");
600 void writeValue(raw_ostream &OS) const override {
601 OS << "\";\n";
602 OS << " bool isFirst = true;\n"
605 << " else OS << \", \";\n";
606 writeValueImpl(OS);
607 OS << " }\n";
608 OS << " OS << \"";
610 void writeDump(raw_ostream &OS) const override {
611 OS << " for (const auto &Val : SA->" << RangeName << "())\n";
612 OS << " OS << \" \" << Val;\n";
647 void writeAccessors(raw_ostream &OS) const override {
648 OS << " " << type << " get" << getUpperName() << "() const {\n";
649 OS << " return " << getLowerName() << ";\n";
650 OS << " }";
652 void writeCloneArgs(raw_ostream &OS) const override {
653 OS << getLowerName();
655 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
656 OS << "A->get" << getUpperName() << "()";
658 void writeCtorInitializers(raw_ostream &OS) const override {
659 OS << getLowerName() << "(" << getUpperName() << ")";
661 void writeCtorDefaultInitializers(raw_ostream &OS) const override {
662 OS << getLowerName() << "(" << type << "(0))";
664 void writeCtorParameters(raw_ostream &OS) const override {
665 OS << type << " " << getUpperName();
667 void writeDeclarations(raw_ostream &OS) const override {
672 OS << "public:\n";
673 OS << " enum " << type << " {\n";
675 OS << " " << *i << ",\n";
676 OS << " " << *e << "\n";
677 OS << " };\n";
678 OS << "private:\n";
679 OS << " " << type << " " << getLowerName() << ";";
681 void writePCHReadDecls(raw_ostream &OS) const override {
682 OS << " " << getAttrName() << "Attr::" << type << " " << getLowerName()
686 void writePCHReadArgs(raw_ostream &OS) const override {
687 OS << getLowerName();
689 void writePCHWrite(raw_ostream &OS) const override {
690 OS << "Record.push_back(SA->get" << getUpperName() << "());\n";
692 void writeValue(raw_ostream &OS) const override {
696 OS << "\\\"\" << " << getAttrName() << "Attr::Convert" << type << "ToStr(get"
699 void writeDump(raw_ostream &OS) const override {
700 OS << " switch(SA->get" << getUpperName() << "()) {\n";
702 OS << " case " << getAttrName() << "Attr::" << I << ":\n";
703 OS << " OS << \" " << I << "\";\n";
704 OS << " break;\n";
706 OS << " }\n";
709 void writeConversion(raw_ostream &OS) const {
710 OS << " static bool ConvertStrTo" << type << "(StringRef Val, ";
711 OS << type << " &Out) {\n";
712 OS << " Optional<" << type << "> R = llvm::StringSwitch<Optional<";
713 OS << type << ">>(Val)\n";
715 OS << " .Case(\"" << values[I] << "\", ";
716 OS << getAttrName() << "Attr::" << enums[I] << ")\n";
718 OS << " .Default(Optional<" << type << ">());\n";
719 OS << " if (R) {\n";
720 OS << " Out = *R;\n return true;\n }\n";
721 OS << " return false;\n";
722 OS << " }\n\n";
728 OS << " static const char *Convert" << type << "ToStr("
734 OS << " case " << getAttrName() << "Attr::" << enums[I]
737 OS << " }\n"
748 void writeValueImpl(raw_ostream &OS) const override {
752 OS << " OS << \"\\\"\" << " << getAttrName() << "Attr::Convert" << type
772 void writeDeclarations(raw_ostream &OS) const override {
777 OS << "public:\n";
778 OS << " enum " << type << " {\n";
780 OS << " " << *i << ",\n";
781 OS << " " << *e << "\n";
782 OS << " };\n";
783 OS << "private:\n";
785 VariadicArgument::writeDeclarations(OS);
787 void writeDump(raw_ostream &OS) const override {
788 OS << " for (" << getAttrName() << "Attr::" << getLowerName()
791 OS << " switch(*I) {\n";
793 OS << " case " << getAttrName() << "Attr::" << UI << ":\n";
794 OS << " OS << \" " << UI << "\";\n";
795 OS << " break;\n";
797 OS << " }\n";
798 OS << " }\n";
800 void writePCHReadDecls(raw_ostream &OS) const override {
801 OS << " unsigned " << getLowerName() << "Size = Record[Idx++];\n";
802 OS << " SmallVector<" << QualifiedTypeName << ", 4> " << getLowerName()
804 OS << " " << getLowerName() << ".reserve(" << getLowerName()
806 OS << " for (unsigned i = " << getLowerName() << "Size; i; --i)\n";
807 OS << " " << getLowerName() << ".push_back(" << "static_cast<"
810 void writePCHWrite(raw_ostream &OS) const override {
811 OS << " Record.push_back(SA->" << getLowerName() << "_size());\n";
812 OS << " for (" << getAttrName() << "Attr::" << getLowerName()
815 OS << " " << WritePCHRecord(QualifiedTypeName, "(*i)");
817 void writeConversion(raw_ostream &OS) const {
818 OS << " static bool ConvertStrTo" << type << "(StringRef Val, ";
819 OS
820 OS << " Optional<" << type << "> R = llvm::StringSwitch<Optional<";
821 OS << type << ">>(Val)\n";
823 OS << " .Case(\"" << values[I] << "\", ";
824 OS << getAttrName() << "Attr::" << enums[I] << ")\n";
826 OS << " .Default(Optional<" << type << ">());\n";
827 OS << " if (R) {\n";
828 OS << " Out = *R;\n return true;\n }\n";
829 OS << " return false;\n";
830 OS << " }\n\n";
832 OS << " static const char *Convert" << type << "ToStr("
838 OS << " case " << getAttrName() << "Attr::" << enums[I]
841 OS << " }\n"
853 void writeAccessors(raw_ostream &OS) const override {
854 OS << " VersionTuple get" << getUpperName() << "() const {\n";
855 OS << " return " << getLowerName() << ";\n";
856 OS << " }\n";
857 OS << " void set" << getUpperName()
859 OS << " " << getLowerName() << " = V;\n";
860 OS << " }";
862 void writeCloneArgs(raw_ostream &OS) const override {
863 OS << "get" << getUpperName() << "()";
865 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
866 OS << "A->get" << getUpperName() << "()";
868 void writeCtorInitializers(raw_ostream &OS) const override {
869 OS << getLowerName() << "(" << getUpperName() << ")";
871 void writeCtorDefaultInitializers(raw_ostream &OS) const override {
872 OS << getLowerName() << "()";
874 void writeCtorParameters(raw_ostream &OS) const override {
875 OS << "VersionTuple " << getUpperName();
877 void writeDeclarations(raw_ostream &OS) const override {
878 OS << "VersionTuple " << getLowerName() << ";\n";
880 void writePCHReadDecls(raw_ostream &OS) const override {
881 OS << " VersionTuple " << getLowerName()
884 void writePCHReadArgs(raw_ostream &OS) const override {
885 OS << getLowerName();
887 void writePCHWrite(raw_ostream &OS) const override {
888 OS << " AddVersionTuple(SA->get" << getUpperName() << "(), Record);\n";
890 void writeValue(raw_ostream &OS) const override {
891 OS << getLowerName() << "=\" << get" << getUpperName() << "() << \"";
893 void writeDump(raw_ostream &OS) const override {
894 OS << " OS << \" \" << SA->get" << getUpperName() << "();\n";
904 void writeASTVisitorTraversal(raw_ostream &OS) const override {
905 OS << " if (!"
907 OS << " return false;\n";
910 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
911 OS << "tempInst" << getUpperName();
914 void writeTemplateInstantiation(raw_ostream &OS) const override {
915 OS << " " << getType() << " tempInst" << getUpperName() << ";\n";
916 OS << " {\n";
917 OS << " EnterExpressionEvaluationContext "
919 OS << " ExprResult " << "Result = S.SubstExpr("
921 OS << " tempInst" << getUpperName() << " = "
923 OS << " }\n";
926 void writeDump(raw_ostream &OS) const override {}
928 void writeDumpChildren(raw_ostream &OS) const override {
929 OS << " dumpStmt(SA->get" << getUpperName() << "());\n";
931 void writeHasChildren(raw_ostream &OS) const override { OS << "true"; }
940 void writeASTVisitorTraversal(raw_ostream &OS) const override {
941 OS << " {\n";
942 OS << " " << getType() << " *I = A->" << getLowerName()
944 OS << " " << getType() << " *E = A->" << getLowerName()
946 OS << " for (; I != E; ++I) {\n";
947 OS << " if (!getDerived().TraverseStmt(*I))\n";
948 OS << " return false;\n";
949 OS << " }\n";
950 OS << " }\n";
953 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
954 OS << "tempInst" << getUpperName() << ", "
958 void writeTemplateInstantiation(raw_ostream &OS) const override {
959 OS << " auto *tempInst" << getUpperName()
962 OS << " {\n";
963 OS << " EnterExpressionEvaluationContext "
965 OS << " " << getType() << " *TI = tempInst" << getUpperName()
967 OS << " " << getType() << " *I = A->" << getLowerName()
969 OS << " " << getType() << " *E = A->" << getLowerName()
971 OS << " for (; I != E; ++I, ++TI) {\n";
972 OS << " ExprResult Result = S.SubstExpr(*I, TemplateArgs);\n";
973 OS << " *TI = Result.getAs<Expr>();\n";
974 OS << " }\n";
975 OS << " }\n";
978 void writeDump(raw_ostream &OS) const override {}
980 void writeDumpChildren(raw_ostream &OS) const override {
981 OS << " for (" << getAttrName() << "Attr::" << getLowerName()
984 OS << " dumpStmt(*I);\n";
987 void writeHasChildren(raw_ostream &OS) const override {
988 OS << "SA->" << getLowerName() << "_begin() != "
998 void writeValueImpl(raw_ostream &OS) const override {
999 OS << " OS << \"\\\"\" << Val << \"\\\"\";\n";
1009 void writeAccessors(raw_ostream &OS) const override {
1010 OS << " QualType get" << getUpperName() << "() const {\n";
1011 OS << " return " << getLowerName() << "->getType();\n";
1012 OS << " }";
1013 OS << " " << getType() << " get" << getUpperName() << "Loc() const {\n";
1014 OS << " return " << getLowerName() << ";\n";
1015 OS << " }";
1017 void writeTemplateInstantiationArgs(raw_ostream &OS) const override {
1018 OS << "A->get" << getUpperName() << "Loc()";
1020 void writePCHWrite(raw_ostream &OS) const override {
1021 OS << " " << WritePCHRecord(
1091 static void writeAvailabilityValue(raw_ostream &OS) {
1092 OS << "\" << getPlatform()->getName();\n"
1093 << " if (!getIntroduced().empty()) OS << \", introduced=\" << getIntroduced();\n"
1094 << " if (!getDeprecated().empty()) OS << \", deprecated=\" << getDeprecated();\n"
1095 << " if (!getObsoleted().empty()) OS << \", obsoleted=\" << getObsoleted();\n"
1096 << " if (getUnavailable()) OS << \", unavailable\";\n"
1097 << " OS << \"";
1100 static void writeGetSpellingFunction(Record &R, raw_ostream &OS) {
1103 OS << "const char *" << R.getName() << "Attr::getSpelling() const {\n";
1105 OS << " return \"(No spelling)\";\n}\n\n";
1109 OS << " switch (SpellingListIndex) {\n"
1115 OS << " case " << I << ":\n"
1118 OS << " }\n";
1120 OS << "}\n\n";
1126 raw_ostream &OS) {
1129 OS << "void " << R.getName() << "Attr::printPretty("
1130 << "raw_ostream &OS, const PrintingPolicy &Policy) const {\n";
1133 OS << "}\n\n";
1137 OS <<
1183 OS <<
1185 " OS << \"" << Prefix << Spelling;
1188 OS << " \";\n";
1189 OS << " printPrettyPragma(OS, Policy);\n";
1190 OS << " OS << \"\\n\";";
1191 OS << " break;\n";
1192 OS << " }\n";
1210 OS << "(";
1212 writeAvailabilityValue(OS);
1217 if (index++) OS << ", ";
1218 arg->writeValue(OS);
1223 OS << ")";
1224 OS << Suffix + "\";\n";
1226 OS <<
1232 OS << "}\n";
1234 OS << "}\n\n";
1258 static void writeAttrAccessorDefinition(const Record &R, raw_ostream &OS) {
1268 OS << " bool " << Name << "() const { return SpellingListIndex == ";
1270 OS << getSpellingListIndex(SpellingList, Spellings[Index]);
1272 OS << " ||\n SpellingListIndex == ";
1274 OS << "; }\n";
1343 raw_ostream &OS) {
1344 OS << " switch (" << VarName << ") {\n default: "
1347 OS << " case " << I.first << ": return " << I.second << ";\n";
1348 OS << " }\n";
1352 static void emitClangAttrLateParsedList(RecordKeeper &Records, raw_ostream &OS) {
1353 OS << "#if defined(CLANG_ATTR_LATE_PARSED_LIST)\n";
1366 OS << ".Case(\"" << I.name() << "\", " << LateParsed << ")\n";
1370 OS << "#endif // CLANG_ATTR_LATE_PARSED_LIST\n\n";
1374 static void emitClangAttrTypeArgList(RecordKeeper &Records, raw_ostream &OS) {
1375 OS << "#if defined(CLANG_ATTR_TYPE_ARG_LIST)\n";
1392 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n";
1395 OS << "#endif // CLANG_ATTR_TYPE_ARG_LIST\n\n";
1400 static void emitClangAttrArgContextList(RecordKeeper &Records, raw_ostream &OS) {
1401 OS << "#if defined(CLANG_ATTR_ARG_CONTEXT_LIST)\n";
1414 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n";
1417 OS << "#endif // CLANG_ATTR_ARG_CONTEXT_LIST\n\n";
1430 static void emitClangAttrIdentifierArgList(RecordKeeper &Records, raw_ostream &OS) {
1431 OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n";
1445 OS << ".Case(\"" << S.name() << "\", " << "true" << ")\n";
1448 OS << "#endif // CLANG_ATTR_IDENTIFIER_ARG_LIST\n\n";
1454 void EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) {
1455 emitSourceFileHeader("Attribute classes' definitions", OS);
1457 OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
1458 OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n";
1488 OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n";
1498 Args.back()->writeDeclarations(OS);
1499 OS << "\n\n";
1509 OS << "\npublic:\n";
1523 OS << CreateSemanticSpellings(Spellings, SemanticToSyntacticMap);
1527 OS << " static " << R.getName() << "Attr *CreateImplicit(";
1528 OS << "ASTContext &Ctx";
1530 OS << ", Spelling S";
1533 OS << ", ";
1534 ai->writeCtorParameters(OS);
1536 OS << ", SourceRange Loc = SourceRange()";
1537 OS << ") {\n";
1538 OS << " auto *A = new (Ctx) " << R.getName();
1539 OS << "Attr(Loc, Ctx, ";
1542 ai->writeImplicitCtorArgs(OS);
1543 OS << ", ";
1545 OS << (ElideSpelling ? "0" : "S") << ");\n";
1546 OS << " A->setImplicit(true);\n";
1547 OS << " return A;\n }\n\n";
1566 OS << " " << R.getName() << "Attr(SourceRange R, ASTContext &Ctx\n";
1569 OS << " , ";
1570 ai->writeCtorParameters(OS);
1571 OS << "\n";
1574 OS << " , ";
1575 OS << "unsigned SI\n";
1577 OS << " )\n";
1578 OS << " : " << SuperName << "(attr::" << R.getName() << ", R, SI, "
1583 OS << " , ";
1585 ai->writeCtorDefaultInitializers(OS);
1587 ai->writeCtorInitializers(OS);
1589 OS << "\n";
1592 OS << " {\n";
1596 ai->writeCtorBody(OS);
1597 OS << "\n";
1599 OS << " }\n\n";
1617 OS << " " << R.getName() << "Attr *clone(ASTContext &C) const;\n";
1618 OS << " void printPretty(raw_ostream &OS,\n"
1620 OS << " const char *getSpelling() const;\n";
1624 OS << " Spelling getSemanticSpelling() const {\n";
1626 OS);
1627 OS << " }\n";
1630 writeAttrAccessorDefinition(R, OS);
1633 ai->writeAccessors(OS);
1634 OS << "\n\n";
1640 static_cast<const EnumArgument *>(ai.get())->writeConversion(OS);
1643 ->writeConversion(OS);
1646 OS << R.getValueAsString("AdditionalMembers");
1647 OS << "\n\n";
1649 OS << " static bool classof(const Attr *A) { return A->getKind() == "
1652 OS << "};\n\n";
1655 OS << "#endif // LLVM_CLANG_ATTR_CLASSES_INC\n";
1659 void EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
1660 emitSourceFileHeader("Attribute classes' member function definitions", OS);
1676 ai->writeAccessorDefinitions(OS);
1678 OS << R.getName() << "Attr *" << R.getName()
1680 OS << " auto *A = new (C) " << R.getName() << "Attr(getLocation(), C";
1682 OS << ", ";
1683 ai->writeCloneArgs(OS);
1685 OS << ", getSpellingListIndex());\n";
1686 OS << " A->Inherited = Inherited;\n";
1687 OS << " A->IsPackExpansion = IsPackExpansion;\n";
1688 OS << " A->Implicit = Implicit;\n";
1689 OS << " return A;\n}\n\n";
1691 writePrettyPrintFunction(R, Args, OS);
1692 writeGetSpellingFunction(R, OS);
1698 OS << " switch (getKind()) {\n";
1704 OS << " case attr::" << R.getName() << ":\n";
1705 OS << " return cast<" << R.getName() << "Attr>(this)->" << Method
1708 OS << " case attr::NUM_ATTRS:\n";
1709 OS << " break;\n";
1710 OS << " }\n";
1711 OS << " llvm_unreachable(\"Unexpected attribute kind!\");\n";
1712 OS << "}\n\n";
1715 OS << "const char *Attr::getSpelling() const {\n";
1718 OS << "Attr *Attr::clone(ASTContext &C) const {\n";
1721 OS << "void Attr::printPretty(raw_ostream &OS, "
1723 EmitFunc("printPretty(OS, Policy)");
1728 static void EmitAttrList(raw_ostream &OS, StringRef Class,
1738 OS << Class << "(" << (*i)->getName() << ")\n";
1741 OS << "LAST_" << Class << "(" << (*i)->getName() << ")\n\n";
1756 void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
1757 emitSourceFileHeader("List of all attributes that Clang recognizes", OS);
1759 OS << "#ifndef LAST_ATTR\n";
1760 OS << "#define LAST_ATTR(NAME) ATTR(NAME)\n";
1761 OS << "#endif\n\n";
1763 OS << "#ifndef INHERITABLE_ATTR\n";
1764 OS << "#define INHERITABLE_ATTR(NAME) ATTR(NAME)\n";
1765 OS << "#endif\n\n";
1767 OS << "#ifndef LAST_INHERITABLE_ATTR\n";
1768 OS << "#define LAST_INHERITABLE_ATTR(NAME) INHERITABLE_ATTR(NAME)\n";
1769 OS << "#endif\n\n";
1771 OS << "#ifndef INHERITABLE_PARAM_ATTR\n";
1772 OS << "#define INHERITABLE_PARAM_ATTR(NAME) ATTR(NAME)\n";
1773 OS << "#endif\n\n";
1775 OS << "#ifndef LAST_INHERITABLE_PARAM_ATTR\n";
1776 OS << "#define LAST_INHERITABLE_PARAM_ATTR(NAME)"
1778 OS << "#endif\n\n";
1780 OS << "#ifndef PRAGMA_SPELLING_ATTR\n";
1781 OS << "#define PRAGMA_SPELLING_ATTR(NAME)\n";
1782 OS << "#endif\n\n";
1784 OS << "#ifndef LAST_PRAGMA_SPELLING_ATTR\n";
1785 OS << "#define LAST_PRAGMA_SPELLING_ATTR(NAME) PRAGMA_SPELLING_ATTR(NAME)\n";
1786 OS << "#endif\n\n";
1807 EmitAttrList(OS, "PRAGMA_SPELLING_ATTR", PragmaAttrs);
1808 EmitAttrList(OS, "INHERITABLE_PARAM_ATTR", InhParamAttrs);
1809 EmitAttrList(OS, "INHERITABLE_ATTR", InhAttrs);
1810 EmitAttrList(OS, "ATTR", NonInhAttrs);
1812 OS << "#undef LAST_ATTR\n";
1813 OS << "#undef INHERITABLE_ATTR\n";
1814 OS << "#undef LAST_INHERITABLE_ATTR\n";
1815 OS << "#undef LAST_INHERITABLE_PARAM_ATTR\n";
1816 OS << "#undef LAST_PRAGMA_ATTR\n";
1817 OS << "#undef PRAGMA_SPELLING_ATTR\n";
1818 OS << "#undef ATTR\n";
1822 void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
1823 emitSourceFileHeader("Attribute deserialization code", OS);
1830 OS << " switch (Kind) {\n";
1831 OS << " default:\n";
1832 OS << " llvm_unreachable(\"Unknown attribute!\");\n";
1838 OS << " case attr::" << R.getName() << ": {\n";
1840 OS << " bool isInherited = Record[Idx++];\n";
1841 OS << " bool isImplicit = Record[Idx++];\n";
1842 OS << " unsigned Spelling = Record[Idx++];\n";
1847 Args.back()->writePCHReadDecls(OS);
1849 OS << " New = new (Context) " << R.getName() << "Attr(Range, Context";
1851 OS << ", ";
1852 ri->writePCHReadArgs(OS);
1854 OS << ", Spelling);\n";
1856 OS << " cast<InheritableAttr>(New)->setInherited(isInherited);\n";
1857 OS << " New->setImplicit(isImplicit);\n";
1858 OS << " break;\n";
1859 OS << " }\n";
1861 OS << " }\n";
1865 void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) {
1866 emitSourceFileHeader("Attribute serialization code", OS);
1871 OS << " switch (A->getKind()) {\n";
1872 OS << " default:\n";
1873 OS << " llvm_unreachable(\"Unknown attribute kind!\");\n";
1874 OS << " break;\n";
1879 OS << " case attr::" << R.getName() << ": {\n";
1882 OS << " const auto *SA = cast<" << R.getName()
1885 OS << " Record.push_back(SA->isInherited());\n";
1886 OS << " Record.push_back(A->isImplicit());\n";
1887 OS << " Record.push_back(A->getSpellingListIndex());\n";
1890 createArgument(*Arg, R.getName())->writePCHWrite(OS);
1891 OS << " break;\n";
1892 OS << " }\n";
1894 OS << " }\n";
1925 // OS tests.
1957 const std::vector<Record *> &Attrs, raw_ostream &OS,
2001 OS << " .Case(\"" << S.name() << "\", " << TestStr << ")\n";
2003 OS << " .Default(0);\n";
2007 void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
2008 emitSourceFileHeader("Code to implement the __has_attribute logic", OS);
2033 OS << "const llvm::Triple &T = Target.getTriple();\n";
2034 OS << "switch (Syntax) {\n";
2035 OS << "case AttrSyntax::GNU:\n";
2036 OS << " return llvm::StringSwitch<int>(Name)\n";
2037 GenerateHasAttrSpellingStringSwitch(GNU, OS, "GNU");
2038 OS << "case AttrSyntax::Declspec:\n";
2039 OS << " return llvm::StringSwitch<int>(Name)\n";
2040 GenerateHasAttrSpellingStringSwitch(Declspec, OS, "Declspec");
2041 OS << "case AttrSyntax::Pragma:\n";
2042 OS << " return llvm::StringSwitch<int>(Name)\n";
2043 GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma");
2044 OS << "case AttrSyntax::CXX: {\n";
2048 OS << " else ";
2050 OS << "if (!Scope || Scope->getName() == \"\") {\n";
2052 OS << "if (Scope->getName() == \"" << I->first << "\") {\n";
2053 OS << " return llvm::StringSwitch<int>(Name)\n";
2054 GenerateHasAttrSpellingStringSwitch(I->second, OS, "CXX11", I->first);
2055 OS << "}";
2057 OS << "\n}\n";
2058 OS << "}\n";
2061 void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) {
2063 "into internal identifiers", OS);
2065 OS <<
2075 OS << " case AT_" << I.first << ": {\n";
2077 OS << " if (Name == \"" << Spellings[I].name() << "\" && "
2090 OS << " break;\n";
2091 OS << " }\n";
2094 OS << " }\n";
2095 OS << " return 0;\n";
2099 void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) {
2100 emitSourceFileHeader("Used by RecursiveASTVisitor to visit attributes.", OS);
2107 OS << "#ifdef ATTR_VISITOR_DECLS_ONLY\n\n";
2112 OS << " bool Traverse"
2114 OS << " bool Visit"
2119 OS << "\n#else // ATTR_VISITOR_DECLS_ONLY\n\n";
2127 OS << "template <typename Derived>\n"
2137 createArgument(*Arg, R.getName())->writeASTVisitorTraversal(OS);
2139 OS << " return true;\n";
2140 OS << "}\n\n";
2144 OS << "template <typename Derived>\n"
2158 OS << " case attr::" << R.getName() << ":\n"
2162 OS << " }\n"; // end case
2163 OS << "}\n"; // end function
2164 OS << "#endif // ATTR_VISITOR_DECLS_ONLY\n";
2168 void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
2169 emitSourceFileHeader("Template instantiation code for attributes", OS);
2173 OS << "namespace clang {\n"
2187 OS << " case attr::" << R.getName() << ": {\n";
2191 OS << " return nullptr;\n";
2192 OS << " }\n";
2196 OS << " const auto *A = cast<"
2201 OS << " return A->clone(C);\n";
2202 OS << " }\n";
2214 ai->writeTemplateInstantiation(OS);
2216 OS << " return new (C) " << R.getName() << "Attr(A->getLocation(), C";
2218 OS << ", ";
2219 ai->writeTemplateInstantiationArgs(OS);
2221 OS << ", A->getSpellingListIndex());\n }\n";
2223 OS << " } // end switch\n"
2232 void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
2233 emitSourceFileHeader("List of all attributes that Clang recognizes", OS);
2235 OS << "#ifndef PARSED_ATTR\n";
2236 OS << "#define PARSED_ATTR(NAME) NAME\n";
2237 OS << "#endif\n\n";
2241 OS << "PARSED_ATTR(" << I.first << ")\n";
2249 static void emitArgInfo(const Record &R, std::stringstream &OS) {
2264 OS << ArgCount << ", " << (HasVariadic ? 15 : OptCount);
2267 static void GenerateDefaultAppertainsTo(raw_ostream &OS) {
2268 OS << "static bool defaultAppertainsTo(Sema &, const AttributeList &,";
2269 OS << "const Decl *) {\n";
2270 OS << " return true;\n";
2271 OS << "}\n\n";
2398 raw_ostream &OS) {
2417 OS << "static bool " << FnName << "(const Decl *D) {\n";
2418 OS << " if (const auto *S = dyn_cast<";
2419 OS << GetSubjectWithSuffix(Base);
2420 OS << ">(D))\n";
2421 OS << " return " << Subject.getValueAsString("CheckCode") << ";\n";
2422 OS << " return false;\n";
2423 OS << "}\n\n";
2429 static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
2460 SS << "!" << GenerateCustomAppertainsTo(**I, OS) << "(D)";
2480 OS << SS.str();
2484 static void GenerateDefaultLangOptRequirements(raw_ostream &OS) {
2485 OS << "static bool defaultDiagnoseLangOpts(Sema &, ";
2486 OS << "const AttributeList &) {\n";
2487 OS << " return true;\n";
2488 OS << "}\n\n";
2492 raw_ostream &OS) {
2522 OS << "static bool " << FnName << "(Sema &S, const AttributeList &Attr) {\n";
2523 OS << " if (" << Test << ")\n";
2524 OS << " return true;\n\n";
2525 OS << " S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) ";
2526 OS << "<< Attr.getName();\n";
2527 OS << " return false;\n";
2528 OS << "}\n\n";
2534 static void GenerateDefaultTargetRequirements(raw_ostream &OS) {
2535 OS << "static bool defaultTargetRequirements(const TargetInfo &) {\n";
2536 OS << " return true;\n";
2537 OS << "}\n\n";
2542 raw_ostream &OS) {
2585 OS << "static bool " << FnName << "(const TargetInfo &Target) {\n";
2586 OS << " const llvm::Triple &T = Target.getTriple();\n";
2587 OS << " return " << Test << ";\n";
2588 OS << "}\n\n";
2594 static void GenerateDefaultSpellingIndexToSemanticSpelling(raw_ostream &OS) {
2595 OS << "static unsigned defaultSpellingIndexToSemanticSpelling("
2597 OS << " return UINT_MAX;\n";
2598 OS << "}\n\n";
2602 raw_ostream &OS) {
2619 OS << "static unsigned " << Name << "(const AttributeList &Attr) {\n";
2620 OS << Enum;
2621 OS << " unsigned Idx = Attr.getAttributeSpellingListIndex();\n";
2622 WriteSemanticSpellingSwitch("Idx", SemanticToSyntacticMap, OS);
2623 OS << "}\n\n";
2640 void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
2641 emitSourceFileHeader("Parsed attribute helpers", OS);
2650 GenerateDefaultAppertainsTo(OS);
2651 GenerateDefaultLangOptRequirements(OS);
2652 GenerateDefaultTargetRequirements(OS);
2653 GenerateDefaultSpellingIndexToSemanticSpelling(OS);
2675 SS << ", " << GenerateAppertainsTo(*I->second, OS);
2676 SS << ", " << GenerateLangOptRequirements(*I->second, OS);
2677 SS << ", " << GenerateTargetRequirements(*I->second, Dupes, OS);
2678 SS << ", " << GenerateSpellingIndexToSemanticSpelling(*I->second, OS);
2687 OS << "static const ParsedAttrInfo AttrInfoMap[AttributeList::UnknownAttribute + 1] = {\n";
2688 OS << SS.str();
2689 OS << "};\n\n";
2693 void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
2694 emitSourceFileHeader("Attribute name matcher", OS);
2756 OS << "static AttributeList::Kind getAttrKind(StringRef Name, ";
2757 OS << "AttributeList::Syntax Syntax) {\n";
2758 OS << " if (AttributeList::AS_GNU == Syntax) {\n";
2759 StringMatcher("Name", GNU, OS).Emit();
2760 OS << " } else if (AttributeList::AS_Declspec == Syntax) {\n";
2761 StringMatcher("Name", Declspec, OS).Emit();
2762 OS << " } else if (AttributeList::AS_CXX11 == Syntax) {\n";
2763 StringMatcher("Name", CXX11, OS).Emit();
2764 OS << " } else if (AttributeList::AS_Keyword == Syntax || ";
2765 OS << "AttributeList::AS_ContextSensitiveKeyword == Syntax) {\n";
2766 StringMatcher("Name", Keywords, OS).Emit();
2767 OS << " } else if (AttributeList::AS_Pragma == Syntax) {\n";
2768 StringMatcher("Name", Pragma, OS).Emit();
2769 OS << " }\n";
2770 OS << " return AttributeList::UnknownAttribute;\n"
2775 void EmitClangAttrDump(RecordKeeper &Records, raw_ostream &OS) {
2776 emitSourceFileHeader("Attribute dumper", OS);
2778 OS <<
2788 OS << " case attr::" << R.getName() << ": {\n";
2795 OS << " OS << \" \" << A->getSpelling();\n";
2799 OS << " const auto *SA = cast<" << R.getName()
2802 createArgument(*Arg, R.getName())->writeDump(OS);
2805 createArgument(*AI, R.getName())->writeDumpChildren(OS);
2807 OS <<
2811 OS << " }\n";
2815 raw_ostream &OS) {
2816 emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS);
2817 emitClangAttrArgContextList(Records, OS);
2818 emitClangAttrIdentifierArgList(Records, OS);
2819 emitClangAttrTypeArgList(Records, OS);
2820 emitClangAttrLateParsedList(Records, OS);
2833 raw_ostream &OS) {
2835 OS << Name << "\n" << std::string(Name.length(), '=') << "\n";
2840 OS << StringRef(ContentStr).trim();
2842 OS << "\n\n";
2854 raw_ostream &OS) {
2925 OS << Heading << "\n" << std::string(Heading.length(), '-') << "\n";
2933 OS << ".. csv-table:: Supported Syntaxes\n";
2934 OS << " :header: \"GNU\", \"C++11\", \"__declspec\", \"Keyword\",";
2935 OS << " \"Pragma\"\n\n";
2936 OS << " \"";
2937 if (SupportedSpellings & GNU) OS << "X";
2938 OS << "\",\"";
2939 if (SupportedSpellings & CXX11) OS << "X";
2940 OS << "\",\"";
2941 if (SupportedSpellings & Declspec) OS << "X";
2942 OS << "\",\"";
2943 if (SupportedSpellings & Keyword) OS << "X";
2944 OS << "\", \"";
2945 if (SupportedSpellings & Pragma) OS << "X";
2946 OS << "\"\n\n";
2951 OS << "This attribute has been deprecated, and may be removed in a future "
2956 OS << " This attribute has been superseded by ``"
2958 OS << "\n\n";
2963 OS << StringRef(ContentStr).trim();
2965 OS << "\n\n\n";
2968 void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) {
2977 OS << Documentation->getValueAsString("Intro") << "\n";
3007 WriteCategoryHeader(I.first, OS);
3012 WriteDocumentation(Doc, OS);