LLDBOptionDefEmitter.cpp
LLDBPropertyDefEmitter.cpp
LLDBTableGen.cpp
+ LLDBTableGenUtils.cpp
)
set_target_properties(lldb-tblgen PROPERTIES FOLDER "LLDB tablegenning")
endif()
//===----------------------------------------------------------------------===//
#include "LLDBTableGenBackends.h"
+#include "LLDBTableGenUtils.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/StringMatcher.h"
#include "llvm/TableGen/TableGenBackend.h"
-#include <map>
#include <vector>
using namespace llvm;
using namespace lldb_private;
-/// Groups all records by their command.
-static RecordsByName getCommandList(std::vector<Record *> Options) {
- RecordsByName result;
- for (Record *Option : Options)
- result[Option->getValueAsString("Command").str()].push_back(Option);
- return result;
-}
-
namespace {
struct CommandOption {
std::vector<std::string> GroupsArg;
emitSourceFileHeader("Options for LLDB command line commands.", OS);
std::vector<Record *> Options = Records.getAllDerivedDefinitions("Option");
- for (auto &CommandRecordPair : getCommandList(Options)) {
+ for (auto &CommandRecordPair : getRecordsByName(Options, "Command")) {
emitOptions(CommandRecordPair.first, CommandRecordPair.second, OS);
}
}
//===----------------------------------------------------------------------===//
#include "LLDBTableGenBackends.h"
+#include "LLDBTableGenUtils.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/StringMatcher.h"
#include "llvm/TableGen/TableGenBackend.h"
-#include <map>
#include <vector>
using namespace llvm;
using namespace lldb_private;
-/// Groups all properties by their definition.
-static RecordsByName getPropertyList(std::vector<Record *> Properties) {
- RecordsByName result;
- for (Record *Property : Properties)
- result[Property->getValueAsString("Definition").str()].push_back(Property);
- return result;
-}
-
static void emitPropertyEnum(Record *Property, raw_ostream &OS) {
OS << "eProperty";
OS << Property->getName();
std::vector<Record *> Properties =
Records.getAllDerivedDefinitions("Property");
- for (auto &PropertyRecordPair : getPropertyList(Properties)) {
+ for (auto &PropertyRecordPair : getRecordsByName(Properties, "Definition")) {
emityProperties(PropertyRecordPair.first, PropertyRecordPair.second, OS);
}
}
std::vector<Record *> Properties =
Records.getAllDerivedDefinitions("Property");
- for (auto &PropertyRecordPair : getPropertyList(Properties)) {
+ for (auto &PropertyRecordPair : getRecordsByName(Properties, "Definition")) {
emitPropertyEnum(PropertyRecordPair.first, PropertyRecordPair.second, OS);
}
}
#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
-#include <map>
-#include <string>
-#include <vector>
+#include "llvm/ADT/StringRef.h"
namespace llvm {
class raw_ostream;
namespace lldb_private {
-/// Map of names to their associated records. This map also ensures that our
-/// records are sorted in a deterministic way.
-typedef std::map<std::string, std::vector<llvm::Record *>> RecordsByName;
-
void EmitOptionDefs(RecordKeeper &RK, raw_ostream &OS);
void EmitPropertyDefs(RecordKeeper &RK, raw_ostream &OS);
void EmitPropertyEnumDefs(RecordKeeper &RK, raw_ostream &OS);
--- /dev/null
+//===- LLDBTableGenUtils.cpp ----------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "LLDBTableGenUtils.h"
+#include "llvm/TableGen/Record.h"
+
+using namespace llvm;
+using namespace lldb_private;
+
+RecordsByName lldb_private::getRecordsByName(std::vector<Record *> Records,
+ StringRef Name) {
+ RecordsByName Result;
+ for (Record *R : Records)
+ Result[R->getValueAsString(Name).str()].push_back(R);
+ return Result;
+}
--- /dev/null
+//===- LLDBTableGenUtils.h --------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENUTILS_H
+#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENUTILS_H
+
+#include "llvm/ADT/StringRef.h"
+#include <map>
+#include <string>
+#include <vector>
+
+namespace llvm {
+class RecordKeeper;
+class Record;
+} // namespace llvm
+
+namespace lldb_private {
+
+/// Map of names to their associated records. This map also ensures that our
+/// records are sorted in a deterministic way.
+typedef std::map<std::string, std::vector<llvm::Record *>> RecordsByName;
+
+/// Return records grouped by name.
+RecordsByName getRecordsByName(std::vector<llvm::Record *> Records,
+ llvm::StringRef);
+
+} // namespace lldb_private
+
+#endif