[llvm] 85dadf6 - [TableGen] Drop an unnecessary const from a return type (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 23 11:30:31 PDT 2022
Author: Kazu Hirata
Date: 2022-07-23T11:30:23-07:00
New Revision: 85dadf6d8d5adcca3539ad33442d28710f166e42
URL: https://github.com/llvm/llvm-project/commit/85dadf6d8d5adcca3539ad33442d28710f166e42
DIFF: https://github.com/llvm/llvm-project/commit/85dadf6d8d5adcca3539ad33442d28710f166e42.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/JSONBackend.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index bfcf44da04c0f..50df38e695d7b 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1615,7 +1615,7 @@ class Record {
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 e389039102752..6dc466e29df3e 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<std::string, json::Array> 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;
More information about the llvm-commits
mailing list