1 //===- ClangAttrEmitter.cpp - Generate Clang attribute handling =-*- C++ -*--=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // These tablegen backends emit Clang attribute processing code
12 //===----------------------------------------------------------------------===//
14 #include "ClangAttrEmitter.h"
20 void ClangAttrClassEmitter::run(raw_ostream
&OS
) {
21 OS
<< "// This file is generated by TableGen. Do not edit.\n\n";
22 OS
<< "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
23 OS
<< "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n";
25 std::vector
<Record
*> Attrs
= Records
.getAllDerivedDefinitions("Attr");
27 for (std::vector
<Record
*>::iterator i
= Attrs
.begin(), e
= Attrs
.end();
31 if (R
.getValueAsBit("DoNotEmit"))
34 OS
<< "class " << R
.getName() << "Attr : public Attr {\n";
36 std::vector
<Record
*> Args
= R
.getValueAsListOfDefs("Args");
38 // FIXME: Handle arguments
39 assert(Args
.empty() && "Can't yet handle arguments");
42 OS
<< " " << R
.getName() << "Attr(";
47 OS
<< " : Attr(attr::" << R
.getName() << ")";
53 OS
<< " virtual Attr *clone (ASTContext &C) const;\n";
54 OS
<< " static bool classof(const Attr *A) { return A->getKind() == "
55 << "attr::" << R
.getName() << "; }\n";
56 OS
<< " static bool classof(const " << R
.getName()
57 << "Attr *) { return true; }\n";
64 void ClangAttrListEmitter::run(raw_ostream
&OS
) {
65 OS
<< "// This file is generated by TableGen. Do not edit.\n\n";
67 OS
<< "#ifndef LAST_ATTR\n";
68 OS
<< "#define LAST_ATTR(NAME) ATTR(NAME)\n";
71 std::vector
<Record
*> Attrs
= Records
.getAllDerivedDefinitions("Attr");
72 std::vector
<Record
*>::iterator i
= Attrs
.begin(), e
= Attrs
.end();
75 // Move the end iterator back to emit the last attribute.
77 OS
<< "ATTR(" << (*i
)->getName() << ")\n";
79 OS
<< "LAST_ATTR(" << (*i
)->getName() << ")\n\n";
82 OS
<< "#undef LAST_ATTR\n";
83 OS
<< "#undef ATTR\n";