From 85dadf6d8d5adcca3539ad33442d28710f166e42 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 23 Jul 2022 11:30:23 -0700 Subject: [PATCH] [TableGen] Drop an unnecessary const from a return type (NFC) This patch also drops "&" that binds to a temporary. Identified with readability-const-return-type. --- llvm/include/llvm/TableGen/Record.h | 2 +- llvm/lib/TableGen/JSONBackend.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index bfcf44d..50df38e 100644 --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/include/llvm/TableGen/Record.h @@ -1615,7 +1615,7 @@ public: return Name; } - const std::string getNameInitAsString() const { + std::string getNameInitAsString() const { return getNameInit()->getAsUnquotedString(); } diff --git a/llvm/lib/TableGen/JSONBackend.cpp b/llvm/lib/TableGen/JSONBackend.cpp index e389039..6dc466e 100644 --- a/llvm/lib/TableGen/JSONBackend.cpp +++ b/llvm/lib/TableGen/JSONBackend.cpp @@ -129,13 +129,13 @@ void JSONEmitter::run(raw_ostream &OS) { // construct the array for each one. std::map instance_lists; for (const auto &C : Records.getClasses()) { - auto &Name = C.second->getNameInitAsString(); + const auto Name = C.second->getNameInitAsString(); (void)instance_lists[Name]; } // Main iteration over the defs. for (const auto &D : Records.getDefs()) { - auto &Name = D.second->getNameInitAsString(); + const auto Name = D.second->getNameInitAsString(); auto &Def = *D.second; json::Object obj; -- 2.7.4