//=== ClangTypeNodesEmitter.cpp - Generate type node tables -----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This tblgen backend emits the node table (the .def file) for Clang // type nodes. // // This file defines the AST type info database. Each type node is // enumerated by providing its name (e.g., "Builtin" or "Enum") and // base class (e.g., "Type" or "TagType"). Depending on where in the // abstract syntax tree the type will show up, the enumeration uses // one of five different macros: // // TYPE(Class, Base) - A type that can show up anywhere in the AST, // and might be dependent, canonical, or non-canonical. All clients // will need to understand these types. // // ABSTRACT_TYPE(Class, Base) - An abstract class that shows up in // the type hierarchy but has no concrete instances. // // NON_CANONICAL_TYPE(Class, Base) - A type that can show up // anywhere in the AST but will never be a part of a canonical // type. Clients that only need to deal with canonical types // (ignoring, e.g., typedefs and other type aliases used for // pretty-printing) can ignore these types. // // DEPENDENT_TYPE(Class, Base) - A type that will only show up // within a C++ template that has not been instantiated, e.g., a // type that is always dependent. Clients that do not need to deal // with uninstantiated C++ templates can ignore these types. // // NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) - A type that // is non-canonical unless it is dependent. Defaults to TYPE because // it is neither reliably dependent nor reliably non-canonical. // // There is a sixth macro, independent of the others. Most clients // will not need to use it. // // LEAF_TYPE(Class) - A type that never has inner types. Clients // which can operate on such types more efficiently may wish to do so. // //===----------------------------------------------------------------------===// #include "ASTTableGen.h" #include "TableGenBackends.h" #include "llvm/ADT/StringRef.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" #include <set> #include <string> #include <vector> usingnamespacellvm; usingnamespaceclang; usingnamespaceclang::tblgen; // These are spellings in the generated output. #define TypeMacroName … #define AbstractTypeMacroName … #define DependentTypeMacroName … #define NonCanonicalTypeMacroName … #define NonCanonicalUnlessDependentTypeMacroName … #define TypeMacroArgs … #define LastTypeMacroName … #define LeafTypeMacroName … #define TypeClassName … namespace { class TypeNodeEmitter { … }; } void TypeNodeEmitter::emit() { … } void TypeNodeEmitter::emitFallbackDefine(StringRef macroName, StringRef fallbackMacroName, StringRef args) { … } void TypeNodeEmitter::emitNodeInvocations() { … } void TypeNodeEmitter::emitLastNodeInvocation(TypeNode type) { … } void TypeNodeEmitter::emitLeafNodeInvocations() { … } void TypeNodeEmitter::addMacroToUndef(StringRef macroName) { … } void TypeNodeEmitter::emitUndefs() { … } void clang::EmitClangTypeNodes(const RecordKeeper &records, raw_ostream &out) { … }