From 310f6b89b198a2e7138c401fd442c98d84e14bb2 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Tue, 30 Jul 2019 22:50:37 +0000 Subject: [PATCH] [TableGen] Reuse typedef across emitters (NFC) This moves the std::map typedef into the header so it can be reused by all the emitter implementations. llvm-svn: 367363 --- lldb/utils/TableGen/LLDBOptionDefEmitter.cpp | 17 +++++------------ lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp | 9 +++------ lldb/utils/TableGen/LLDBTableGenBackends.h | 6 ++++++ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp index d17b2af..01eacba 100644 --- a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp +++ b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp @@ -20,14 +20,11 @@ #include using namespace llvm; - -/// Map of command names to their associated records. Also makes sure our -/// commands are sorted in a deterministic way. -typedef std::map> RecordsByCommand; +using namespace lldb_private; /// Groups all records by their command. -static RecordsByCommand getCommandList(std::vector Options) { - RecordsByCommand result; +static RecordsByName getCommandList(std::vector Options) { + RecordsByName result; for (Record *Option : Options) result[Option->getValueAsString("Command").str()].push_back(Option); return result; @@ -187,14 +184,10 @@ static void emitOptions(std::string Command, std::vector Records, } void lldb_private::EmitOptionDefs(RecordKeeper &Records, raw_ostream &OS) { - - std::vector Options = Records.getAllDerivedDefinitions("Option"); - emitSourceFileHeader("Options for LLDB command line commands.", OS); - RecordsByCommand ByCommand = getCommandList(Options); - - for (auto &CommandRecordPair : ByCommand) { + std::vector Options = Records.getAllDerivedDefinitions("Option"); + for (auto &CommandRecordPair : getCommandList(Options)) { emitOptions(CommandRecordPair.first, CommandRecordPair.second, OS); } } diff --git a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp index f707b8e..9e46218 100644 --- a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp +++ b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp @@ -19,14 +19,11 @@ #include using namespace llvm; - -/// Map of properties definitions to their associated records. Also makes sure -/// our property definitions are sorted in a deterministic way. -typedef std::map> RecordsByDefinition; +using namespace lldb_private; /// Groups all properties by their definition. -static RecordsByDefinition getPropertyList(std::vector Properties) { - RecordsByDefinition result; +static RecordsByName getPropertyList(std::vector Properties) { + RecordsByName result; for (Record *Property : Properties) result[Property->getValueAsString("Definition").str()].push_back(Property); return result; diff --git a/lldb/utils/TableGen/LLDBTableGenBackends.h b/lldb/utils/TableGen/LLDBTableGenBackends.h index e5c3548..4170553 100644 --- a/lldb/utils/TableGen/LLDBTableGenBackends.h +++ b/lldb/utils/TableGen/LLDBTableGenBackends.h @@ -16,11 +16,13 @@ #ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H #define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H +#include #include namespace llvm { class raw_ostream; class RecordKeeper; +class Record; } // namespace llvm using llvm::raw_ostream; @@ -28,6 +30,10 @@ using llvm::RecordKeeper; 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> RecordsByName; + void EmitOptionDefs(RecordKeeper &RK, raw_ostream &OS); void EmitPropertyDefs(RecordKeeper &RK, raw_ostream &OS); void EmitPropertyEnumDefs(RecordKeeper &RK, raw_ostream &OS); -- 2.7.4