Author: jdevlieghere Date: Tue Jul 30 15:50:37 2019 New Revision: 367363 URL: http://llvm.org/viewvc/llvm-project?rev=367363&view=rev Log: [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. Modified: lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp lldb/trunk/utils/TableGen/LLDBPropertyDefEmitter.cpp lldb/trunk/utils/TableGen/LLDBTableGenBackends.h Modified: lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp?rev=367363&r1=367362&r2=367363&view=diff ============================================================================== --- lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp (original) +++ lldb/trunk/utils/TableGen/LLDBOptionDefEmitter.cpp Tue Jul 30 15:50:37 2019 @@ -20,14 +20,11 @@ #include <vector> 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<std::string, std::vector<Record *>> RecordsByCommand; +using namespace lldb_private; /// Groups all records by their command. -static RecordsByCommand getCommandList(std::vector<Record *> Options) { - RecordsByCommand result; +static RecordsByName getCommandList(std::vector<Record *> 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 Comm } void lldb_private::EmitOptionDefs(RecordKeeper &Records, raw_ostream &OS) { - - std::vector<Record *> Options = Records.getAllDerivedDefinitions("Option"); - emitSourceFileHeader("Options for LLDB command line commands.", OS); - RecordsByCommand ByCommand = getCommandList(Options); - - for (auto &CommandRecordPair : ByCommand) { + std::vector<Record *> Options = Records.getAllDerivedDefinitions("Option"); + for (auto &CommandRecordPair : getCommandList(Options)) { emitOptions(CommandRecordPair.first, CommandRecordPair.second, OS); } } Modified: lldb/trunk/utils/TableGen/LLDBPropertyDefEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/TableGen/LLDBPropertyDefEmitter.cpp?rev=367363&r1=367362&r2=367363&view=diff ============================================================================== --- lldb/trunk/utils/TableGen/LLDBPropertyDefEmitter.cpp (original) +++ lldb/trunk/utils/TableGen/LLDBPropertyDefEmitter.cpp Tue Jul 30 15:50:37 2019 @@ -19,14 +19,11 @@ #include <vector> 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<std::string, std::vector<Record *>> RecordsByDefinition; +using namespace lldb_private; /// Groups all properties by their definition. -static RecordsByDefinition getPropertyList(std::vector<Record *> Properties) { - RecordsByDefinition result; +static RecordsByName getPropertyList(std::vector<Record *> Properties) { + RecordsByName result; for (Record *Property : Properties) result[Property->getValueAsString("Definition").str()].push_back(Property); return result; Modified: lldb/trunk/utils/TableGen/LLDBTableGenBackends.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/TableGen/LLDBTableGenBackends.h?rev=367363&r1=367362&r2=367363&view=diff ============================================================================== --- lldb/trunk/utils/TableGen/LLDBTableGenBackends.h (original) +++ lldb/trunk/utils/TableGen/LLDBTableGenBackends.h Tue Jul 30 15:50:37 2019 @@ -16,11 +16,13 @@ #ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H #define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H +#include <map> #include <string> 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<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); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits