Lines Matching refs:OS

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