30 lines · cpp
1//===-- ClangDataCollectorsEmitter.cpp - Generate Clang data collector ----===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This tablegen backend emit Clang data collector tables.10//11//===----------------------------------------------------------------------===//12 13#include "TableGenBackends.h"14#include "llvm/TableGen/Record.h"15#include "llvm/TableGen/TableGenBackend.h"16 17using namespace llvm;18 19void clang::EmitClangDataCollectors(const RecordKeeper &RK, raw_ostream &OS) {20 const auto &Defs = RK.getClasses();21 for (const auto &Entry : Defs) {22 Record &R = *Entry.second;23 OS << "DEF_ADD_DATA(" << R.getName() << ", {\n";24 auto Code = R.getValue("Code")->getValue();25 OS << Code->getAsUnquotedString() << "}\n)";26 OS << "\n";27 }28 OS << "#undef DEF_ADD_DATA\n";29}30