[memprof] Upgrade a unit test to MemProf Version 3 (#117063)
[llvm-project.git] / clang / utils / TableGen / ClangDataCollectorsEmitter.cpp
blob50e90691c555bf95def0b5062834ec2af82db6d8
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This tablegen backend emit Clang data collector tables.
11 //===----------------------------------------------------------------------===//
13 #include "TableGenBackends.h"
14 #include "llvm/TableGen/Record.h"
15 #include "llvm/TableGen/TableGenBackend.h"
17 using namespace llvm;
19 void 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";
28 OS << "#undef DEF_ADD_DATA\n";