From 705e4a59558f66aef1a6e1d2bb846b888c02bc30 Mon Sep 17 00:00:00 2001 From: Ivan Krysak Date: Wed, 12 Feb 2025 15:52:59 +0200 Subject: [PATCH] `auto [...]` -> `auto &&[...]` --- include/revng/ADT/GenericGraph.h | 4 +- .../revng/EarlyFunctionAnalysis/CFGHelpers.h | 10 ++--- include/revng/GraphLayout/Graphs.h | 6 +-- .../revng/GraphLayout/SugiyamaStyle/Compute.h | 2 +- .../GraphLayout/SugiyamaStyle/InternalGraph.h | 6 +-- include/revng/Model/Binary.h | 2 +- include/revng/Model/CABIFunctionDefinition.h | 2 +- include/revng/Model/Importer/TypeCopier.h | 8 ++-- include/revng/Model/Pass/RegisterModelPass.h | 2 +- include/revng/Model/PrimitiveType.h | 2 +- include/revng/Model/RawBinaryView.h | 4 +- include/revng/Model/RawFunctionDefinition.h | 4 +- include/revng/Model/StructDefinition.h | 2 +- include/revng/PTML/CommentPlacementHelper.h | 4 +- include/revng/Pipeline/Loader.h | 25 ++++++------ include/revng/Pipeline/Target.h | 6 +-- include/revng/Pipes/StringMap.h | 8 ++-- .../revng/RestructureCFG/RegionCFGTreeImpl.h | 2 +- include/revng/Support/YAMLTraits.h | 2 +- include/revng/TupleTree/TupleTreeDiff.h | 2 +- include/revng/TupleTree/TupleTreePath.h | 2 +- include/revng/TupleTree/Visits.h | 10 ++--- include/revng/tests/unit/ModelType.inc | 30 +++++++------- lib/ABI/DefaultFunctionPrototype.cpp | 2 +- lib/ABI/Definition.cpp | 2 +- lib/ABI/FunctionType/Conversion.cpp | 4 +- lib/ABI/FunctionType/Layout.cpp | 8 ++-- lib/ABI/FunctionType/ValueDistributor.cpp | 16 ++++---- lib/ABI/RegisterStateDeductions.cpp | 2 +- lib/Canonicalize/HoistStructPhis.cpp | 4 +- lib/Canonicalize/ImplicitModelCastPass.cpp | 2 +- lib/Canonicalize/MakeModelGEPPass.cpp | 4 +- .../OperatorPrecedenceResolutionPass.cpp | 16 ++++---- lib/Canonicalize/RemoveLoadStore.cpp | 4 +- .../Backend/DLAMakeModelTypes.cpp | 21 +++++----- .../Backend/DLAUpdateModelTypes.cpp | 2 +- .../DLACreateInterProceduralTypes.cpp | 4 +- .../DLACreateIntraProceduralTypes.cpp | 7 ++-- .../Middleend/DecomposeStridedEdges.cpp | 2 +- .../Middleend/DeduplicateFields.cpp | 12 +++--- lib/EarlyFunctionAnalysis/CFGAnalyzer.cpp | 12 +++--- .../ControlFlowGraph.cpp | 4 +- lib/EarlyFunctionAnalysis/DetectABI.cpp | 12 +++--- .../FunctionSummaryOracle.cpp | 6 +-- lib/EarlyFunctionAnalysis/Outliner.cpp | 40 +++++++++---------- lib/FunctionIsolation/EnforceABI.cpp | 15 +++---- .../InvokeIsolatedFunctions.cpp | 4 +- lib/FunctionIsolation/IsolateFunctions.cpp | 2 +- lib/FunctionIsolation/PromoteCSVs.cpp | 4 +- lib/GraphLayout/SugiyamaStyle/Compute.cpp | 6 +-- lib/GraphLayout/SugiyamaStyle/EdgeRouting.cpp | 12 +++--- .../SugiyamaStyle/GraphPreparation.cpp | 8 ++-- .../SugiyamaStyle/HorizontalPositions.cpp | 4 +- .../SugiyamaStyle/InternalCompute.h | 2 +- .../SugiyamaStyle/LaneDistribution.cpp | 18 ++++----- .../SugiyamaStyle/PermutationSelection.cpp | 4 +- lib/ImportFromC/HeaderToModel.cpp | 10 ++--- lib/ImportFromC/ImportFromCAnalysis.cpp | 4 +- lib/InitModelTypes/InitModelTypes.cpp | 2 +- lib/Lift/CodeGenerator.cpp | 4 +- lib/Lift/InstructionTranslator.cpp | 2 +- lib/Lift/JumpTargetManager.cpp | 4 +- lib/Lift/RootAnalyzer.cpp | 2 +- lib/Lift/VariableManager.h | 2 +- lib/Model/Binary.cpp | 2 +- lib/Model/Importer/Binary/ELFImporter.cpp | 4 +- lib/Model/Importer/Binary/MachOImporter.cpp | 2 +- lib/Model/Importer/Binary/PECOFFImporter.cpp | 6 +-- .../Importer/Binary/SegmentImportHelpers.h | 6 +-- .../Importer/DebugInfo/DwarfImporter.cpp | 6 +-- lib/Model/Importer/DebugInfo/PDBImporter.cpp | 24 +++++------ lib/Model/NameBuilder.cpp | 2 +- lib/Model/Pass/DeduplicateEquivalentTypes.cpp | 4 +- lib/Model/Pass/PromoteOriginalName.cpp | 2 +- lib/Model/TypeSystemPrinter.cpp | 8 ++-- lib/PTML/Doxygen.cpp | 4 +- lib/Pipeline/Runner.cpp | 7 ++-- .../DetectStackSizePass.cpp | 2 +- .../SegregateStackAccessesPass.cpp | 16 ++++---- lib/RestructureCFG/BeautifyGHAST.cpp | 4 +- lib/RestructureCFG/RestructureCFG.cpp | 2 +- lib/Support/IRHelpers.cpp | 2 +- lib/Support/ModuleStatistics.cpp | 2 +- lib/TypeNames/DependencyGraph.cpp | 2 +- lib/TypeNames/TypePrinters.cpp | 6 +-- lib/Yield/Assembly/DisassemblyHelper.cpp | 14 +++---- .../Assembly/LLVMDisassemblerInterface.cpp | 2 +- lib/Yield/Assembly/LLVMTagsToPTML.cpp | 26 ++++++------ lib/Yield/CallGraphs/CallGraphSlices.cpp | 2 +- lib/Yield/ControlFlow/Extraction.cpp | 6 +-- .../ControlFlow/FallthroughDetection.cpp | 4 +- lib/Yield/CrossRelations.cpp | 4 +- lib/Yield/PTML.cpp | 25 ++++++------ lib/Yield/SVG.cpp | 18 ++++----- lib/Yield/Verify.cpp | 8 ++-- lib/mlir/Dialect/Clift/IR/CliftOps.cpp | 4 +- lib/mlir/Dialect/Clift/IR/CliftTypes.cpp | 4 +- .../ABIRuntimeTestResultParser.cpp | 2 +- .../check-compatibility-with-abi/Verify.cpp | 2 +- .../abi/tools/ensure-rft-equivalence/Main.cpp | 10 ++--- tests/unit/ADT.cpp | 4 +- tests/unit/AdvancedValueInfo.cpp | 4 +- tests/unit/Alignment.cpp | 34 +++++++++------- tests/unit/DepthFirstVisit.h | 2 +- tests/unit/GenericGraph.cpp | 6 +-- tests/unit/KeyedObjectsContainers.cpp | 8 ++-- tests/unit/Location.cpp | 2 +- tests/unit/Model.cpp | 10 ++--- tests/unit/PointerArrayEmission.cpp | 4 +- tests/unit/TypeBucket.cpp | 16 ++++---- tools/pipeline/Main.cpp | 6 +-- tools/pipeline/invalidate/Main.cpp | 2 +- tools/trace/inspect/Main.cpp | 4 +- 113 files changed, 396 insertions(+), 390 deletions(-) diff --git a/include/revng/ADT/GenericGraph.h b/include/revng/ADT/GenericGraph.h index 71f78e668..2082b3d6e 100644 --- a/include/revng/ADT/GenericGraph.h +++ b/include/revng/ADT/GenericGraph.h @@ -695,13 +695,13 @@ public: public: EdgeView addSuccessor(MutableEdgeNode *NewSuccessor, EdgeLabel EL = {}) { - auto [Owner, View] = constructEdge(this, NewSuccessor, std::move(EL)); + auto &&[Owner, View] = constructEdge(this, NewSuccessor, std::move(EL)); auto &Output = Successors.emplace_back(std::move(Owner)); NewSuccessor->Predecessors.emplace_back(std::move(View)); return EdgeView(Output); } EdgeView addPredecessor(MutableEdgeNode *NewPredecessor, EdgeLabel EL = {}) { - auto [Owner, View] = constructEdge(NewPredecessor, this, std::move(EL)); + auto &&[Owner, View] = constructEdge(NewPredecessor, this, std::move(EL)); auto &Output = NewPredecessor->Successors.emplace_back(std::move(Owner)); Predecessors.emplace_back(std::move(View)); return EdgeView(Output); diff --git a/include/revng/EarlyFunctionAnalysis/CFGHelpers.h b/include/revng/EarlyFunctionAnalysis/CFGHelpers.h index aaa9bfad2..9f5c75ca2 100644 --- a/include/revng/EarlyFunctionAnalysis/CFGHelpers.h +++ b/include/revng/EarlyFunctionAnalysis/CFGHelpers.h @@ -112,7 +112,7 @@ buildControlFlowGraph(const Container &BB, for (const BasicBlockType &Block : BB) { revng_assert(Block.ID().isValid()); auto *NewNode = Graph.addNode(Node{ Block, EntryAddress }); - auto [_, Success] = NodeLookup.try_emplace(Block.ID(), NewNode); + auto &&[_, Success] = NodeLookup.try_emplace(Block.ID(), NewNode); revng_assert(Success != false, "Different basic blocks with the same `Start` address"); } @@ -123,8 +123,8 @@ buildControlFlowGraph(const Container &BB, revng_assert(FromNodeIterator != NodeLookup.end()); for (const auto &Edge : Block.Successors()) { - auto [NextInstruction, - _] = parseSuccessor(*Edge, Block.nextBlock(), Binary); + auto &&[NextInstruction, + _] = parseSuccessor(*Edge, Block.nextBlock(), Binary); if (NextInstruction.isValid()) { auto ToNodeIterator = NodeLookup.find(NextInstruction); revng_assert(ToNodeIterator != NodeLookup.end()); @@ -134,8 +134,8 @@ buildControlFlowGraph(const Container &BB, constexpr auto Invalid = BasicBlockID::invalid(); ExitNode = Graph.addNode(Node{ BasicBlockType{ Invalid }, EntryAddress }); - auto [_, Success] = NodeLookup.try_emplace(BasicBlockID::invalid(), - ExitNode); + auto &&[_, Success] = NodeLookup.try_emplace(BasicBlockID::invalid(), + ExitNode); revng_assert(Success != false); } FromNodeIterator->second->addSuccessor(ExitNode); diff --git a/include/revng/GraphLayout/Graphs.h b/include/revng/GraphLayout/Graphs.h index b61ba9812..03472efa4 100644 --- a/include/revng/GraphLayout/Graphs.h +++ b/include/revng/GraphLayout/Graphs.h @@ -122,13 +122,13 @@ convert(const InputGraph &Input) { OutputNode Output(*Node); Output.Size = Node->Size; - auto [It, Success] = Lookup.emplace(Node, - Result.addNode(std::move(Output))); + auto &&[It, Success] = Lookup.emplace(Node, + Result.addNode(std::move(Output))); revng_assert(Success); } for (const InputNode *From : Input.nodes()) - for (auto [To, EdgeLabel] : From->successor_edges()) + for (auto &&[To, EdgeLabel] : From->successor_edges()) Lookup.at(From)->addSuccessor(Lookup.at(To), EdgeDataType(std::move(*EdgeLabel))); diff --git a/include/revng/GraphLayout/SugiyamaStyle/Compute.h b/include/revng/GraphLayout/SugiyamaStyle/Compute.h index b5dd265bc..36a8ff386 100644 --- a/include/revng/GraphLayout/SugiyamaStyle/Compute.h +++ b/include/revng/GraphLayout/SugiyamaStyle/Compute.h @@ -87,7 +87,7 @@ template inline bool computeInPlace(GraphType &&Graph, const Configuration &Configuration) { using IG = InternalGraph; - auto [Internal, InputNodeLookup] = IG::make(std::forward(Graph)); + auto &&[Internal, InputNodeLookup] = IG::make(std::forward(Graph)); if (!detail::computeImpl(Internal, Configuration)) return false; diff --git a/include/revng/GraphLayout/SugiyamaStyle/InternalGraph.h b/include/revng/GraphLayout/SugiyamaStyle/InternalGraph.h index d1c9f5776..0ab6caeeb 100644 --- a/include/revng/GraphLayout/SugiyamaStyle/InternalGraph.h +++ b/include/revng/GraphLayout/SugiyamaStyle/InternalGraph.h @@ -161,8 +161,8 @@ public: for (NodeRef Node : llvm::nodes(Graph)) { layout::Size Size = LayoutTrait::getNodeSize(Node); - auto [It, Success] = InternalLookup.try_emplace(Node, - Result.makeNode(Size)); + auto &&[It, Success] = InternalLookup.try_emplace(Node, + Result.makeNode(Size)); revng_assert(Success); revng_assert(It->second->Index == Lookup.Nodes.size()); Lookup.Nodes.emplace_back(Node); @@ -203,7 +203,7 @@ public: std::move(Node->Center)); for (InternalNode *From : nodes()) { - for (auto [To, Label] : From->successor_edges()) { + for (auto &&[To, Label] : From->successor_edges()) { revng_assert(Label->IsRouted == true); if (!Label->isVirtual()) diff --git a/include/revng/Model/Binary.h b/include/revng/Model/Binary.h index 8a04f9332..1787d984b 100644 --- a/include/revng/Model/Binary.h +++ b/include/revng/Model/Binary.h @@ -151,7 +151,7 @@ public: makeTypeDefinition(ArgumentTypes &&...Arguments) { using UTD = model::UpcastableTypeDefinition; UTD New = UTD::make(std::forward(Arguments)...); - auto [Reference, Result] = recordNewType(std::move(New)); + auto &&[Reference, Result] = recordNewType(std::move(New)); return { llvm::cast(Reference), std::move(Result) }; } diff --git a/include/revng/Model/CABIFunctionDefinition.h b/include/revng/Model/CABIFunctionDefinition.h index 4fcc90175..0092d070f 100644 --- a/include/revng/Model/CABIFunctionDefinition.h +++ b/include/revng/Model/CABIFunctionDefinition.h @@ -52,7 +52,7 @@ public: using generated::CABIFunctionDefinition::CABIFunctionDefinition; Argument &addArgument(UpcastableType &&Type) { - auto [Iterator, Success] = Arguments().emplace(Arguments().size()); + auto &&[Iterator, Success] = Arguments().emplace(Arguments().size()); revng_assert(Success); Iterator->Type() = std::move(Type); return *Iterator; diff --git a/include/revng/Model/Importer/TypeCopier.h b/include/revng/Model/Importer/TypeCopier.h index 07d12652d..1a0fa1f0d 100644 --- a/include/revng/Model/Importer/TypeCopier.h +++ b/include/revng/Model/Importer/TypeCopier.h @@ -72,9 +72,9 @@ public: visitTupleTree(NewType, Visitor, [](const auto &) {}); // Record the type - auto [Def, Type] = DestinationModel->recordNewType(std::move(NewType)); - NewTypes.insert(&Def); - auto [_, Success] = AlreadyCopied.insert({ P->ID(), Def.ID() }); + auto &&[D, Type] = DestinationModel->recordNewType(std::move(NewType)); + NewTypes.insert(&D); + auto &&[_, Success] = AlreadyCopied.insert({ P->ID(), D.ID() }); revng_assert(Success); // Record the type we were looking for originally @@ -104,7 +104,7 @@ public: // Extract ID from the key const TupleTreeKeyWrapper &TypeKey = Path.path().toArrayRef()[1]; - auto [ID, Kind] = *TypeKey.tryGet(); + auto &&[ID, Kind] = *TypeKey.tryGet(); revng_assert(AlreadyCopied.count(ID) == 1); model::TypeDefinition::Key Key = { AlreadyCopied[ID], Kind }; Path = DestinationModel->getDefinitionReference(Key); diff --git a/include/revng/Model/Pass/RegisterModelPass.h b/include/revng/Model/Pass/RegisterModelPass.h index 82a50e442..4b122281f 100644 --- a/include/revng/Model/Pass/RegisterModelPass.h +++ b/include/revng/Model/Pass/RegisterModelPass.h @@ -45,7 +45,7 @@ public: const llvm::Twine &Description, ModelPass Pass) { Registered RegisteredPass{ Name.str(), Description.str(), Pass }; - auto [_, Success] = Registry->emplace(std::move(RegisteredPass)); + auto &&[_, Success] = Registry->emplace(std::move(RegisteredPass)); revng_assert(Success); } diff --git a/include/revng/Model/PrimitiveType.h b/include/revng/Model/PrimitiveType.h index 6e8201189..dc9888bf8 100644 --- a/include/revng/Model/PrimitiveType.h +++ b/include/revng/Model/PrimitiveType.h @@ -141,7 +141,7 @@ public: static UpcastableType fromCName(llvm::StringRef Name) { // Figure the primitive kind out. - auto [Kind, RemainingName] = PrimitiveKind::tryConsumeCPrefix(Name); + auto &&[Kind, RemainingName] = PrimitiveKind::tryConsumeCPrefix(Name); if (Kind == PrimitiveKind::Invalid || RemainingName == Name) return UpcastableType::empty(); diff --git a/include/revng/Model/RawBinaryView.h b/include/revng/Model/RawBinaryView.h index 01847ec6d..055f78fc0 100644 --- a/include/revng/Model/RawBinaryView.h +++ b/include/revng/Model/RawBinaryView.h @@ -97,7 +97,7 @@ public: std::optional> getFromAddressOn(MetaAddress Address) const { - auto [Segment, OffsetInSegment] = findOffsetInSegment(Address, 0); + auto &&[Segment, OffsetInSegment] = findOffsetInSegment(Address, 0); if (Segment == nullptr) return std::nullopt; @@ -114,7 +114,7 @@ public: /// translation. std::optional addressToOffset(MetaAddress Address, uint64_t Size = 0) const { - auto [Segment, OffsetInSegment] = findOffsetInSegment(Address, Size); + auto &&[Segment, OffsetInSegment] = findOffsetInSegment(Address, Size); if (Segment == nullptr) { return std::nullopt; } else { diff --git a/include/revng/Model/RawFunctionDefinition.h b/include/revng/Model/RawFunctionDefinition.h index 225c1aec9..ef763c645 100644 --- a/include/revng/Model/RawFunctionDefinition.h +++ b/include/revng/Model/RawFunctionDefinition.h @@ -86,14 +86,14 @@ public: NamedTypedRegister &addArgument(model::Register::Values Location, model::UpcastableType &&Type) { - auto [Iterator, Success] = Arguments().emplace(Location); + auto &&[Iterator, Success] = Arguments().emplace(Location); revng_assert(Success); Iterator->Type() = std::move(Type); return *Iterator; } NamedTypedRegister &addReturnValue(model::Register::Values Location, model::UpcastableType &&Type) { - auto [Iterator, Success] = ReturnValues().emplace(Location); + auto &&[Iterator, Success] = ReturnValues().emplace(Location); revng_assert(Success); Iterator->Type() = std::move(Type); return *Iterator; diff --git a/include/revng/Model/StructDefinition.h b/include/revng/Model/StructDefinition.h index 8aceaae84..a9e435086 100644 --- a/include/revng/Model/StructDefinition.h +++ b/include/revng/Model/StructDefinition.h @@ -44,7 +44,7 @@ public: } StructField &addField(uint64_t Offset, UpcastableType &&Type) { - auto [Iterator, Success] = Fields().emplace(Offset); + auto &&[Iterator, Success] = Fields().emplace(Offset); revng_assert(Success); Iterator->Type() = std::move(Type); return *Iterator; diff --git a/include/revng/PTML/CommentPlacementHelper.h b/include/revng/PTML/CommentPlacementHelper.h index 8bebf7fd0..3c38aa527 100644 --- a/include/revng/PTML/CommentPlacementHelper.h +++ b/include/revng/PTML/CommentPlacementHelper.h @@ -221,7 +221,7 @@ public: for (const auto &Statement : Trait::getStatements(Node->getBlock())) { StatementLocationType Location = Trait::getAddresses(Statement); - for (auto [Index, Comment] : llvm::enumerate(Function.Comments())) { + for (auto &&[Index, Comment] : llvm::enumerate(Function.Comments())) { // Use the Tversky Index as the scoring function. // Note the parameters controlling the weights of the sets: the higher @@ -241,7 +241,7 @@ public: } // Process homeless comments so they don't interfere with the others - for (auto [I, Comment] : llvm::enumerate(Function.Comments())) + for (auto &&[I, Comment] : llvm::enumerate(Function.Comments())) if (Scores[I].first.Numerator == 0) HomelessComments.emplace_back(I, false, Score{}, &Comment.Location()); diff --git a/include/revng/Pipeline/Loader.h b/include/revng/Pipeline/Loader.h index 125b77ecc..9632fb06e 100644 --- a/include/revng/Pipeline/Loader.h +++ b/include/revng/Pipeline/Loader.h @@ -126,11 +126,10 @@ public: template void addDefaultConstructibleContainer(llvm::StringRef Name) { - auto [_, - inserted] = KnownContainerTypes - .try_emplace(Name, - ContainerFactory::create()); - revng_assert(inserted); + bool S = KnownContainerTypes + .try_emplace(Name, ContainerFactory::create()) + .second; + revng_assert(S); } void addContainerFactory(llvm::StringRef Name, ContainerFactory Factory) { @@ -152,7 +151,7 @@ public: template void registerLLVMPass(llvm::StringRef Name) { - auto [_, inserted] = KnownLLVMPipeTypes.try_emplace(Name, []() { + auto &&[_, inserted] = KnownLLVMPipeTypes.try_emplace(Name, []() { using Type = LLVMPassWrapper; return std::make_unique(LLVMPass()); }); @@ -162,17 +161,17 @@ public: template void registerAnalysis(llvm::StringRef Name, const AnalysisType &Analysis) { - auto [_, inserted] = KnownAnalysisTypes - .try_emplace(Name, - AnalysisWrapper::make(Analysis, {})); - revng_assert(inserted); + bool S = KnownAnalysisTypes + .try_emplace(Name, AnalysisWrapper::make(Analysis, {})) + .second; + revng_assert(S); } template void registerPipe(llvm::StringRef Name) { - auto [_, inserted] = KnownPipesTypes - .try_emplace(Name, PipeWrapper::make({})); - revng_assert(inserted); + bool S = KnownPipesTypes.try_emplace(Name, PipeWrapper::make({})) + .second; + revng_assert(S); } void registerEnabledFlags(auto &NamesRange) { diff --git a/include/revng/Pipeline/Target.h b/include/revng/Pipeline/Target.h index ca44990b7..ead3d3883 100644 --- a/include/revng/Pipeline/Target.h +++ b/include/revng/Pipeline/Target.h @@ -254,12 +254,12 @@ private: public: llvm::iterator_range filterByKind(const Kind &K) { - auto [b, e] = std::equal_range(begin(), end(), K, Comp()); + auto &&[b, e] = std::equal_range(begin(), end(), K, Comp()); return llvm::make_range(b, e); } llvm::iterator_range filterByKind(const Kind &K) const { - auto [b, e] = std::equal_range(begin(), end(), K, Comp()); + auto &&[b, e] = std::equal_range(begin(), end(), K, Comp()); return llvm::make_range(b, e); } @@ -305,7 +305,7 @@ public: bool operator==(const ContainerToTargetsMap &) const = default; bool sameTargets(const ContainerToTargetsMap &Other) const { - for (auto [ThisPair, OtherPair] : zipmap_range(Status, Other.Status)) { + for (auto &&[ThisPair, OtherPair] : zipmap_range(Status, Other.Status)) { if (ThisPair == nullptr and not OtherPair->second.empty()) { return false; } else if (OtherPair == nullptr and not ThisPair->second.empty()) { diff --git a/include/revng/Pipes/StringMap.h b/include/revng/Pipes/StringMap.h index 623337133..ac428364b 100644 --- a/include/revng/Pipes/StringMap.h +++ b/include/revng/Pipes/StringMap.h @@ -271,20 +271,20 @@ private: public: auto insert(const ValueType &V) { - auto [Iterator, Success] = Map.insert(V); + auto &&[Iterator, Success] = Map.insert(V); return std::pair{ revng::map_iterator(Iterator, mapIt), Success }; }; auto insert(ValueType &&V) { - auto [Iterator, Success] = Map.insert(std::move(V)); + auto &&[Iterator, Success] = Map.insert(std::move(V)); return std::pair{ revng::map_iterator(Iterator, mapIt), Success }; }; auto insert_or_assign(KeyType Key, const std::string &Value) { - auto [Iterator, Success] = Map.insert_or_assign(Key, Value); + auto &&[Iterator, Success] = Map.insert_or_assign(Key, Value); return std::pair{ revng::map_iterator(Iterator, mapIt), Success }; }; auto insert_or_assign(KeyType Key, std::string &&Value) { - auto [Iterator, Success] = Map.insert_or_assign(Key, std::move(Value)); + auto &&[Iterator, Success] = Map.insert_or_assign(Key, std::move(Value)); return std::pair{ revng::map_iterator(Iterator, mapIt), Success }; }; diff --git a/include/revng/RestructureCFG/RegionCFGTreeImpl.h b/include/revng/RestructureCFG/RegionCFGTreeImpl.h index 64b7ff26d..98464bd1b 100644 --- a/include/revng/RestructureCFG/RegionCFGTreeImpl.h +++ b/include/revng/RestructureCFG/RegionCFGTreeImpl.h @@ -392,7 +392,7 @@ RegionCFG::cloneUntilExit(BasicBlockNode *Node, // Ensure that we are not processing the sink node. revng_assert(CurrentNode != Sink); - auto [_, Inserted] = AlreadyProcessed.insert(CurrentNode); + auto &&[_, Inserted] = AlreadyProcessed.insert(CurrentNode); if (!Inserted) continue; diff --git a/include/revng/Support/YAMLTraits.h b/include/revng/Support/YAMLTraits.h index 868888724..a566e1309 100644 --- a/include/revng/Support/YAMLTraits.h +++ b/include/revng/Support/YAMLTraits.h @@ -118,7 +118,7 @@ struct CompositeScalar { static llvm::StringRef input(llvm::StringRef Scalar, void *Context, T &Value) { if constexpr (I < std::tuple_size_v) { - auto [Before, After] = Scalar.split(Separator); + auto &&[Before, After] = Scalar.split(Separator); using element = std::tuple_element_t; get(Value) = getValueFromYAMLScalar(Before); diff --git a/include/revng/TupleTree/TupleTreeDiff.h b/include/revng/TupleTree/TupleTreeDiff.h index 353a7551e..34756d7ab 100644 --- a/include/revng/TupleTree/TupleTreeDiff.h +++ b/include/revng/TupleTree/TupleTreeDiff.h @@ -371,7 +371,7 @@ private: template void diffImpl(const T &LHS, const T &RHS) { - for (auto [LHSElement, RHSElement] : zipmap_range(LHS, RHS)) { + for (auto &&[LHSElement, RHSElement] : zipmap_range(LHS, RHS)) { if (LHSElement == nullptr) { // Added Result.add(Stack, *RHSElement); diff --git a/include/revng/TupleTree/TupleTreePath.h b/include/revng/TupleTree/TupleTreePath.h index 309ab11ea..9c4ec540d 100644 --- a/include/revng/TupleTree/TupleTreePath.h +++ b/include/revng/TupleTree/TupleTreePath.h @@ -172,7 +172,7 @@ public: TupleTreePath &operator=(const TupleTreePath &Other) { if (&Other != this) { Storage.resize(Other.size()); - for (auto [ThisElement, OtherElement] : + for (auto &&[ThisElement, OtherElement] : llvm::zip(Storage, Other.Storage)) { static_assert(std::is_reference_v); OtherElement.clone(&ThisElement); diff --git a/include/revng/TupleTree/Visits.h b/include/revng/TupleTree/Visits.h index 13dbaea94..a7377dbe6 100644 --- a/include/revng/TupleTree/Visits.h +++ b/include/revng/TupleTree/Visits.h @@ -570,9 +570,9 @@ bool PathMatcher::visitTupleTreeNode(llvm::StringRef String, if (String.size() == 0) return true; - auto [Kind, RHS] = String.split("::"); + auto &&[Kind, RHS] = String.split("::"); auto Dispatch = [&RHS, &Result]() { - auto [Before, After] = RHS.split('/'); + auto &&[Before, After] = RHS.split('/'); return PathMatcher::visitTuple(Before, After, Result); }; @@ -590,7 +590,7 @@ bool PathMatcher::visitTupleTreeNode(llvm::StringRef String, if (String.size() == 0) return true; - auto [Before, After] = String.split('/'); + auto &&[Before, After] = String.split('/'); return visitTuple(Before, After, Result); } @@ -600,13 +600,13 @@ bool PathMatcher::visitTupleTreeNode(llvm::StringRef String, if (String.size() == 0) return true; - auto [Before, After] = String.split('/'); + auto &&[Before, After] = String.split('/'); using Key = std::remove_cv_t; using Value = typename T::value_type; if constexpr (StrictSpecializationOf) { - auto [PreDash, PostDash] = Before.split("-"); + auto &&[PreDash, PostDash] = Before.split("-"); if (PreDash == "*") { // Mark as free Result.Free.push_back(Result.Path.size()); diff --git a/include/revng/tests/unit/ModelType.inc b/include/revng/tests/unit/ModelType.inc index 500535782..52d684c7b 100644 --- a/include/revng/tests/unit/ModelType.inc +++ b/include/revng/tests/unit/ModelType.inc @@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(PrimitiveTypes) { BOOST_AUTO_TEST_CASE(EnumTypes) { TupleTree T; - auto [EnumDefinition, EnumType] = T->makeEnumDefinition(); + auto &&[EnumDefinition, EnumType] = T->makeEnumDefinition(); revng_check(T->TypeDefinitions().size() == 1); // The enum does not verify unless it has a valid underlying type and at least @@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(TypedefTypes) { TupleTree T; // Make a typedef of an int32_t - auto [Int32, Int32Type] = T->makeTypeDefinition(); + auto &&[Int32, Int32Type] = T->makeTypeDefinition(); revng_check(T->TypeDefinitions().size() == 1); Int32.UnderlyingType() = model::PrimitiveType::make(Signed, 4); Int32.CustomName() = "int_32_typedef"; @@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(TypedefTypes) { revng_check(checkSerialization(T)); // Make another typedef, this time a pointer. - auto [Pointer, PointerType] = T->makeTypeDefinition(); + auto &&[Pointer, PointerType] = T->makeTypeDefinition(); revng_check(T->TypeDefinitions().size() == 2); Pointer.UnderlyingType() = model::PointerType::make(std::move(Int32Type), 4); Pointer.CustomName() = "int_32_pointer_typedef"; @@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE(TypedefTypes) { revng_check(checkSerialization(T)); // Make one more, this time an array - auto [Array, ArrayType] = T->makeTypeDefinition(); + auto &&[Array, ArrayType] = T->makeTypeDefinition(); revng_check(T->TypeDefinitions().size() == 3); Array.UnderlyingType() = model::ArrayType::make(std::move(PointerType), 25); Array.CustomName() = "int_32_pointer_array_typedef"; @@ -263,7 +263,7 @@ BOOST_AUTO_TEST_CASE(TypedefTypes) { revng_check(checkSerialization(T)); // If the underlying type is the type itself, something is broken - auto [Error, ErrorType] = T->makeTypeDefinition(); + auto &&[Error, ErrorType] = T->makeTypeDefinition(); revng_check(T->TypeDefinitions().size() == 4); Error.UnderlyingType() = std::move(ErrorType); revng_check(not verify(Error, *T, false)); @@ -276,7 +276,7 @@ BOOST_AUTO_TEST_CASE(StructTypes) { TupleTree T; // Insert the struct - auto [Struct, StructType] = T->makeStructDefinition(); + auto &&[Struct, StructType] = T->makeStructDefinition(); revng_check(T->TypeDefinitions().size() == 1); // Struct without size does not verify. @@ -410,7 +410,7 @@ BOOST_AUTO_TEST_CASE(UnionTypes) { TupleTree T; // Insert the union - auto [Union, UnionType] = T->makeUnionDefinition(); + auto &&[Union, UnionType] = T->makeUnionDefinition(); revng_check(T->TypeDefinitions().size() == 1); revng_check(not verify(Union, *T, false)); revng_check(not verify(*T, false)); @@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(UnionTypes) { UnionField Field1(1); Field1.Type() = model::PrimitiveType::makeSigned(8); Field1.CustomName() = "fld1"; - const auto [It, New] = Union.Fields().insert(std::move(Field1)); + auto &&[It, New] = Union.Fields().insert(std::move(Field1)); revng_check(New); } revng_check(verify(Union, *T, true)); @@ -441,7 +441,7 @@ BOOST_AUTO_TEST_CASE(UnionTypes) { UnionField Field1(2); Field1.Type() = model::PrimitiveType::makeSigned(4); Field1.CustomName() = "fld1"; - const auto [It, New] = Union.Fields().insert(std::move(Field1)); + auto &&[It, New] = Union.Fields().insert(std::move(Field1)); revng_check(New); revng_check(Union.Fields().at(It->Index()).CustomName() == "fld1"); revng_check(not verify(Union, *T, false)); @@ -488,7 +488,7 @@ BOOST_AUTO_TEST_CASE(CABIFunctionTypes) { T->Architecture() = Architecture::x86_64; // Create a C-like function prototype - auto [Prototype, FunctionType] = T->makeCABIFunctionDefinition(); + auto &&[Prototype, FunctionType] = T->makeCABIFunctionDefinition(); Prototype.ABI() = model::ABI::SystemV_x86_64; revng_check(T->TypeDefinitions().size() == 1); @@ -549,7 +549,7 @@ BOOST_AUTO_TEST_CASE(RawFunctionTypes) { TupleTree T; T->Architecture() = Architecture::x86_64; - auto [Prototype, FunctionType] = T->makeRawFunctionDefinition(); + auto &&[Prototype, FunctionType] = T->makeRawFunctionDefinition(); Prototype.Architecture() = Architecture::x86_64; revng_check(Prototype.verify(true)); @@ -638,10 +638,10 @@ BOOST_AUTO_TEST_CASE(TypeComparison) { model::Binary Model; - auto [FirstTD, FirstT] = Model.makeTypedefDefinition(PT::makeUnsigned(4)); + auto &&[FirstTD, FirstT] = Model.makeTypedefDefinition(PT::makeUnsigned(4)); revng_check(FirstTD == *FirstT->tryGetAsDefinition()); - auto [SecondTD, SecondT] = Model.makeTypedefDefinition(PT::makeUnsigned(4)); + auto &&[SecondTD, SecondT] = Model.makeTypedefDefinition(PT::makeUnsigned(4)); revng_check(SecondTD == *SecondT->tryGetAsDefinition()); // Ensure different types are different, even if they only differ by the ID. @@ -679,7 +679,7 @@ BOOST_AUTO_TEST_CASE(TypeComparison) { BOOST_AUTO_TEST_CASE(Filters) { model::Binary Model; { - auto [Enum, _] = Model.makeEnumDefinition(); + auto &&[Enum, _] = Model.makeEnumDefinition(); Enum.UnderlyingType() = model::PrimitiveType::makeUnsigned(4); Enum.Entries().emplace(1ull); @@ -696,7 +696,7 @@ BOOST_AUTO_TEST_CASE(Filters) { } revng_check(ScalarCount == 3); - auto [CFT, _] = Model.makeCABIFunctionDefinition(); + auto &&[CFT, _] = Model.makeCABIFunctionDefinition(); for (auto &[Index, Definition] : llvm::enumerate(Model.TypeDefinitions())) { if (auto &&Type = Model.makeType(Definition->key()); Definition->isPrototype()) { diff --git a/lib/ABI/DefaultFunctionPrototype.cpp b/lib/ABI/DefaultFunctionPrototype.cpp index abe84de28..22e07ffb6 100644 --- a/lib/ABI/DefaultFunctionPrototype.cpp +++ b/lib/ABI/DefaultFunctionPrototype.cpp @@ -11,7 +11,7 @@ static model::UpcastableType defaultPrototype(model::Binary &Binary, model::ABI::Values ABI) { - auto [Definition, Type] = Binary.makeRawFunctionDefinition(); + auto &&[Definition, Type] = Binary.makeRawFunctionDefinition(); revng_assert(ABI != model::ABI::Invalid); Definition.Architecture() = model::ABI::getArchitecture(ABI); diff --git a/lib/ABI/Definition.cpp b/lib/ABI/Definition.cpp index 68a4edeff..564fda2a4 100644 --- a/lib/ABI/Definition.cpp +++ b/lib/ABI/Definition.cpp @@ -196,7 +196,7 @@ const Definition &Definition::get(model::ABI::Values ABI) { revng_abort(Error.c_str()); } - auto [It, Success] = DefinitionCache.try_emplace(ABI, std::move(**Parsed)); + auto &&[It, Success] = DefinitionCache.try_emplace(ABI, std::move(**Parsed)); revng_assert(Success); return It->second; } diff --git a/lib/ABI/FunctionType/Conversion.cpp b/lib/ABI/FunctionType/Conversion.cpp index cdb17915d..4691ecea7 100644 --- a/lib/ABI/FunctionType/Conversion.cpp +++ b/lib/ABI/FunctionType/Conversion.cpp @@ -186,7 +186,7 @@ tryConvertToCABI(const model::RawFunctionDefinition &FunctionType, // The conversion was successful, a new `CABIFunctionDefinition` can now be // created, - auto [Definition, Type] = Binary->makeCABIFunctionDefinition(); + auto &&[Definition, Type] = Binary->makeCABIFunctionDefinition(); revng_assert(Definition.ID() != 0); model::copyMetadata(Definition, FunctionType); Definition.ABI() = ABI.ABI(); @@ -704,7 +704,7 @@ TCC::tryConvertingReturnValue(RFTReturnValues Registers) { } else { // It could be either a struct or a scalar, go the conservative route // and make a struct for it. - auto [Definition, ReturnType] = Bucket.makeStructDefinition(); + auto &&[Definition, ReturnType] = Bucket.makeStructDefinition(); for (model::Register::Values Register : Ordered) { // Make a separate field for each register. model::StructField Field; diff --git a/lib/ABI/FunctionType/Layout.cpp b/lib/ABI/FunctionType/Layout.cpp index f1c1d5dab..89039342f 100644 --- a/lib/ABI/FunctionType/Layout.cpp +++ b/lib/ABI/FunctionType/Layout.cpp @@ -83,7 +83,7 @@ ToRawConverter::convert(const model::CABIFunctionDefinition &FunctionType, // Since this conversion cannot fail, nothing prevents us from creating // the result type right away. - auto [NewPrototype, NewType] = Binary->makeRawFunctionDefinition(); + auto &&[NewPrototype, NewType] = Binary->makeRawFunctionDefinition(); revng_assert(FunctionType.ABI() != model::ABI::Invalid); NewPrototype.Architecture() = model::ABI::getArchitecture(FunctionType.ABI()); @@ -280,8 +280,8 @@ ToRawConverter::convert(const model::CABIFunctionDefinition &FunctionType, // Otherwise, add a new struct to the model. if (NewPrototype.StackArgumentsType().isEmpty()) { - auto [_, Path] = Binary->makeStructDefinition(std::move(StackArguments)); - NewPrototype.StackArgumentsType() = Path; + auto &&[_, T] = Binary->makeStructDefinition(std::move(StackArguments)); + NewPrototype.StackArgumentsType() = T; } } @@ -357,7 +357,7 @@ ToRawConverter::distributeArguments(CFTArguments Arguments, std::back_inserter(Result)); if (ABI.PackStackArguments()) { - for (auto [Current, Next] : zip_pairs(Result)) { + for (auto &&[Current, Next] : zip_pairs(Result)) { if (Current.SizeOnStack && Next.SizeOnStack) { if (Current.OffsetOnStack + Current.SizeOnStack > Next.OffsetOnStack) { Current.SizeOnStack -= Current.PostPaddingSize; diff --git a/lib/ABI/FunctionType/ValueDistributor.cpp b/lib/ABI/FunctionType/ValueDistributor.cpp index 9f6b3a902..cd9201053 100644 --- a/lib/ABI/FunctionType/ValueDistributor.cpp +++ b/lib/ABI/FunctionType/ValueDistributor.cpp @@ -252,13 +252,13 @@ ArgumentDistributor::nonPositionBased(bool IsScalar, HasNaturalAlignment = false; } - auto [Result, NextRegisterIndex] = distribute(Size, - Alignment, - HasNaturalAlignment, - RegisterList, - *RegisterCounter, - RegisterLimit, - ForbidSplitting); + auto &&[Result, NextRegisterIndex] = distribute(Size, + Alignment, + HasNaturalAlignment, + RegisterList, + *RegisterCounter, + RegisterLimit, + ForbidSplitting); if (UsesPointerToCopy) { revng_assert(Result.size() == 1); Result[0].UsesPointerToCopy = UsesPointerToCopy; @@ -357,7 +357,7 @@ DistributedValue ReturnValueDistributor::returnValue(const model::Type &Type) { ABI.MaximumGPRsPerAggregateReturnValue(); } - auto [Result, _] = distribute(Type, RegisterList, 0, Limit, true); + auto &&[Result, _] = distribute(Type, RegisterList, 0, Limit, true); revng_assert(Result.size() == 1, "Return values should never be padded."); return Result[0]; } diff --git a/lib/ABI/RegisterStateDeductions.cpp b/lib/ABI/RegisterStateDeductions.cpp index 412483f6c..733d9830f 100644 --- a/lib/ABI/RegisterStateDeductions.cpp +++ b/lib/ABI/RegisterStateDeductions.cpp @@ -126,7 +126,7 @@ private: } auto ArgumentRange = llvm::zip(llvm::reverse(GPAR), llvm::reverse(VAR)); - for (auto [GPR, VR] : ArgumentRange) + for (auto &&[GPR, VR] : ArgumentRange) if (!singlePositionBasedDeduction(GPR, VR, State, IsRequired)) return false; diff --git a/lib/Canonicalize/HoistStructPhis.cpp b/lib/Canonicalize/HoistStructPhis.cpp index 1598e99bf..fb4efe302 100644 --- a/lib/Canonicalize/HoistStructPhis.cpp +++ b/lib/Canonicalize/HoistStructPhis.cpp @@ -85,7 +85,7 @@ public: } } - for (auto [V, Predecessor] : zip(Phi->incoming_values(), Phi->blocks())) { + for (auto &&[V, Predecessor] : zip(Phi->incoming_values(), Phi->blocks())) { if (isa(V)) { for (auto *NewPhi : Phis) cast(NewPhi)->addIncoming(UndefValue::get(NewPhi->getType()), @@ -97,7 +97,7 @@ public: } } else if (auto *Call = dyn_cast(V)) { revng_assert(Call->arg_size() == Phis.size()); - for (auto [Argument, NewPhi] : zip(Call->args(), Phis)) + for (auto &&[Argument, NewPhi] : zip(Call->args(), Phis)) cast(NewPhi)->addIncoming(Argument, Predecessor); } } diff --git a/lib/Canonicalize/ImplicitModelCastPass.cpp b/lib/Canonicalize/ImplicitModelCastPass.cpp index 307a8ca16..188573b5b 100644 --- a/lib/Canonicalize/ImplicitModelCastPass.cpp +++ b/lib/Canonicalize/ImplicitModelCastPass.cpp @@ -360,7 +360,7 @@ bool IMCP::collectTypeInfoForPromotionForSingleValue(const llvm::Value *Value, if (PromotedType) { // This will be used in the second stage of the // reducing-cast-algorithm. - auto [It, Success] = PromotedTypes[I].try_emplace(Value, PromotedType); + auto &&[It, Success] = PromotedTypes[I].try_emplace(Value, PromotedType); if (not Success) { revng_assert(not It->second.isEmpty()); revng_assert(not PromotedType.isEmpty()); diff --git a/lib/Canonicalize/MakeModelGEPPass.cpp b/lib/Canonicalize/MakeModelGEPPass.cpp index 2d4889ef0..641c2e78d 100644 --- a/lib/Canonicalize/MakeModelGEPPass.cpp +++ b/lib/Canonicalize/MakeModelGEPPass.cpp @@ -2028,7 +2028,7 @@ class ModelGEPArgCache { public: Constant *get(const model::UpcastableType &Type, llvm::Module &M) { - auto [It, Success] = GlobalModelGEPTypeArgs.try_emplace(Type, nullptr); + auto &&[It, Success] = GlobalModelGEPTypeArgs.try_emplace(Type, nullptr); if (Success) It->second = toLLVMString(Type, M); @@ -2039,7 +2039,7 @@ public: static llvm::BasicBlock *getUniqueIncoming(Value *V, PHINode *Phi) { llvm::BasicBlock *Result = nullptr; - for (auto [IncomingValue, IncomingBlock] : + for (auto &&[IncomingValue, IncomingBlock] : zip(Phi->incoming_values(), Phi->blocks())) { if (IncomingValue == V) { if (Result == nullptr) { diff --git a/lib/Canonicalize/OperatorPrecedenceResolutionPass.cpp b/lib/Canonicalize/OperatorPrecedenceResolutionPass.cpp index 037e8526c..a55886285 100644 --- a/lib/Canonicalize/OperatorPrecedenceResolutionPass.cpp +++ b/lib/Canonicalize/OperatorPrecedenceResolutionPass.cpp @@ -447,15 +447,15 @@ bool OPRP::needsParentheses(Instruction *I, Use &U) { if (&U != &Call->getCalledOperandUse()) return false; - auto [InstructionPrecedence, - NumberOfClassesToForceParenthesesFor, - InstructionAssociativity, - InstructionArity] = getPrecedence(*I); + auto &&[InstructionPrecedence, + NumberOfClassesToForceParenthesesFor, + InstructionAssociativity, + InstructionArity] = getPrecedence(*I); - auto [OperandPrecedence, - _, - OperandAssociativity, - OperandArity] = getPrecedence(*Op); + auto &&[OperandPrecedence, + _, + OperandAssociativity, + OperandArity] = getPrecedence(*Op); // If the precedence of the instruction and the operand is the same, we have // to discriminate by Associativity and by Arity diff --git a/lib/Canonicalize/RemoveLoadStore.cpp b/lib/Canonicalize/RemoveLoadStore.cpp index 82d5c42ce..a66cf2fbb 100644 --- a/lib/Canonicalize/RemoveLoadStore.cpp +++ b/lib/Canonicalize/RemoveLoadStore.cpp @@ -126,8 +126,8 @@ bool RemoveLoadStore::runOnFunction(llvm::Function &F) { InjectedCall = Builder.CreateCall(CopyFunction, { DerefCall }); // Add the dereferenced type to the type map - auto [_, Inserted] = TypeMap.insert({ InjectedCall, PointedT.copy() }); - revng_assert(Inserted); + auto &&[_, Success] = TypeMap.insert({ InjectedCall, PointedT.copy() }); + revng_assert(Success); } else if (auto *Store = dyn_cast(&I)) { llvm::Value *ValueOp = Store->getValueOperand(); diff --git a/lib/DataLayoutAnalysis/Backend/DLAMakeModelTypes.cpp b/lib/DataLayoutAnalysis/Backend/DLAMakeModelTypes.cpp index 3d0f26f3c..ba6ecf364 100644 --- a/lib/DataLayoutAnalysis/Backend/DLAMakeModelTypes.cpp +++ b/lib/DataLayoutAnalysis/Backend/DLAMakeModelTypes.cpp @@ -48,7 +48,7 @@ createStructWrapper(const LTSN *N, uint64_t Offset = 0ULL, uint64_t WrapperSize = 0ULL) { // Create struct - auto [Struct, NewType] = Model->makeStructDefinition(); + auto &&[Struct, NewType] = Model->makeStructDefinition(); // Create and insert field in struct model::StructField &Field = Struct.addField(Offset, std::move(T)); @@ -179,7 +179,7 @@ makeStructFromNode(const LTSN *N, // Create struct revng_log(Log, "Creating struct type for node " << N->ID); LoggerIndent StructIndent{ Log }; - auto [Struct, NewType] = Model->makeStructDefinition(); + auto &&[Struct, NewType] = Model->makeStructDefinition(); Struct.Size() = N->Size; // This holds the struct fields in the same order as in the model, so we can @@ -250,7 +250,7 @@ makeUnionFromNode(const LTSN *N, const VectEqClasses &EqClasses) { // Create union revng_log(Log, "Creating union type for node " << N->ID); - auto [Union, NewType] = Model->makeUnionDefinition(); + auto &&[Union, NewType] = Model->makeUnionDefinition(); LoggerIndent StructIndent{ Log }; @@ -294,17 +294,17 @@ makeUnionFromNode(const LTSN *N, for (auto &[Field, SuccNode] : Fields) { // Insert field in union - const auto &[NewF, Inserted] = Union.Fields().insert(std::move(Field)); + const auto &[New, Inserted] = Union.Fields().insert(std::move(Field)); revng_assert(Inserted); // If the field is a pointer, save the type: we want to update it later - if (NewF->Type()->isPointer()) { - auto [_, S] = PointerFieldsToUpdate[SuccNode].insert(NewF->Type().get()); + if (New->Type()->isPointer()) { + auto &&[_, S] = PointerFieldsToUpdate[SuccNode].insert(New->Type().get()); revng_assert(S); revng_log(Log, "Pointer node " << SuccNode->ID << " inside union (ID: " << Union.ID() - << "): " << NewF->Type()->toString()); + << "): " << New->Type()->toString()); } } @@ -435,7 +435,7 @@ static TypeMapT mapLLVMValuesToModelTypes(const LayoutTypeSystem &TS, TypeMapT ValMap; revng_log(TypeMapLog, "LayoutTypePtr; ModelType"); - for (auto [ValueIdx, Val] : llvm::enumerate(Values)) { + for (auto &&[ValueIdx, Val] : llvm::enumerate(Values)) { // If the value is in the class that represents nodes removed from the // graph, or the value itself does not represent an llvm::Value, we can just // skip it. @@ -495,15 +495,14 @@ TypeMapT dla::makeModelTypes(const LayoutTypeSystem &TS, // encountered. In this way, each tree of pointer edges is visited only once. revng_log(Log, "Fixing pointer fields"); LoggerIndent Indent{ Log }; - for (auto [PointerNode, PointerTypes] : PointerFieldsToUpdate) { + for (auto &&[PointerNode, PointerTypes] : PointerFieldsToUpdate) { revng_log(Log, "Updating " << PointerTypes.size() << " pointer types associated to ptr node: " << PointerNode->ID); LoggerIndent MoreIndent{ Log }; - const auto [NumPointers, - PointeeNode] = getNumPointersAndPointee(PointerNode); + auto &&[NumPointers, PointeeNode] = getNumPointersAndPointee(PointerNode); revng_log(Log, "NumPointers: " << NumPointers); auto FinalPointeeType = getNodeType(Model, PointeeNode, Types, EqClasses); diff --git a/lib/DataLayoutAnalysis/Backend/DLAUpdateModelTypes.cpp b/lib/DataLayoutAnalysis/Backend/DLAUpdateModelTypes.cpp index 0e8fb93f7..d549d8e4e 100644 --- a/lib/DataLayoutAnalysis/Backend/DLAUpdateModelTypes.cpp +++ b/lib/DataLayoutAnalysis/Backend/DLAUpdateModelTypes.cpp @@ -618,7 +618,7 @@ fillStructWithRecoveredDLATypeAtOffset(model::Binary &Model, NewU->Fields().erase(FieldNum); // Re-enumerate the remaining fields - for (auto [Index, Field] : llvm::enumerate(NewU->Fields())) + for (auto &&[Index, Field] : llvm::enumerate(NewU->Fields())) Field.Index() = Index; revng_assert(NewU->Fields().size() == FieldsRemaining); diff --git a/lib/DataLayoutAnalysis/Frontend/DLACreateInterProceduralTypes.cpp b/lib/DataLayoutAnalysis/Frontend/DLACreateInterProceduralTypes.cpp index 6f6f7db44..d827fe995 100644 --- a/lib/DataLayoutAnalysis/Frontend/DLACreateInterProceduralTypes.cpp +++ b/lib/DataLayoutAnalysis/Frontend/DLACreateInterProceduralTypes.cpp @@ -71,7 +71,7 @@ bool TSBuilder::createInterproceduralTypes(llvm::Module &M, if (not FuncWithSameProto.isNull()) { auto OtherRetVals = getLayoutTypes(*FuncWithSameProto.getVal()); revng_assert(FRetTypes.size() == OtherRetVals.size()); - for (auto [N1, N2] : llvm::zip(OtherRetVals, FRetTypes)) + for (auto &&[N1, N2] : llvm::zip(OtherRetVals, FRetTypes)) TS.addEqualityLink(N1, N2.first); } @@ -96,7 +96,7 @@ bool TSBuilder::createInterproceduralTypes(llvm::Module &M, // Arguments can only be integers and pointers revng_assert(isa(ArgVal.getType()) or isa(ArgVal.getType())); - auto [ArgNode, _] = getOrCreateLayoutType(&ArgVal); + auto &&[ArgNode, _] = getOrCreateLayoutType(&ArgVal); revng_assert(ArgNode); model::UpcastableType ArgumentModelType; diff --git a/lib/DataLayoutAnalysis/Frontend/DLACreateIntraProceduralTypes.cpp b/lib/DataLayoutAnalysis/Frontend/DLACreateIntraProceduralTypes.cpp index 762a2be66..eb56966bc 100644 --- a/lib/DataLayoutAnalysis/Frontend/DLACreateIntraProceduralTypes.cpp +++ b/lib/DataLayoutAnalysis/Frontend/DLACreateIntraProceduralTypes.cpp @@ -420,9 +420,10 @@ public: // Add an equality edge between the `AddressOf` node and it's // pointee node auto *Arg = C->getArgOperand(1); - auto [PointedLayout, ArgIsNew] = Builder.getOrCreateLayoutType(Arg); + auto &&[PointedLayout, + ArgIsNew] = Builder.getOrCreateLayoutType(Arg); Changed |= ArgIsNew; - auto [_, NewLink] = TS.addEqualityLink(PointedLayout, AddrLayout); + auto &&[_, NewLink] = TS.addEqualityLink(PointedLayout, AddrLayout); Changed |= NewLink; continue; } @@ -664,7 +665,7 @@ bool Builder::connectToFuncsWithSamePrototype(const llvm::CallInst *Call, auto OtherRetVals = getLayoutTypes(*OtherCall.getVal()); auto RetVals = getLayoutTypes(*Call); revng_assert(RetVals.size() == OtherRetVals.size()); - for (auto [N1, N2] : llvm::zip(OtherRetVals, RetVals)) { + for (auto &&[N1, N2] : llvm::zip(OtherRetVals, RetVals)) { Changed = true; TS.addEqualityLink(N1, N2); } diff --git a/lib/DataLayoutAnalysis/Middleend/DecomposeStridedEdges.cpp b/lib/DataLayoutAnalysis/Middleend/DecomposeStridedEdges.cpp index 079b6f7d7..a24814b9e 100644 --- a/lib/DataLayoutAnalysis/Middleend/DecomposeStridedEdges.cpp +++ b/lib/DataLayoutAnalysis/Middleend/DecomposeStridedEdges.cpp @@ -76,7 +76,7 @@ bool DecomposeStridedEdges::runOnTypeSystem(LayoutTypeSystem &TS) { LayoutTypeSystemNode *Pred = NodeChain[Idx + 1]; LayoutTypeSystemNode *Succ = NodeChain[Idx]; // Link them - const auto [Tag, New] = TS.addInstanceLink(Pred, Succ, std::move(OE)); + auto &&[Tag, New] = TS.addInstanceLink(Pred, Succ, std::move(OE)); if (Pred != Parent) Pred->Size = getFieldSize(Succ, Tag); } diff --git a/lib/DataLayoutAnalysis/Middleend/DeduplicateFields.cpp b/lib/DataLayoutAnalysis/Middleend/DeduplicateFields.cpp index cdff159d2..fd8445891 100644 --- a/lib/DataLayoutAnalysis/Middleend/DeduplicateFields.cpp +++ b/lib/DataLayoutAnalysis/Middleend/DeduplicateFields.cpp @@ -290,7 +290,7 @@ mergeIfTopologicallyEq(LayoutTypeSystem &TS, const Link &ToKeep, const Link &ToMerge) { - auto [AreEquiv, Subtree1, Subtree2] = areEquivSubtrees(ToKeep, ToMerge); + auto &&[AreEquiv, Subtree1, Subtree2] = areEquivSubtrees(ToKeep, ToMerge); if (not AreEquiv) { revng_log(CmpLog, "Different!"); return { false, {}, {} }; @@ -456,11 +456,11 @@ bool DeduplicateFields::runOnTypeSystem(LayoutTypeSystem &TS) { revng_log(Log, "skip pointer edge"); } - auto [IsMerged, - Preserved, - Erased] = mergeIfTopologicallyEq(TS, - NotMergedLink, - CurLink); + auto &&[IsMerged, + Preserved, + Erased] = mergeIfTopologicallyEq(TS, + NotMergedLink, + CurLink); if (not IsMerged) { revng_log(Log, "Edge not merged!"); continue; diff --git a/lib/EarlyFunctionAnalysis/CFGAnalyzer.cpp b/lib/EarlyFunctionAnalysis/CFGAnalyzer.cpp index 78918f850..fd65aa5e0 100644 --- a/lib/EarlyFunctionAnalysis/CFGAnalyzer.cpp +++ b/lib/EarlyFunctionAnalysis/CFGAnalyzer.cpp @@ -58,7 +58,7 @@ static opt IndirectBranchInfoSummaryPath("indirect-branch-info-" static Logger<> Log("cfg-analyzer"); static MetaAddress getFinalAddressOfBasicBlock(llvm::BasicBlock *BB) { - auto [End, Size] = getPC(BB->getTerminator()); + auto &&[End, Size] = getPC(BB->getTerminator()); return End + Size; } @@ -779,10 +779,10 @@ FunctionSummary CFGAnalyzer::milkInfo(OutlinedFunction *OutlinedFunction, // it's useful to determine the FSO of the caller auto *CalledSymbolArgument = CI->getArgOperand(CalledSymbolIndex); StringRef CalledSymbol = extractFromConstantStringPtr(CalledSymbolArgument); - auto [Summary, IsTailCall] = Oracle.getCallSite(OutlinedFunction->Address, - Block.ID(), - MetaAddress::invalid(), - CalledSymbol); + auto &&[Summary, IsTailCall] = Oracle.getCallSite(OutlinedFunction->Address, + Block.ID(), + MetaAddress::invalid(), + CalledSymbol); Argument = CI->getArgOperand(StackPointerOffsetIndex); auto *StackPointerOffset = dyn_cast(Argument); @@ -867,7 +867,7 @@ FunctionSummary CFGAnalyzer::milkInfo(OutlinedFunction *OutlinedFunction, if (TailCalls.size() > 0) { MaybeWinFSO = electFSO(TailCalls); bool Different = false; - for (auto [CI, FSO, Summary] : TailCalls) { + for (auto &&[CI, FSO, Summary] : TailCalls) { if (FSO == *MaybeWinFSO) { ClobberedRegisters.recordClobberedRegisters(CI); ClobberedRegisters.add(Summary->ClobberedRegisters); diff --git a/lib/EarlyFunctionAnalysis/ControlFlowGraph.cpp b/lib/EarlyFunctionAnalysis/ControlFlowGraph.cpp index 2a0c57813..c0f8c432b 100644 --- a/lib/EarlyFunctionAnalysis/ControlFlowGraph.cpp +++ b/lib/EarlyFunctionAnalysis/ControlFlowGraph.cpp @@ -190,7 +190,7 @@ void ControlFlowGraph::simplify(const model::Binary &Binary) { ToMerge.emplace_back(Block.ID(), Block.nextBlock()); } - for (auto [PredecessorAddress, BlockAddress] : llvm::reverse(ToMerge)) { + for (auto &&[PredecessorAddress, BlockAddress] : llvm::reverse(ToMerge)) { efa::BasicBlock &Predecessor = Blocks().at(PredecessorAddress); efa::BasicBlock &Block = Blocks().at(BlockAddress); @@ -294,7 +294,7 @@ bool ControlFlowGraph::verify(const model::Binary &Binary, } void ControlFlowGraph::dumpCFG(const model::Binary &Binary) const { - auto [G, _] = buildControlFlowGraph(Blocks(), Entry(), Binary); + auto &&[G, _] = buildControlFlowGraph(Blocks(), Entry(), Binary); WriteGraph(&G, "function-metadata"); } diff --git a/lib/EarlyFunctionAnalysis/DetectABI.cpp b/lib/EarlyFunctionAnalysis/DetectABI.cpp index 1ffe1e4fa..e2cddd5dd 100644 --- a/lib/EarlyFunctionAnalysis/DetectABI.cpp +++ b/lib/EarlyFunctionAnalysis/DetectABI.cpp @@ -542,10 +542,10 @@ Changes DetectABI::analyzeFunctionABI(const model::Function &Function, auto CalleeAddress = MetaAddress::fromValue(Call->getArgOperand(1)); auto ExtractString = extractFromConstantStringPtr; StringRef CalleeSymbol = ExtractString(Call->getArgOperand(2)); - auto [Summary, _] = Oracle.getCallSite(Function.Entry(), - CallerBlock, - CalleeAddress, - CalleeSymbol); + auto &&[Summary, _] = Oracle.getCallSite(Function.Entry(), + CallerBlock, + CalleeAddress, + CalleeSymbol); auto &ABIResults = Summary->ABIResults; auto *BB = Call->getParent(); @@ -682,7 +682,7 @@ void DetectABI::finalizeModel() { // Replace function attributes Function.Attributes() = Summary.Attributes; - auto [Prototype, NewType] = Binary->makeRawFunctionDefinition(); + auto &&[Prototype, NewType] = Binary->makeRawFunctionDefinition(); Prototype.Architecture() = getCodeArchitecture(EntryPC); // Record arguments and return values @@ -860,7 +860,7 @@ DetectABI::buildPrototypeForIndirectCall(const FunctionSummary &CallerSummary, const efa::BasicBlock &CallerBlock) { using namespace model; - auto [Prototype, NewType] = Binary->makeRawFunctionDefinition(); + auto &&[Prototype, NewType] = Binary->makeRawFunctionDefinition(); Prototype.Architecture() = getCodeArchitecture(CallerBlock.ID().start()); bool Found = false; diff --git a/lib/EarlyFunctionAnalysis/FunctionSummaryOracle.cpp b/lib/EarlyFunctionAnalysis/FunctionSummaryOracle.cpp index 059c16518..97db90830 100644 --- a/lib/EarlyFunctionAnalysis/FunctionSummaryOracle.cpp +++ b/lib/EarlyFunctionAnalysis/FunctionSummaryOracle.cpp @@ -49,8 +49,8 @@ PrototypeImporter::prototype(const AttributesSet &Attributes, Summary.ABIResults.ReturnValuesRegisters.erase(CSV); } - auto [ArgumentRegisters, - ReturnValueRegisters] = abi::FunctionType::usedRegisters(*Prototype); + auto &&[ArgumentRegisters, + ReturnValueRegisters] = abi::FunctionType::usedRegisters(*Prototype); for (Register ArgumentRegister : ArgumentRegisters) { llvm::StringRef Name = model::Register::getCSVName(ArgumentRegister); if (llvm::GlobalVariable *CSV = M.getGlobalVariable(Name, true)) @@ -73,7 +73,7 @@ FunctionSummaryOracle::getCallSite(MetaAddress Function, BasicBlockID CallerBlockAddress, MetaAddress CalledLocalFunction, llvm::StringRef CalledSymbol) { - auto [Summary, IsTailCall] = getExactCallSite(Function, CallerBlockAddress); + auto &&[Summary, IsTailCall] = getExactCallSite(Function, CallerBlockAddress); if (Summary != nullptr) { return { Summary, IsTailCall }; } else if (not CalledSymbol.empty()) { diff --git a/lib/EarlyFunctionAnalysis/Outliner.cpp b/lib/EarlyFunctionAnalysis/Outliner.cpp index 3d6f18170..f0960135c 100644 --- a/lib/EarlyFunctionAnalysis/Outliner.cpp +++ b/lib/EarlyFunctionAnalysis/Outliner.cpp @@ -129,11 +129,11 @@ void Outliner::integrateFunctionCallee(CallHandler *TheCallHandler, OutlinedFunctionsMap &FunctionsMap) { llvm::LLVMContext &Context = M.getContext(); - auto [Summary, IsTailCall] = getCallSiteInfo(CallerFunction, - CallerBlock, - FunctionCall, - JumpToSymbol, - Callee); + auto &&[Summary, IsTailCall] = getCallSiteInfo(CallerFunction, + CallerBlock, + FunctionCall, + JumpToSymbol, + Callee); using namespace llvm; using llvm::BasicBlock; @@ -289,11 +289,11 @@ Outliner::outlineFunctionInternal(CallHandler *TheCallHandler, PCCallee = getBasicBlockAddress(Next); CallInst *JumpToSymbol = getMarker(Current, "jump_to_symbol"); - auto [Summary, IsTailCall] = getCallSiteInfo(FunctionAddress, - FunctionCall->getParent(), - FunctionCall, - JumpToSymbol, - PCCallee); + auto &&[Summary, IsTailCall] = getCallSiteInfo(FunctionAddress, + FunctionCall->getParent(), + FunctionCall, + JumpToSymbol, + PCCallee); // Unless it's NoReturn, enqueue the call fallthrough using namespace model::FunctionAttribute; @@ -348,11 +348,11 @@ Outliner::outlineFunctionInternal(CallHandler *TheCallHandler, using namespace model::FunctionAttribute; CallInst *JumpToSymbol = getMarker(BB, "jump_to_symbol"); - auto [CalleeSummary, IsTailCall] = getCallSiteInfo(FunctionAddress, - BB, - FunctionCall, - JumpToSymbol, - PCCallee); + auto &&[CalleeSummary, IsTailCall] = getCallSiteInfo(FunctionAddress, + BB, + FunctionCall, + JumpToSymbol, + PCCallee); bool IsNoReturn = CalleeSummary->Attributes.contains(NoReturn); if (IsNoReturn) { @@ -475,11 +475,11 @@ void Outliner::createAnyPCHooks(CallHandler *TheCallHandler, Value *SymbolName = CPN::get(Type::getInt8PtrTy(Context)); CallInst *JumpToSymbol = getMarker(BB, "jump_to_symbol"); - auto [Summary, _] = getCallSiteInfo(OutlinedFunction->Address, - BB, - nullptr, - JumpToSymbol, - MetaAddress::invalid()); + auto &&[Summary, _] = getCallSiteInfo(OutlinedFunction->Address, + BB, + nullptr, + JumpToSymbol, + MetaAddress::invalid()); if (JumpToSymbol != nullptr) { SymbolName = JumpToSymbol->getArgOperand(0); diff --git a/lib/FunctionIsolation/EnforceABI.cpp b/lib/FunctionIsolation/EnforceABI.cpp index bc08f1cfc..96784ea2c 100644 --- a/lib/FunctionIsolation/EnforceABI.cpp +++ b/lib/FunctionIsolation/EnforceABI.cpp @@ -186,7 +186,7 @@ bool EnforceABI::epilogue() { eraseFromParent(OldFunction); // Quick and dirty DCE - for (auto [_, F] : OldToNew) + for (auto &&[_, F] : OldToNew) if (not F->isDeclaration()) EliminateUnreachableBlocks(*F, nullptr, false); @@ -206,7 +206,7 @@ getLLVMReturnTypeAndArguments(llvm::Module *M, const UsedRegisters &Registers) { return IntegerType::getIntNTy(Context, 8 * model::Register::getSize(V)); }; - auto [ArgumentRegisters, ReturnValueRegisters] = Registers; + auto &&[ArgumentRegisters, ReturnValueRegisters] = Registers; std::ranges::copy(ArgumentRegisters | std::views::transform(IntoLLVMType), std::back_inserter(ArgumentsTypes)); std::ranges::copy(ReturnValueRegisters | std::views::transform(IntoLLVMType), @@ -251,8 +251,8 @@ Function *EnforceABI::recreateFunction(Function &OldFunction, const abi::FunctionType::UsedRegisters &Registers) { // Create new function - auto [NewReturnType, NewArguments] = getLLVMReturnTypeAndArguments(&M, - Registers); + auto &&[NewReturnType, + NewArguments] = getLLVMReturnTypeAndArguments(&M, Registers); auto *Result = changeFunctionType(OldFunction, NewReturnType, NewArguments); revng_assert(Result->arg_size() == Registers.Arguments.size()); @@ -300,7 +300,7 @@ void EnforceABI::createPrologue(Function *NewFunction, SmallVector, 8> ReturnCSVs; // We sort arguments by their CSV name - auto [ArgumentRegisters, ReturnValueRegisters] = UsedRegisters; + auto &&[ArgumentRegisters, ReturnValueRegisters] = UsedRegisters; for (model::Register::Values Register : ArgumentRegisters) ArgumentCSVs.push_back(getCSVOrUndef(&M, Register).second); for (model::Register::Values Register : ReturnValueRegisters) @@ -318,7 +318,7 @@ void EnforceABI::createPrologue(Function *NewFunction, if (auto *Return = dyn_cast(BB.getTerminator())) { IRBuilder<> Builder(Return); std::vector ReturnValues; - for (auto [Type, ReturnCSV] : ReturnCSVs) + for (auto &&[Type, ReturnCSV] : ReturnCSVs) ReturnValues.push_back(Builder.CreateLoad(Type, ReturnCSV)); if (ReturnValues.size() == 1) @@ -436,7 +436,8 @@ CallInst *EnforceABI::generateCall(IRBuilder<> &Builder, // Create a new `indirect_placeholder` function with the specific function // type we need Value *PC = GCBI.programCounterHandler()->loadJumpablePC(Builder); - auto [ReturnType, Arguments] = getLLVMReturnTypeAndArguments(&M, Registers); + auto &&[ReturnType, Arguments] = getLLVMReturnTypeAndArguments(&M, + Registers); auto *NewType = FunctionType::get(ReturnType, Arguments, false); Callee = toFunctionPointer(Builder, PC, NewType); } else { diff --git a/lib/FunctionIsolation/InvokeIsolatedFunctions.cpp b/lib/FunctionIsolation/InvokeIsolatedFunctions.cpp index dcaf4aa49..a1ca2e44a 100644 --- a/lib/FunctionIsolation/InvokeIsolatedFunctions.cpp +++ b/lib/FunctionIsolation/InvokeIsolatedFunctions.cpp @@ -172,8 +172,8 @@ public: // Add the personality to the root function RootFunction->setPersonalityFn(PersonalityFunction); - for (auto [_, T] : Map) { - auto [ModelF, BB, F] = T; + for (auto &&[_, T] : Map) { + auto &&[ModelF, BB, F] = T; // Create a new trampoline entry block and substitute it to the old entry // block diff --git a/lib/FunctionIsolation/IsolateFunctions.cpp b/lib/FunctionIsolation/IsolateFunctions.cpp index 78ab16dd5..873ef2607 100644 --- a/lib/FunctionIsolation/IsolateFunctions.cpp +++ b/lib/FunctionIsolation/IsolateFunctions.cpp @@ -353,7 +353,7 @@ void printAddressListComparison(const LeftMap &ExpectedAddresses, const RightMap &ActualAddresses) { // Compare expected and actual if (TheLogger.isEnabled()) { - for (auto [ExpectedAddress, ActualAddress] : + for (auto &&[ExpectedAddress, ActualAddress] : zipmap_range(ExpectedAddresses, ActualAddresses)) { if (ExpectedAddress == nullptr) { TheLogger << "Warning: "; diff --git a/lib/FunctionIsolation/PromoteCSVs.cpp b/lib/FunctionIsolation/PromoteCSVs.cpp index d51d4666e..0f96e2b37 100644 --- a/lib/FunctionIsolation/PromoteCSVs.cpp +++ b/lib/FunctionIsolation/PromoteCSVs.cpp @@ -246,7 +246,7 @@ void PromoteCSVs::wrap(CallInst *Call, // Initialize the new set of arguments with the old ones SmallVector NewArguments; - for (auto [Argument, Type] : zip(Call->args(), HelperType->params())) + for (auto &&[Argument, Type] : zip(Call->args(), HelperType->params())) NewArguments.push_back(Builder.CreateBitOrPointerCast(Argument, Type)); // Add arguments read @@ -520,7 +520,7 @@ CSVsUsageMap PromoteCSVs::getUsedCSVs(ArrayRef CallsRange) { // Populate results set for (auto &[Label, Value] : AnalysisResult) { auto &FunctionDescriptor = Result.Functions[Label->F]; - for (auto [IsWrite, CSV] : Value.OutValue) { + for (auto &&[IsWrite, CSV] : Value.OutValue) { if (IsWrite) FunctionDescriptor.Written.push_back(CSV); else diff --git a/lib/GraphLayout/SugiyamaStyle/Compute.cpp b/lib/GraphLayout/SugiyamaStyle/Compute.cpp index 777827a72..a7bb29375 100644 --- a/lib/GraphLayout/SugiyamaStyle/Compute.cpp +++ b/lib/GraphLayout/SugiyamaStyle/Compute.cpp @@ -46,7 +46,7 @@ bool sugiyama::detail::computeImpl(InternalGraph &Graph, std::swap(Node->Size.W, Node->Size.H); std::swap(Node->Center.X, Node->Center.Y); - for (auto [_, Edge] : Node->successor_edges()) + for (auto &&[_, Edge] : Node->successor_edges()) if (!Edge->isVirtual()) for (auto &[X, Y] : Edge->getPath()) std::swap(X, Y); @@ -57,7 +57,7 @@ bool sugiyama::detail::computeImpl(InternalGraph &Graph, for (auto *Node : Graph.nodes()) { Node->Center.Y = -Node->Center.Y; - for (auto [_, Edge] : Node->successor_edges()) + for (auto &&[_, Edge] : Node->successor_edges()) if (!Edge->isVirtual()) for (auto &[X, Y] : Edge->getPath()) Y = -Y; @@ -66,7 +66,7 @@ bool sugiyama::detail::computeImpl(InternalGraph &Graph, for (auto *Node : Graph.nodes()) { Node->Center.X = -Node->Center.X; - for (auto [_, Edge] : Node->successor_edges()) + for (auto &&[_, Edge] : Node->successor_edges()) if (!Edge->isVirtual()) for (auto &[X, Y] : Edge->getPath()) X = -X; diff --git a/lib/GraphLayout/SugiyamaStyle/EdgeRouting.cpp b/lib/GraphLayout/SugiyamaStyle/EdgeRouting.cpp index dc57d276d..c98b6c317 100644 --- a/lib/GraphLayout/SugiyamaStyle/EdgeRouting.cpp +++ b/lib/GraphLayout/SugiyamaStyle/EdgeRouting.cpp @@ -18,7 +18,7 @@ CornerContainer routeBackwardsCorners(InternalGraph &Graph, // To keep the hierarchy consistent, V-shapes were added using forward // direction. So that's what we're going to use to detect them. for (auto *From : Graph.nodes()) - for (auto [To, Label] : From->successor_edges()) + for (auto &&[To, Label] : From->successor_edges()) if (!From->IsVirtual != !To->IsVirtual && !Label->IsBackwards) CornerEdges.emplace_back(From, To, *Label); @@ -55,7 +55,7 @@ CornerContainer routeBackwardsCorners(InternalGraph &Graph, + LaneIndex * EdgeDistance; auto &From = Edge.From; - for (auto [To, Label] : From->successor_edges()) { + for (auto &&[To, Label] : From->successor_edges()) { auto FromTop = From->Center.Y + From->Size.H / 2; auto ToTop = To->Center.Y + To->Size.H / 2; @@ -116,7 +116,7 @@ CornerContainer routeBackwardsCorners(InternalGraph &Graph, Edge.To->Center.Y += MarginSize + LaneIndex * EdgeDistance; auto &To = Edge.To; - for (auto [From, Label] : To->predecessor_edges()) { + for (auto &&[From, Label] : To->predecessor_edges()) { auto FromBottom = From->Center.Y - From->Size.H / 2; auto ToBottom = To->Center.Y - To->Size.H / 2; @@ -231,7 +231,7 @@ void restoreEdgeDirections(InternalGraph &Graph) { for (auto *From : Graph.nodes()) { for (auto Iterator = From->successor_edges().begin(); Iterator != From->successor_edges().end();) { - if (auto [To, Label] = *Iterator; Label->IsBackwards) { + if (auto &&[To, Label] = *Iterator; Label->IsBackwards) { Label->IsBackwards = !Label->IsBackwards; To->addSuccessor(From, std::move(*Label)); Iterator = From->removeSuccessor(Iterator); @@ -250,7 +250,7 @@ OrderedEdgeContainer orderEdges(InternalGraph &Graph, RoutableEdgeMaker Maker(Ranks, Lanes, std::move(Prerouted)); for (auto *From : Graph.nodes()) { if (!From->IsVirtual) { - for (auto [To, Label] : From->successor_edges()) { + for (auto &&[To, Label] : From->successor_edges()) { Result.emplace_back(Maker.make(From, To, *Label)); if (To->IsVirtual) { for (auto *Current : llvm::depth_first(To)) { @@ -263,7 +263,7 @@ OrderedEdgeContainer orderEdges(InternalGraph &Graph, && Graph.hasEntryNode && Graph.getEntryNode() && Graph.getEntryNode()->IsVirtual)); - auto [Next, NextLabel] = *Current->successor_edges().begin(); + auto &&[Next, NextLabel] = *Current->successor_edges().begin(); Result.emplace_back(Maker.make(Current, Next, *NextLabel)); } } diff --git a/lib/GraphLayout/SugiyamaStyle/GraphPreparation.cpp b/lib/GraphLayout/SugiyamaStyle/GraphPreparation.cpp index 1a7929e86..4b770352f 100644 --- a/lib/GraphLayout/SugiyamaStyle/GraphPreparation.cpp +++ b/lib/GraphLayout/SugiyamaStyle/GraphPreparation.cpp @@ -80,7 +80,7 @@ static void ensureSingleEntry(InternalGraph &Graph, static void convertToDAG(InternalGraph &Graph) { ensureSingleEntry(Graph); - for (auto [From, To] : getBackedges(&Graph)) { + for (auto &&[From, To] : getBackedges(&Graph)) { for (auto Iterator = From->successor_edges_begin(); Iterator != From->successor_edges_end();) { if (To == Iterator->Neighbor) { @@ -112,7 +112,7 @@ static std::vector pickLongEdges(InternalGraph &Graph, std::vector Result; for (auto *From : Graph.nodes()) - for (auto [To, Label] : From->successor_edges()) + for (auto &&[To, Label] : From->successor_edges()) if (delta(From, To, Ranks) > RankDelta(1)) Result.emplace_back(From, To, *Label); @@ -272,7 +272,7 @@ void partitionArtificialBackwardsEdges(InternalGraph &Graph, auto *From = *std::next(Graph.nodes().begin(), NodeIndex); for (auto EdgeIterator = From->successor_edges_rbegin(); EdgeIterator != From->successor_edges_rend();) { - auto [To, Original] = *EdgeIterator; + auto &&[To, Original] = *EdgeIterator; if (From->IsVirtual != To->IsVirtual && Original->IsBackwards == true) { // Move the label out, so that the original edge can be deleted right // away. If this is not done, inserting new edges might cause @@ -329,7 +329,7 @@ void partitionOriginalBackwardsEdges(InternalGraph &Graph, auto *From = *std::next(Graph.nodes().begin(), NodeIndex); for (auto EdgeIterator = From->successor_edges_rbegin(); EdgeIterator != From->successor_edges_rend();) { - auto [To, Original] = *EdgeIterator; + auto &&[To, Original] = *EdgeIterator; if (!From->IsVirtual && !To->IsVirtual && Original->IsBackwards == true) { InternalEdge Label = std::move(*Original); EdgeIterator = From->removeSuccessor(EdgeIterator); diff --git a/lib/GraphLayout/SugiyamaStyle/HorizontalPositions.cpp b/lib/GraphLayout/SugiyamaStyle/HorizontalPositions.cpp index 09f83da32..e0d7b6b2a 100644 --- a/lib/GraphLayout/SugiyamaStyle/HorizontalPositions.cpp +++ b/lib/GraphLayout/SugiyamaStyle/HorizontalPositions.cpp @@ -40,7 +40,7 @@ void setHorizontalCoordinates(const LayerContainer &Layers, MinimalLayerWidths[Index] += Node->Size.W + MarginSize; for (size_t Iteration = 0; Iteration < IterationCount; ++Iteration) { - for (auto [Child, Parent] : LinearSegments) + for (auto &&[Child, Parent] : LinearSegments) if (Child->Center.X > Parent->Center.X) Parent->Center.X = Child->Center.X; else @@ -78,7 +78,7 @@ void setHorizontalCoordinates(const LayerContainer &Layers, // graph, these are the segments that can be moved freely. std::map FreeSegments; - for (auto [Child, Parent] : LinearSegments) { + for (auto &&[Child, Parent] : LinearSegments) { auto const &ChildPosition = Layout.at(Child); auto ChildLayerSize = Layers.at(ChildPosition.Layer).size(); if (ChildLayerSize == ChildPosition.Index + 1) { diff --git a/lib/GraphLayout/SugiyamaStyle/InternalCompute.h b/lib/GraphLayout/SugiyamaStyle/InternalCompute.h index eece41d5c..56281ae37 100644 --- a/lib/GraphLayout/SugiyamaStyle/InternalCompute.h +++ b/lib/GraphLayout/SugiyamaStyle/InternalCompute.h @@ -123,7 +123,7 @@ bool computeInternal(InternalGraph &Graph, const Configuration &Configuration) { // by the router so they can be treated in a special way. // For more details on this, see `routeBackwardsCorners` function. bool ShouldClassify = !Configuration.UseSimpleTreeOptimization; - auto [Ranks, Classified] = prepareGraph(Graph, !ShouldClassify); + auto &&[Ranks, Classified] = prepareGraph(Graph, !ShouldClassify); // Try to select an optimal node permutation per layer. // NOTE: since this is the part with the highest complexity, it needs extra diff --git a/lib/GraphLayout/SugiyamaStyle/LaneDistribution.cpp b/lib/GraphLayout/SugiyamaStyle/LaneDistribution.cpp index c8c641c05..c74363eb4 100644 --- a/lib/GraphLayout/SugiyamaStyle/LaneDistribution.cpp +++ b/lib/GraphLayout/SugiyamaStyle/LaneDistribution.cpp @@ -36,10 +36,10 @@ public: bool operator<(const SortableEdge &Another) const { if (IsFacingRight == Another.IsFacingRight) { // Both edges face in the same direction. - auto [LHSMin, LHSMax] = std::minmax(Edge.From->Center.X, - Edge.To->Center.X); - auto [RHSMin, RHSMax] = std::minmax(Another.Edge.From->Center.X, - Another.Edge.To->Center.X); + auto &&[LHSMin, LHSMax] = std::minmax(Edge.From->Center.X, + Edge.To->Center.X); + auto &&[RHSMin, RHSMax] = std::minmax(Another.Edge.From->Center.X, + Another.Edge.To->Center.X); if (IsFacingRight) return LHSMax == RHSMax ? LHSMin < RHSMin : LHSMax < RHSMax; @@ -78,7 +78,7 @@ LaneContainer assignLanes(InternalGraph &Graph, // Calculate the number of lanes needed for each layer for (auto *From : Graph.nodes()) { - for (auto [To, Label] : From->successor_edges()) { + for (auto &&[To, Label] : From->successor_edges()) { // If the ends of an edge are not a part of the same linear segment or // their horizontal coordinates are not aligned, a bend is necessary. if (LinearSegments.at(From) != LinearSegments.at(To) @@ -117,8 +117,8 @@ LaneContainer assignLanes(InternalGraph &Graph, auto &NodeExits = Result.Exits[Node]; for (size_t ExitRank = 0; ExitRank < Neighbors.size(); ExitRank++) { - auto [_, Success] = NodeExits.try_emplace(Neighbors[ExitRank].view(), - ExitRank); + auto &&[_, Success] = NodeExits.try_emplace(Neighbors[ExitRank].view(), + ExitRank); revng_assert(Success); } } @@ -129,8 +129,8 @@ LaneContainer assignLanes(InternalGraph &Graph, auto &NodeEntries = Result.Entries[Node]; for (size_t EntryRank = 0; EntryRank < Neighbors.size(); EntryRank++) { - auto [_, Success] = NodeEntries.try_emplace(Neighbors[EntryRank].view(), - EntryRank); + auto &&[_, Success] = NodeEntries.try_emplace(Neighbors[EntryRank].view(), + EntryRank); revng_assert(Success); } } diff --git a/lib/GraphLayout/SugiyamaStyle/PermutationSelection.cpp b/lib/GraphLayout/SugiyamaStyle/PermutationSelection.cpp index c1a3a2888..db498988b 100644 --- a/lib/GraphLayout/SugiyamaStyle/PermutationSelection.cpp +++ b/lib/GraphLayout/SugiyamaStyle/PermutationSelection.cpp @@ -473,7 +473,7 @@ static std::unordered_map rankSubtrees(InternalGraph &Graph) { revng_assert(Iterator != Result.end()); CurrentRank += Iterator->second; } - auto [_, Success] = Result.try_emplace(CurrentNode, CurrentRank); + auto &&[_, Success] = Result.try_emplace(CurrentNode, CurrentRank); revng_assert(Success); } } @@ -535,7 +535,7 @@ LayerContainer selectSimpleTreePermutation(InternalGraph &Graph, // Update the last layer lookup table. LastLayerLookup.clear(); for (size_t Index = 0; Index < Layer.size(); ++Index) { - auto [_, Success] = LastLayerLookup.try_emplace(Layer[Index], Index); + auto &&[_, Success] = LastLayerLookup.try_emplace(Layer[Index], Index); revng_assert(Success); } } diff --git a/lib/ImportFromC/HeaderToModel.cpp b/lib/ImportFromC/HeaderToModel.cpp index 920656548..b34fce958 100644 --- a/lib/ImportFromC/HeaderToModel.cpp +++ b/lib/ImportFromC/HeaderToModel.cpp @@ -710,7 +710,7 @@ bool DeclVisitor::VisitFunctionDecl(const clang::FunctionDecl *FD) { // TODO: remember/clone StackFrameType as well. - auto [_, Prototype] = Model->recordNewType(std::move(NewType)); + auto &&[_, Prototype] = Model->recordNewType(std::move(NewType)); ModelFunction.Prototype() = Prototype; return true; @@ -756,7 +756,7 @@ bool DeclVisitor::VisitTypedefDecl(const TypedefDecl *D) { "type of the typedef.\n"); return false; } - auto [ID, Kind] = *Type; + auto &&[ID, Kind] = *Type; auto NewTypedef = model::makeTypeDefinition(); if (AnalysisOption == ImportFromCOption::EditType) NewTypedef->ID() = ID; @@ -788,7 +788,7 @@ bool DeclVisitor::VisitFunctionPrototype(const FunctionProtoType *FP, makeTypeDefinition() : makeTypeDefinition(); - auto [ID, Kind] = *Type; + auto &&[ID, Kind] = *Type; if (AnalysisOption == ImportFromCOption::EditType) NewType->ID() = ID; @@ -866,7 +866,7 @@ bool DeclVisitor::handleStructType(const clang::RecordDecl *RD) { return false; } - auto [ID, Kind] = *Type; + auto &&[ID, Kind] = *Type; auto NewType = makeTypeDefinition(); if (AnalysisOption == ImportFromCOption::EditType) NewType->ID() = ID; @@ -1038,7 +1038,7 @@ bool DeclVisitor::handleUnionType(const clang::RecordDecl *RD) { return false; } - auto [ID, Kind] = *Type; + auto &&[ID, Kind] = *Type; auto NewType = makeTypeDefinition(); if (AnalysisOption == ImportFromCOption::EditType) NewType->ID() = ID; diff --git a/lib/ImportFromC/ImportFromCAnalysis.cpp b/lib/ImportFromC/ImportFromCAnalysis.cpp index 3335079f2..d1e94aec7 100644 --- a/lib/ImportFromC/ImportFromCAnalysis.cpp +++ b/lib/ImportFromC/ImportFromCAnalysis.cpp @@ -102,7 +102,7 @@ struct ImportFromCAnalysis { } else { if (auto L = pipeline::locationFromString(revng::ranks::Function, LocationToEdit)) { - auto [Key] = L->at(revng::ranks::Function); + auto &&[Key] = L->at(revng::ranks::Function); auto Iterator = Model->Functions().find(Key); if (Iterator == Model->Functions().end()) { return revng::createError("Couldn't find the function " @@ -113,7 +113,7 @@ struct ImportFromCAnalysis { TheOption = ImportFromCOption::EditFunctionPrototype; } else if (auto L = pipeline::locationFromString(RRanks::TypeDefinition, LocationToEdit)) { - auto [Key, Kind] = L->at(revng::ranks::TypeDefinition); + auto &&[Key, Kind] = L->at(revng::ranks::TypeDefinition); auto Iterator = Model->TypeDefinitions().find({ Key, Kind }); if (Iterator == Model->TypeDefinitions().end()) { return revng::createError("Couldn't find the type " + LocationToEdit); diff --git a/lib/InitModelTypes/InitModelTypes.cpp b/lib/InitModelTypes/InitModelTypes.cpp index bbe8a0390..402f350f9 100644 --- a/lib/InitModelTypes/InitModelTypes.cpp +++ b/lib/InitModelTypes/InitModelTypes.cpp @@ -293,7 +293,7 @@ static void handleCallInstruction(const llvm::CallInst *Call, const auto ExtractedValues = getExtractedValuesFromInstruction(Call); revng_assert(ReturnedTypes.size() == ExtractedValues.size()); - for (auto [Type, ExtractedSet] : zip(ReturnedTypes, ExtractedValues)) { + for (auto &&[Type, ExtractedSet] : zip(ReturnedTypes, ExtractedValues)) { revng_assert(Type->isScalar()); // Each extractedSet contains the set of instructions that extract the diff --git a/lib/Lift/CodeGenerator.cpp b/lib/Lift/CodeGenerator.cpp index 26c84addf..05c91b248 100644 --- a/lib/Lift/CodeGenerator.cpp +++ b/lib/Lift/CodeGenerator.cpp @@ -89,7 +89,7 @@ public: void drop() { SmallVector ToErase; - for (auto [T, F] : Map) { + for (auto &&[T, F] : Map) { for (User *U : F->users()) { auto *Call = cast(U); Call->replaceAllUsesWith(Call->getArgOperand(0)); @@ -100,7 +100,7 @@ public: for (CallInst *Call : ToErase) eraseFromParent(Call); - for (auto [T, F] : Map) + for (auto &&[T, F] : Map) eraseFromParent(F); Map.clear(); diff --git a/lib/Lift/InstructionTranslator.cpp b/lib/Lift/InstructionTranslator.cpp index 64752370c..064c41fdd 100644 --- a/lib/Lift/InstructionTranslator.cpp +++ b/lib/Lift/InstructionTranslator.cpp @@ -800,7 +800,7 @@ IT::translate(PTCInstruction *Instr, MetaAddress PC, MetaAddress NextPC) { void IT::registerDirectJumps() { for (BasicBlock *ExitBB : ExitBlocks) { - auto [Result, NextPC] = PCH->getUniqueJumpTarget(ExitBB); + auto &&[Result, NextPC] = PCH->getUniqueJumpTarget(ExitBB); if (Result == NextJumpTarget::Unique and JumpTargets.isPC(NextPC) and not JumpTargets.hasJT(NextPC)) { JumpTargets.registerJT(NextPC, JTReason::DirectJump); diff --git a/lib/Lift/JumpTargetManager.cpp b/lib/Lift/JumpTargetManager.cpp index 885eebcaa..15c2dff2d 100644 --- a/lib/Lift/JumpTargetManager.cpp +++ b/lib/Lift/JumpTargetManager.cpp @@ -241,7 +241,7 @@ bool TDBP::pinConstantStore(Function &F) { revng_assert(getCalledFunction(Call) == ExitTB); // Look for the last write to the PC - auto [Result, NextPC] = PCH->getUniqueJumpTarget(Call->getParent()); + auto &&[Result, NextPC] = PCH->getUniqueJumpTarget(Call->getParent()); switch (Result) { case NextJumpTarget::Unique: @@ -805,7 +805,7 @@ void JumpTargetManager::translateIndirectJumps() { // Look for the last write to the PC BasicBlock *CallBB = Call->getParent(); - auto [Result, NextPC] = PCH->getUniqueJumpTarget(CallBB); + auto &&[Result, NextPC] = PCH->getUniqueJumpTarget(CallBB); if (NextPC.isValid() and isExecutableAddress(NextPC)) { revng_check(Result != NextJumpTarget::Unique diff --git a/lib/Lift/RootAnalyzer.cpp b/lib/Lift/RootAnalyzer.cpp index ddcce9725..0cd702e03 100644 --- a/lib/Lift/RootAnalyzer.cpp +++ b/lib/Lift/RootAnalyzer.cpp @@ -372,7 +372,7 @@ Function *RootAnalyzer::createTemporaryRoot(Function *TheFunction, OptimizedFunction = CloneFunction(TheFunction, OldToNew); // Restore callees after function_call - for (auto [U, BB] : Undo) + for (auto &&[U, BB] : Undo) U->set(BB); // Force canonical register values at the beginning of each callee diff --git a/lib/Lift/VariableManager.h b/lib/Lift/VariableManager.h index bddba5fb5..6354d6d8c 100644 --- a/lib/Lift/VariableManager.h +++ b/lib/Lift/VariableManager.h @@ -50,7 +50,7 @@ public: llvm::Instruction *load(llvm::IRBuilder<> &Builder, unsigned TemporaryId) { using namespace llvm; - auto [IsNew, V] = getOrCreate(TemporaryId, true); + auto &&[IsNew, V] = getOrCreate(TemporaryId, true); if (V == nullptr) return nullptr; diff --git a/lib/Model/Binary.cpp b/lib/Model/Binary.cpp index 9c409c531..46c5e377f 100644 --- a/lib/Model/Binary.cpp +++ b/lib/Model/Binary.cpp @@ -92,7 +92,7 @@ model::Binary::recordNewType(model::UpcastableTypeDefinition &&T) { T->ID() = getAvailableTypeID(); - auto [It, Success] = TypeDefinitions().insert(T); + auto &&[It, Success] = TypeDefinitions().insert(T); revng_assert(Success); return { **It, makeType((*It)->key()) }; diff --git a/lib/Model/Importer/Binary/ELFImporter.cpp b/lib/Model/Importer/Binary/ELFImporter.cpp index fbee7d981..f7ee1af54 100644 --- a/lib/Model/Importer/Binary/ELFImporter.cpp +++ b/lib/Model/Importer/Binary/ELFImporter.cpp @@ -496,8 +496,8 @@ void ELFImporter::findMissingTypes(object::ELFFile &TheELF, revng_assert(Iterator != ModelsOfLibraries.end()); auto NewCopier = std::make_unique(Iterator->second, Model); - auto [Result, Success] = TypeCopiers.emplace(Name.str(), - std::move(NewCopier)); + auto &&[Result, Success] = TypeCopiers.emplace(Name.str(), + std::move(NewCopier)); revng_assert(Success); return *Result->second; }; diff --git a/lib/Model/Importer/Binary/MachOImporter.cpp b/lib/Model/Importer/Binary/MachOImporter.cpp index 7c07826a6..c45078d73 100644 --- a/lib/Model/Importer/Binary/MachOImporter.cpp +++ b/lib/Model/Importer/Binary/MachOImporter.cpp @@ -326,7 +326,7 @@ void MachOImporter::parseMachOSegment(ArrayRef RawDataRef, // TODO: replace the following with `populateSegmentTypeStruct`, when // LC_SYMTAB and LC_DYSYMTAB parsing is available - auto [Struct, Type] = Model->makeStructDefinition(Segment.VirtualSize()); + auto &&[Struct, Type] = Model->makeStructDefinition(Segment.VirtualSize()); Struct.CanContainCode() = Segment.IsExecutable(); Segment.Type() = std::move(Type); diff --git a/lib/Model/Importer/Binary/PECOFFImporter.cpp b/lib/Model/Importer/Binary/PECOFFImporter.cpp index 09f25e1c6..581005d50 100644 --- a/lib/Model/Importer/Binary/PECOFFImporter.cpp +++ b/lib/Model/Importer/Binary/PECOFFImporter.cpp @@ -131,7 +131,7 @@ Error PECOFFImporter::parseSectionsHeaders() { // TODO: replace the following with `populateSegmentTypeStruct`, when // symbol table and dynamic symbol table parsing is finalized - auto [Struct, Type] = Model->makeStructDefinition(Segment.VirtualSize()); + auto &&[Struct, Type] = Model->makeStructDefinition(Segment.VirtualSize()); Struct.CanContainCode() = Segment.IsExecutable(); Segment.Type() = std::move(Type); @@ -461,8 +461,8 @@ void PECOFFImporter::findMissingTypes(const ImporterOptions &Opts) { revng_assert(Iterator != ModelsOfLibraries.end()); auto NewCopier = std::make_unique(Iterator->second, Model); - auto [Result, Success] = TypeCopiers.emplace(Name.str(), - std::move(NewCopier)); + auto &&[Result, Success] = TypeCopiers.emplace(Name.str(), + std::move(NewCopier)); revng_assert(Success); return *Result->second; }; diff --git a/lib/Model/Importer/Binary/SegmentImportHelpers.h b/lib/Model/Importer/Binary/SegmentImportHelpers.h index 01dc5e6dd..632de302d 100644 --- a/lib/Model/Importer/Binary/SegmentImportHelpers.h +++ b/lib/Model/Importer/Binary/SegmentImportHelpers.h @@ -91,8 +91,8 @@ populateSegmentTypeStruct(model::Binary &Binary, // Create a struct for the segment revng_assert(Segment.VirtualSize() > 0); - auto [SegmentStruct, - SegmentType] = Binary.makeStructDefinition(Segment.VirtualSize()); + auto &&[SegmentStruct, + SegmentType] = Binary.makeStructDefinition(Segment.VirtualSize()); SegmentStruct.CanContainCode() = SegmentIsExecutable; for (const auto &Section : Sections) { @@ -106,7 +106,7 @@ populateSegmentTypeStruct(model::Binary &Binary, continue; // Create a struct for each section - auto [SectionStruct, Type] = Binary.makeStructDefinition(Section.Size); + auto &&[SectionStruct, Type] = Binary.makeStructDefinition(Section.Size); SectionStruct.CanContainCode() = (SegmentIsExecutable and Section.CanContainCode); diff --git a/lib/Model/Importer/DebugInfo/DwarfImporter.cpp b/lib/Model/Importer/DebugInfo/DwarfImporter.cpp index eeeb9333b..2d58d6355 100644 --- a/lib/Model/Importer/DebugInfo/DwarfImporter.cpp +++ b/lib/Model/Importer/DebugInfo/DwarfImporter.cpp @@ -294,7 +294,7 @@ private: } void createInvalidPrimitivePlaceholder(const DWARFDie &Die) { - auto [Definition, Type] = Model->makeTypedefDefinition(); + auto &&[Definition, Type] = Model->makeTypedefDefinition(); record(Die, std::move(Type), false); InvalidPrimitives.insert(&Definition); } @@ -677,7 +677,7 @@ private: } auto Tag = Die.getTag(); - auto [SearchResult, Type] = findType(Die); + auto &&[SearchResult, Type] = findType(Die); switch (SearchResult) { case TypeSearchResult::Absent: { @@ -908,7 +908,7 @@ private: void purgeUnresolvedPlaceholders() { std::set ToDrop; - for (const auto [_, Type] : Placeholders) + for (auto &&[_, Type] : Placeholders) ToDrop.insert(Type); unsigned DroppedTypes = dropTypesDependingOnDefinitions(Model, ToDrop); diff --git a/lib/Model/Importer/DebugInfo/PDBImporter.cpp b/lib/Model/Importer/DebugInfo/PDBImporter.cpp index 094be2b78..c5b6ce73b 100644 --- a/lib/Model/Importer/DebugInfo/PDBImporter.cpp +++ b/lib/Model/Importer/DebugInfo/PDBImporter.cpp @@ -563,7 +563,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, auto Pointer = model::PointerType::make(std::move(ReferencedTypeFromModel), getPointerSize(Ptr.getPointerKind())); - auto [Typedef, NewType] = Model->makeTypedefDefinition(); + auto &&[Typedef, NewType] = Model->makeTypedefDefinition(); Typedef.UnderlyingType() = std::move(Pointer); ProcessedTypes[CurrentTypeIndex] = std::move(NewType); @@ -587,7 +587,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, const uint64_t ArraySize = Array.getSize() / *MaybeSize; auto NewA = model::ArrayType::make(std::move(ElementTypeFromModel), ArraySize); - auto [_, NewType] = Model->makeTypedefDefinition(std::move(NewA)); + auto &&[_, NewType] = Model->makeTypedefDefinition(std::move(NewA)); ProcessedTypes[CurrentTypeIndex] = std::move(NewType); } @@ -607,7 +607,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, } else { using ModifierOs = ModifierOptions; if ((Modifier.getModifiers() & ModifierOs::Const) != ModifierOs::None) { - auto [_, NewType] = Model->makeTypedefDefinition(std::move(ModelType)); + auto &&[_, NewType] = Model->makeTypedefDefinition(std::move(ModelType)); NewType->IsConst() = true; ProcessedTypes[CurrentTypeIndex] = std::move(NewType); } @@ -669,12 +669,12 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, // 0-sized structs are typedef'ed to void. It can happen that there is // an incomplete struct type. model::UpcastableType Void = model::PrimitiveType::makeVoid(); - auto [Typedef, NewType] = Model->makeTypedefDefinition(std::move(Void)); + auto &&[Typedef, NewType] = Model->makeTypedefDefinition(std::move(Void)); Typedef.OriginalName() = Class.getName(); ProcessedTypes[CurrentTypeIndex] = std::move(NewType); } else { // Pre-create the type that is being referenced by this type. - auto [Struct, NewType] = Model->makeStructDefinition(); + auto &&[Struct, NewType] = Model->makeStructDefinition(); Struct.OriginalName() = Class.getName(); Struct.Size() = ForwardTypeSize; ProcessedTypes[CurrentTypeIndex] = std::move(NewType); @@ -749,7 +749,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, } if (not WasReferenced) { - auto [_, NewType] = Model->recordNewType(std::move(NewDefinition)); + auto &&[_, NewType] = Model->recordNewType(std::move(NewDefinition)); ProcessedTypes[CurrentTypeIndex] = std::move(NewType); } else { TypeIndex ForwardRef = ForwardReferencedTypes[CurrentTypeIndex]; @@ -830,7 +830,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, } } - auto [_, NewType] = Model->recordNewType(std::move(NewDefinition)); + auto &&[_, NewType] = Model->recordNewType(std::move(NewDefinition)); ProcessedTypes[FnTypeIndex] = std::move(NewType); } } @@ -866,7 +866,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, EnumEntry.OriginalName() = Entry.getName().str(); } - auto [_, NewType] = Model->recordNewType(std::move(NewDefinition)); + auto &&[_, NewType] = Model->recordNewType(std::move(NewDefinition)); ProcessedTypes[CurrentTypeIndex] = std::move(NewType); return Error::success(); @@ -984,7 +984,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, } } - auto [_, NewType] = Model->recordNewType(std::move(NewDef)); + auto &&[_, NewType] = Model->recordNewType(std::move(NewDef)); ProcessedTypes[CurrentTypeIndex] = std::move(NewType); } @@ -1000,7 +1000,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, // Handle an empty union, similar to 0-sized structs. // Typedef it to void. model::UpcastableType Void = model::PrimitiveType::makeVoid(); - auto [Typedef, NewType] = Model->makeTypedefDefinition(std::move(Void)); + auto &&[Typedef, NewType] = Model->makeTypedefDefinition(std::move(Void)); Typedef.OriginalName() = Union.getName().str(); ProcessedTypes[CurrentTypeIndex] = std::move(NewType); @@ -1035,7 +1035,7 @@ Error PDBImporterTypeVisitor::visitKnownRecord(CVType &Record, } if (GeneratedAtLeastOneField) { - auto [_, NewType] = Model->recordNewType(std::move(NewDefinition)); + auto &&[_, NewType] = Model->recordNewType(std::move(NewDefinition)); ProcessedTypes[CurrentTypeIndex] = std::move(NewType); } @@ -1245,7 +1245,7 @@ PDBImporterTypeVisitor::createPrimitiveType(TypeIndex SimpleType) { // implemented in the msvc compiler. revng_abort("128-bit pointers are not supported for now."); model::UpcastableType Void = model::PrimitiveType::makeVoid(); - auto [_, Typedef] = Model->makeTypedefDefinition(std::move(Void)); + auto &&[_, Typedef] = Model->makeTypedefDefinition(std::move(Void)); return ProcessedTypes[SimpleType] = std::move(Typedef); } else { diff --git a/lib/Model/NameBuilder.cpp b/lib/Model/NameBuilder.cpp index bac956536..32a981995 100644 --- a/lib/Model/NameBuilder.cpp +++ b/lib/Model/NameBuilder.cpp @@ -100,7 +100,7 @@ llvm::Error model::NameBuilder::populateGlobalNamespace() { + ".\n"); } - auto [Iterator, Success] = GlobalNamespace->try_emplace(Name, Path); + auto &&[Iterator, Success] = GlobalNamespace->try_emplace(Name, Path); if (not Success) return makeDuplicateSymbolError(Name, Iterator->second, Path); } diff --git a/lib/Model/Pass/DeduplicateEquivalentTypes.cpp b/lib/Model/Pass/DeduplicateEquivalentTypes.cpp index 5f71cd812..c7e93abcd 100644 --- a/lib/Model/Pass/DeduplicateEquivalentTypes.cpp +++ b/lib/Model/Pass/DeduplicateEquivalentTypes.cpp @@ -256,7 +256,7 @@ private: Node *RightNode = RightIt->second; // Zip out edges of the node pair: consider the destinations. - for (auto [LeftSuccessor, RightSuccessor] : + for (auto &&[LeftSuccessor, RightSuccessor] : zip(LeftNode->successors(), RightNode->successors())) { revng_log(Log, "Visiting successor " << LeftSuccessor->T->ID()); if (not compareSuccessor(LeftToRight, @@ -269,7 +269,7 @@ private: } // All those in the map are strongly equivalent - for (auto [LeftNode, RightMode] : LeftToRight) + for (auto &&[LeftNode, RightMode] : LeftToRight) StrongEquivalence.unionSets(Left->T, Right->T); return true; diff --git a/lib/Model/Pass/PromoteOriginalName.cpp b/lib/Model/Pass/PromoteOriginalName.cpp index f896a4b48..a201f0f7b 100644 --- a/lib/Model/Pass/PromoteOriginalName.cpp +++ b/lib/Model/Pass/PromoteOriginalName.cpp @@ -76,7 +76,7 @@ private: Entry->CustomName() = Name; // Record new name as taken in the current namespace - auto [_, Inserted] = Namespace.insert(Name); + auto &&[_, Inserted] = Namespace.insert(Name); revng_assert(Inserted); } } diff --git a/lib/Model/TypeSystemPrinter.cpp b/lib/Model/TypeSystemPrinter.cpp index 7d045a5bd..b6934f428 100644 --- a/lib/Model/TypeSystemPrinter.cpp +++ b/lib/Model/TypeSystemPrinter.cpp @@ -194,7 +194,7 @@ void TypeSystemPrinter::dumpStructFields(llvm::raw_ostream &Out, // Struct fields are stacked vertically uint64_t LastOffset = 0; - for (auto [Index, Field] : llvm::enumerate(T->Fields())) { + for (auto &&[Index, Field] : llvm::enumerate(T->Fields())) { // Check if there's padding to be added before this field if (Field.Offset() > LastOffset) addStructField(Out, LastOffset, Field.Offset() - LastOffset, "padding"); @@ -223,7 +223,7 @@ void TypeSystemPrinter::dumpUnionFields(llvm::raw_ostream &Out, Out << ""; // Union fields are disposed horizontally - for (auto [Index, Field] : llvm::enumerate(T->Fields())) { + for (auto &&[Index, Field] : llvm::enumerate(T->Fields())) { auto Name = buildFieldName(*Field.Type()); const auto Size = Field.Type()->size().value_or(0); paddedCell(Out, Name + " (size: " + to_string(Size) + ")", Index); @@ -433,9 +433,9 @@ void TypeSystemPrinter::print(const model::TypeDefinition &T) { // Collect all the successors FieldList Fields = collectFields(CurType); - for (auto [Index, Field] : llvm::enumerate(Fields)) { + for (auto &&[Index, Field] : llvm::enumerate(Fields)) { FieldEdge Edge = buildFieldEdgeLabel(*Field); - auto [Label, DefinitionPointer, IsPointer] = Edge; + auto &&[Label, DefinitionPointer, IsPointer] = Edge; // Don't add edges for primitive types, as they would pollute the graph // and add no information regarding the type system structure diff --git a/lib/PTML/Doxygen.cpp b/lib/PTML/Doxygen.cpp index 024a1aa8a..a72621220 100644 --- a/lib/PTML/Doxygen.cpp +++ b/lib/PTML/Doxygen.cpp @@ -93,7 +93,7 @@ public: std::string Result; for (DoxygenLine &&Line : as_rvalue(Lines)) { - auto [ResultLine, CurrentSize] = line(); + auto &&[ResultLine, CurrentSize] = line(); if (Line.Tags.empty()) Result += toString(std::move(ResultLine)); @@ -417,7 +417,7 @@ gatherArgumentComments(const model::Binary &Binary, static constexpr llvm::StringRef FirstLine = "stack_args "; bool IsFirst = true; - for (auto [Name, Comment, Field] : Comments) { + for (auto &&[Name, Comment, Field] : Comments) { DoxygenLine &Line = Result.emplace_back(); if (IsFirst) { Line->emplace_back(DoxygenToken::Types::Keyword, diff --git a/lib/Pipeline/Runner.cpp b/lib/Pipeline/Runner.cpp index 76089c9e7..d5cd34bac 100644 --- a/lib/Pipeline/Runner.cpp +++ b/lib/Pipeline/Runner.cpp @@ -50,7 +50,8 @@ static Error getObjectives(Runner &Runner, Step *CurrentStep = &(Runner[EndingStepName]); while (CurrentStep != nullptr and not ToLoad.empty()) { ContainerToTargetsMap Output = ToLoad; - auto [Required, PipesExecutionEntries] = CurrentStep->analyzeGoals(ToLoad); + auto &&[Required, + PipesExecutionEntries] = CurrentStep->analyzeGoals(ToLoad); ToLoad = std::move(Required); ToExec.emplace_back(*CurrentStep, Output, @@ -165,10 +166,10 @@ PipelineFileMapping::parse(StringRef ToParse) { return revng::createError(Message, ToParse.str().c_str()); } - auto [StoragePath, ContainerPath] = ToParse.rsplit(':'); + auto &&[StoragePath, ContainerPath] = ToParse.rsplit(':'); auto Path = revng::FilePath::fromLocalStorage(StoragePath); - auto [StepName, ContainerName] = ContainerPath.split('/'); + auto &&[StepName, ContainerName] = ContainerPath.split('/'); return PipelineFileMapping(StepName, ContainerName, std::move(Path)); } diff --git a/lib/PromoteStackPointer/DetectStackSizePass.cpp b/lib/PromoteStackPointer/DetectStackSizePass.cpp index 234b9ab8e..08d0858cf 100644 --- a/lib/PromoteStackPointer/DetectStackSizePass.cpp +++ b/lib/PromoteStackPointer/DetectStackSizePass.cpp @@ -120,7 +120,7 @@ public: // * FunctionsStackInfo: we can use it to elect stack frame size // Elect stack arguments size for prototypes - for (auto [Prototype, UpperBound] : FunctionTypeStackArguments) + for (auto &&[Prototype, UpperBound] : FunctionTypeStackArguments) electStackArgumentsSize(*Prototype, UpperBound); // Now all prototypes have a definitive stack arguments size, we can elect diff --git a/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp b/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp index 8cf8c6732..b5ccd642a 100644 --- a/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp +++ b/lib/PromoteStackPointer/SegregateStackAccessesPass.cpp @@ -172,7 +172,7 @@ public: if (Map.size() >= 2) { auto FirstToSemiLast = llvm::make_range(Map.begin(), --Map.end()); auto SecondToLast = llvm::make_range(++Map.begin(), Map.end()); - for (auto [Current, Next] : llvm::zip(FirstToSemiLast, SecondToLast)) { + for (auto &&[Current, Next] : llvm::zip(FirstToSemiLast, SecondToLast)) { auto CurrentEnd = Current.first + static_cast(Current.second.first); auto NextStart = Next.first; @@ -185,7 +185,7 @@ public: template void dump(T &Stream) const { - for (auto [K, V] : Map) { + for (auto &&[K, V] : Map) { Stream << K << ": [" << V.first << ", " << getName(V.second) << "]\n"; } } @@ -385,7 +385,7 @@ public: eraseFromParent(I); // Erase original functions - for (auto [OldFunction, NewFunction] : OldToNew) + for (auto &&[OldFunction, NewFunction] : OldToNew) eraseFromParent(OldFunction); return true; @@ -470,7 +470,7 @@ private: Function &upgradeLocalFunction(Function *OldFunction) { using namespace abi::FunctionType; - auto [NewFunction, Layout] = getOrCreateNewLocalFunction(OldFunction); + auto &&[NewFunction, Layout] = getOrCreateNewLocalFunction(OldFunction); // Let the new function steal the body from the old function moveBlocksInto(*OldFunction, *NewFunction); @@ -582,7 +582,7 @@ private: setInsertPointToFirstNonAlloca(B, *NewFunction); // Handle arguments - for (auto [ModelArgument, NewArgument] : + for (auto &&[ModelArgument, NewArgument] : zip(ModelArguments, NewFunction->args())) { // Extract from the new argument the old arguments @@ -918,8 +918,8 @@ private: // std::map ArgumentToRegister; auto ArgumentRegisters = Layout.argumentRegisters(); - for (auto [Register, OldArgument] : zip(ArgumentRegisters, OldCall->args())) - ArgumentToRegister[Register] = OldArgument.get(); + for (auto &&[Register, OldArg] : zip(ArgumentRegisters, OldCall->args())) + ArgumentToRegister[Register] = OldArg.get(); // Check if it's a direct call auto *Callee = dyn_cast(OldCall->getCalledOperand()); @@ -957,7 +957,7 @@ private: copy(CalleeType->params(), std::back_inserter(LLVMArgumentTypes)); bool MessageEmitted = false; - for (auto [LLVMType, ModelArgument] : + for (auto &&[LLVMType, ModelArgument] : llvm::zip(LLVMArgumentTypes, Layout.Arguments)) { uint64_t NewSize = *ModelArgument.Type->size(); diff --git a/lib/RestructureCFG/BeautifyGHAST.cpp b/lib/RestructureCFG/BeautifyGHAST.cpp index 1a3a390fd..fbb0626b4 100644 --- a/lib/RestructureCFG/BeautifyGHAST.cpp +++ b/lib/RestructureCFG/BeautifyGHAST.cpp @@ -106,13 +106,13 @@ static RecursiveCoroutine hasSideEffects(ExprNode *Expr) { case ExprNode::NodeKind::NK_And: { auto *And = llvm::cast(Expr); - const auto [LHS, RHS] = And->getInternalNodes(); + auto &&[LHS, RHS] = And->getInternalNodes(); rc_return rc_recur hasSideEffects(LHS) or rc_recur hasSideEffects(RHS); } case ExprNode::NodeKind::NK_Or: { auto *Or = llvm::cast(Expr); - const auto [LHS, RHS] = Or->getInternalNodes(); + auto &&[LHS, RHS] = Or->getInternalNodes(); rc_return rc_recur hasSideEffects(LHS) or rc_recur hasSideEffects(RHS); } diff --git a/lib/RestructureCFG/RestructureCFG.cpp b/lib/RestructureCFG/RestructureCFG.cpp index cc651c528..d96d2527a 100644 --- a/lib/RestructureCFG/RestructureCFG.cpp +++ b/lib/RestructureCFG/RestructureCFG.cpp @@ -1255,7 +1255,7 @@ bool restructureCFG(Function &F, ASTTree &AST) { while (Changed) { Changed = false; for (const auto &Backedge : Backedges) { - const auto [Source, Target] = Backedge; + auto &&[Source, Target] = Backedge; revng_assert(not Meta->containsNode(Source)); if (Meta->containsNode(Target)) { revng_assert(Target == Head); diff --git a/lib/Support/IRHelpers.cpp b/lib/Support/IRHelpers.cpp index 2f0ab3e6b..0795bbc30 100644 --- a/lib/Support/IRHelpers.cpp +++ b/lib/Support/IRHelpers.cpp @@ -467,7 +467,7 @@ void collectTypes(Type *Root, std::set &Set) { Type *T = ToVisit.front(); ToVisit.pop(); - auto [_, IsNew] = Set.insert(T); + auto &&[_, IsNew] = Set.insert(T); if (not IsNew) continue; diff --git a/lib/Support/ModuleStatistics.cpp b/lib/Support/ModuleStatistics.cpp index 248e06047..0bac6690e 100644 --- a/lib/Support/ModuleStatistics.cpp +++ b/lib/Support/ModuleStatistics.cpp @@ -100,7 +100,7 @@ void ModuleStatistics::dump(llvm::raw_ostream &Output, emitIndentation(Output, Indent); Output << "TaggedFunctions:\n"; - for (auto [NewEntry, OldEntry] : + for (auto &&[NewEntry, OldEntry] : zipmap_range(TaggedFunctions, Old->TaggedFunctions)) { const FunctionTags::Tag *Tag = nullptr; static const FunctionClass Empty; diff --git a/lib/TypeNames/DependencyGraph.cpp b/lib/TypeNames/DependencyGraph.cpp index 90933fbe1..8074e335a 100644 --- a/lib/TypeNames/DependencyGraph.cpp +++ b/lib/TypeNames/DependencyGraph.cpp @@ -134,7 +134,7 @@ getDependencyFor(const model::Type &Type, // be relaxed if we properly handle the array wrappers. DependencyEdgeAnalysisResult Analyzed = analyzeDependencyEdges(Type); - auto [EdgeTarget, PointerIsBetweenTypes] = Analyzed; + auto &&[EdgeTarget, PointerIsBetweenTypes] = Analyzed; if (EdgeTarget == nullptr) { // By definition, all the primitives are always present. // As such, there's no need to add any edges for such cases. diff --git a/lib/TypeNames/TypePrinters.cpp b/lib/TypeNames/TypePrinters.cpp index ab1376f0e..3deb1fcac 100644 --- a/lib/TypeNames/TypePrinters.cpp +++ b/lib/TypeNames/TypePrinters.cpp @@ -205,8 +205,8 @@ void ptml::CTypeBuilder::printTypeDeclaration(const RFT &F) { void ptml::CTypeBuilder::generateArrayWrapper(const model::ArrayType &ArrayType) { // Check if the wrapper was already added - auto [It, IsNew] = ArtificialNameCache.emplace(ArrayType, - getArrayWrapper(ArrayType)); + auto &&[It, IsNew] = ArtificialNameCache.emplace(ArrayType, + getArrayWrapper(ArrayType)); if (not IsNew) return; @@ -330,7 +330,7 @@ void ptml::CTypeBuilder::collectInlinableTypes() { continue; } - auto [Iterator, _] = DependentTypeCount.try_emplace(Node->T->key(), 0); + auto &&[Iterator, _] = DependentTypeCount.try_emplace(Node->T->key(), 0); Iterator->second += Node->predecessorCount(); if (Node->K == TypeNode::Kind::Declaration) { // Ignore a reference from a type definition to its own declaration. diff --git a/lib/Yield/Assembly/DisassemblyHelper.cpp b/lib/Yield/Assembly/DisassemblyHelper.cpp index 998c44e91..e901447a2 100644 --- a/lib/Yield/Assembly/DisassemblyHelper.cpp +++ b/lib/Yield/Assembly/DisassemblyHelper.cpp @@ -54,7 +54,7 @@ static void analyzeBasicBlocks(yield::Function &Function, std::map> Predecessors; for (const efa::BasicBlock &BasicBlock : Metadata.Blocks()) { - auto [It, Success] = Predecessors.try_emplace(BasicBlock.ID()); + auto &&[It, Success] = Predecessors.try_emplace(BasicBlock.ID()); revng_assert(Success, "Duplicate basic blocks in a `SortedVector`? " "Something is clearly very wrong."); @@ -67,9 +67,9 @@ static void analyzeBasicBlocks(yield::Function &Function, for (const efa::BasicBlock &BasicBlock : Metadata.Blocks()) { for (const auto &Edge : BasicBlock.Successors()) { - auto [NextBlock, _] = efa::parseSuccessor(*convert(Edge).get(), - BasicBlock.nextBlock(), - Binary); + auto &&[NextBlock, _] = efa::parseSuccessor(*convert(Edge).get(), + BasicBlock.nextBlock(), + Binary); if (not NextBlock.isValid()) { // Ignore edges with unknown destinations (like indirect jumps). continue; @@ -89,7 +89,7 @@ static void analyzeBasicBlocks(yield::Function &Function, } // Save the results of the analysis - for (auto [CurrentAddress, PredecessorAddress] : Predecessors) { + for (auto &&[CurrentAddress, PredecessorAddress] : Predecessors) { if (PredecessorAddress.has_value()) { auto Current = Metadata.Blocks().find(CurrentAddress); revng_assert(Current != Metadata.Blocks().end()); @@ -214,8 +214,8 @@ DH::getDisassemblerFor(MetaAddressType::Values AddressType, return It->second; using DI = LLVMDisassemblerInterface; - auto [R, Success] = Internal->try_emplace(AddressType, - DI(AddressType, Configuration)); + auto &&[R, Success] = Internal->try_emplace(AddressType, + DI(AddressType, Configuration)); revng_assert(Success); return R->second; } diff --git a/lib/Yield/Assembly/LLVMDisassemblerInterface.cpp b/lib/Yield/Assembly/LLVMDisassemblerInterface.cpp index 841039bf8..4c9b2e1a5 100644 --- a/lib/Yield/Assembly/LLVMDisassemblerInterface.cpp +++ b/lib/Yield/Assembly/LLVMDisassemblerInterface.cpp @@ -389,7 +389,7 @@ DI::Disassembled DI::instruction(const MetaAddress &Where, llvm::ArrayRef RawBytes) { revng_assert(Where.isValid() && !RawBytes.empty()); - auto [Instruction, Size] = disassemble(Where, RawBytes, *Disassembler); + auto &&[Instruction, Size] = disassemble(Where, RawBytes, *Disassembler); if (Instruction.has_value()) { revng_assert(Size != 0); auto Result = parse(*Instruction, Where, *Printer, *SubtargetInformation); diff --git a/lib/Yield/Assembly/LLVMTagsToPTML.cpp b/lib/Yield/Assembly/LLVMTagsToPTML.cpp index d685d8e5e..43827a7d1 100644 --- a/lib/Yield/Assembly/LLVMTagsToPTML.cpp +++ b/lib/Yield/Assembly/LLVMTagsToPTML.cpp @@ -69,7 +69,7 @@ embedContentIntoTags(const std::vector &Tags, uint64_t Index = 0; for (const yield::Instruction::RawTag &T : Tags) { - auto [New, S] = Result.emplace(Index++, T.Type, Text.slice(T.From, T.To)); + auto &&[New, S] = Result.emplace(Index++, T.Type, Text.slice(T.From, T.To)); revng_assert(S); if (New->Type() == yield::TagType::Whitespace) @@ -163,11 +163,11 @@ static Directives detectDirectives(SortedVector &&Tagged) { if (Line.Tags().begin()->Content()[0] == '.') { if (Instruction.empty()) { // No instruction yet, this is a preceding directive. - auto [_, Success] = Preceding.emplace(std::move(Line)); + auto &&[_, Success] = Preceding.emplace(std::move(Line)); revng_assert(Success); } else { // Instruction is set already, this is a following directive. - auto [_, Success] = Following.emplace(std::move(Line)); + auto &&[_, Success] = Following.emplace(std::move(Line)); revng_assert(Success); } } else { @@ -179,19 +179,19 @@ static Directives detectDirectives(SortedVector &&Tagged) { } // Fix indexing and mark appropriate tags as `Directive`s. - for (auto [Index, Tag] : llvm::enumerate(Instruction)) + for (auto &&[Index, Tag] : llvm::enumerate(Instruction)) Tag.Index() = Index; - for (auto [Index, String] : llvm::enumerate(Preceding)) { + for (auto &&[Index, String] : llvm::enumerate(Preceding)) { String.Index() = Index; - for (auto [Index, Tag] : llvm::enumerate(String.Tags())) { + for (auto &&[Index, Tag] : llvm::enumerate(String.Tags())) { Tag.Index() = Index; if (Tag.Type() == yield::TagType::Untagged && Tag.Content()[0] == '.') Tag.Type() = yield::TagType::Directive; } } - for (auto [Index, String] : llvm::enumerate(Following)) { + for (auto &&[Index, String] : llvm::enumerate(Following)) { String.Index() = Index; - for (auto [Index, Tag] : llvm::enumerate(String.Tags())) { + for (auto &&[Index, Tag] : llvm::enumerate(String.Tags())) { Tag.Index() = Index; if (Tag.Type() == yield::TagType::Untagged && Tag.Content()[0] == '.') Tag.Type() = yield::TagType::Directive; @@ -298,10 +298,10 @@ static bool tryToTurnIntoALabel(yield::TaggedString &Input, && Successor->Destination().start().address() == Address.address()) { // Since we have no easy way to decide which one of the successors // is better, stop looking after the first match. - auto [Name, Loc] = labelImpl(Successor->Destination(), - Function, - Binary, - NameBuilder); + auto &&[Name, Loc] = labelImpl(Successor->Destination(), + Function, + Binary, + NameBuilder); Input.Type() = yield::TagType::Label; Input.Content() = std::move(Name); @@ -445,7 +445,7 @@ void yield::Instruction::handleSpecialTags(const yield::BasicBlock &BasicBlock, void yield::BasicBlock::setLabel(const yield::Function &Function, const model::Binary &Binary, model::NameBuilder &NameBuilder) { - auto [N, Location] = labelImpl(ID(), Function, Binary, NameBuilder); + auto &&[N, Location] = labelImpl(ID(), Function, Binary, NameBuilder); SortedVector Attributes; Attributes.emplace(ptml::attributes::LocationDefinition, Location); diff --git a/lib/Yield/CallGraphs/CallGraphSlices.cpp b/lib/Yield/CallGraphs/CallGraphSlices.cpp index d2851045a..841c74740 100644 --- a/lib/Yield/CallGraphs/CallGraphSlices.cpp +++ b/lib/Yield/CallGraphs/CallGraphSlices.cpp @@ -66,7 +66,7 @@ Graph makeTreeImpl(const Graph &Input, llvm::StringRef SlicePointLocation) { } } - auto [_, Success] = RealEdges.try_emplace(Current, SelectedNeighbour); + auto &&[_, Success] = RealEdges.try_emplace(Current, SelectedNeighbour); revng_assert(Success); } diff --git a/lib/Yield/ControlFlow/Extraction.cpp b/lib/Yield/ControlFlow/Extraction.cpp index 95f9997a0..d3b071c60 100644 --- a/lib/Yield/ControlFlow/Extraction.cpp +++ b/lib/Yield/ControlFlow/Extraction.cpp @@ -19,9 +19,9 @@ yield::cfg::extractFromInternal(const yield::Function &Function, const Configuration &Configuration) { using PLG = PreLayoutGraph; const auto &ControlFlowGraph = Function.Blocks(); - auto [Result, Lookup] = efa::buildControlFlowGraph(ControlFlowGraph, - Function.Entry(), - Binary); + auto &&[Result, Lookup] = efa::buildControlFlowGraph(ControlFlowGraph, + Function.Entry(), + Binary); if (!Configuration.AddExitNode) { auto ExitNodeIterator = Lookup.find(BasicBlockID::invalid()); diff --git a/lib/Yield/ControlFlow/FallthroughDetection.cpp b/lib/Yield/ControlFlow/FallthroughDetection.cpp index 80f72b2bc..e32aab964 100644 --- a/lib/Yield/ControlFlow/FallthroughDetection.cpp +++ b/lib/Yield/ControlFlow/FallthroughDetection.cpp @@ -17,8 +17,8 @@ yield::cfg::detectFallthrough(const yield::BasicBlock &BasicBlock, const yield::BasicBlock *Result = nullptr; for (const auto &Edge : BasicBlock.Successors()) { - auto [NextAddress, - _] = efa::parseSuccessor(*Edge, BasicBlock.nextBlock(), Binary); + auto &&[NextAddress, + _] = efa::parseSuccessor(*Edge, BasicBlock.nextBlock(), Binary); if (NextAddress.isValid() && NextAddress == BasicBlock.nextBlock()) { if (auto Iterator = Function.Blocks().find(NextAddress); Iterator != Function.Blocks().end()) { diff --git a/lib/Yield/CrossRelations.cpp b/lib/Yield/CrossRelations.cpp index a2aa226b9..bb803aa36 100644 --- a/lib/Yield/CrossRelations.cpp +++ b/lib/Yield/CrossRelations.cpp @@ -90,7 +90,7 @@ CR::CrossRelations::toCallGraph() const { std::unordered_map LookupHelper; auto AddNode = [&Result, &LookupHelper](llvm::StringRef Location) { auto *Node = Result.addNode(Location); - auto [Iterator, Success] = LookupHelper.try_emplace(Location, Node); + auto &&[Iterator, Success] = LookupHelper.try_emplace(Location, Node); revng_assert(Success); }; auto AddEdge = [&LookupHelper](llvm::StringRef Callee, @@ -129,7 +129,7 @@ yield::calls::PreLayoutGraph CR::CrossRelations::toYieldGraph() const { else revng_abort("Unsupported location found in cross relations."); - auto [Iterator, Success] = LookupHelper.try_emplace(Location, Node); + auto &&[Iterator, Success] = LookupHelper.try_emplace(Location, Node); revng_assert(Success); }; auto AddEdge = [&LookupHelper](llvm::StringRef Callee, diff --git a/lib/Yield/PTML.cpp b/lib/Yield/PTML.cpp index 0d85d2b9f..477577ace 100644 --- a/lib/Yield/PTML.cpp +++ b/lib/Yield/PTML.cpp @@ -74,9 +74,10 @@ static std::set targets(const yield::BasicBlock &BasicBlock, const model::Binary &Binary) { std::set Result; for (const auto &Edge : BasicBlock.Successors()) { - auto [NextAddress, MaybeCall] = efa::parseSuccessor(*Edge, - BasicBlock.nextBlock(), - Binary); + auto &&[NextAddress, + MaybeCall] = efa::parseSuccessor(*Edge, + BasicBlock.nextBlock(), + Binary); if (NextAddress.isValid()) Result.emplace(targetPath(NextAddress, Function, Binary)); @@ -145,7 +146,7 @@ public: const model::Binary &Binary) { const auto Config = Binary.Configuration().Disassembly(); for (const yield::BasicBlock &BasicBlock : Function.Blocks()) { - auto [Iterator, Success] = Prefixes.try_emplace(BasicBlock.ID()); + auto &&[Iterator, Success] = Prefixes.try_emplace(BasicBlock.ID()); revng_assert(Success, "Duplicate basic blocks?"); auto &BBPrefixes = Iterator->second; @@ -171,8 +172,8 @@ public: InstructionPrefix Result = { .Address = std::move(Address), .Bytes = std::move(Bytes) }; - auto [_, Success] = BBPrefixes.try_emplace(Instruction.Address(), - std::move(Result)); + auto &&[_, Success] = BBPrefixes.try_emplace(Instruction.Address(), + std::move(Result)); revng_assert(Success, "Duplicate instructions?"); } } @@ -486,9 +487,9 @@ std::string yield::ptml::functionAssembly(const ::ptml::MarkupBuilder &B, const model::Function &MFunction = Binary.Functions().at(Function.Entry()); - auto [G, _] = efa::buildControlFlowGraph(Function.Blocks(), - Function.Entry(), - Binary); + auto &&[G, _] = efa::buildControlFlowGraph(Function.Blocks(), + Function.Entry(), + Binary); ::CommentPlacementHelper CM(MFunction, G); for (const auto &BBlock : Function.Blocks()) { @@ -532,9 +533,9 @@ std::string yield::ptml::controlFlowNode(const ::ptml::MarkupBuilder &B, const model::Function &MFunction = Binary.Functions().at(Function.Entry()); - auto [G, _] = efa::buildControlFlowGraph(Function.Blocks(), - Function.Entry(), - Binary); + auto &&[G, _] = efa::buildControlFlowGraph(Function.Blocks(), + Function.Entry(), + Binary); ::CommentPlacementHelper CM(MFunction, G); auto Result = labeledBlock(B, *Iterator, Function, MFunction, Binary); diff --git a/lib/Yield/SVG.cpp b/lib/Yield/SVG.cpp index 6cdd3fc85..0623dbe1b 100644 --- a/lib/Yield/SVG.cpp +++ b/lib/Yield/SVG.cpp @@ -199,7 +199,7 @@ Viewbox calculateViewbox(const GraphType &Graph) { // Ensure every edge point fits. for (const auto *From : Graph.nodes()) - for (const auto [To, Label] : From->successor_edges()) + for (auto &&[To, Label] : From->successor_edges()) for (const auto &Point : Label->Path) expandViewbox(Result, Point); @@ -295,7 +295,7 @@ static std::string exportGraph(const ptml::MarkupBuilder &B, // Export all the edges. for (const auto *From : Graph.nodes()) { if (ShouldEmitEmptyNodes || !From->isEmpty()) { - for (const auto [To, Edge] : From->successor_edges()) { + for (auto &&[To, Edge] : From->successor_edges()) { if (ShouldEmitEmptyNodes || !To->isEmpty()) { revng_assert(Edge != nullptr); Result += edge(B, @@ -547,7 +547,7 @@ combineHalvesHelper(llvm::StringRef SlicePoint, // Ready the backwards part of the graph for (auto *From : BackwardsSlice.nodes()) { From->Center = convertPoint(From->Center, Delta); - for (auto [Neighbor, Label] : From->successor_edges()) + for (auto &&[Neighbor, Label] : From->successor_edges()) for (auto &Point : Label->Path) Point = convertPoint(Point, Delta); } @@ -566,18 +566,18 @@ combineHalvesHelper(llvm::StringRef SlicePoint, revng_assert(Node != nullptr); if (Node != BackwardsSlicePoint) { auto NewNode = ForwardsSlice.addNode(Node->moveData()); - auto [Iterator, Success] = Lookup.try_emplace(Node, NewNode); + auto &&[Iterator, Success] = Lookup.try_emplace(Node, NewNode); revng_assert(Success == true); } else { - auto [Iterator, Success] = Lookup.try_emplace(BackwardsSlicePoint, - ForwardsSlicePoint); + auto &&[Iterator, Success] = Lookup.try_emplace(BackwardsSlicePoint, + ForwardsSlicePoint); revng_assert(Success == true); } } // Move all the edges while also inverting their direction. for (auto *From : BackwardsSlice.nodes()) { - for (auto [To, Label] : From->successor_edges()) { + for (auto &&[To, Label] : From->successor_edges()) { std::reverse(Label->Path.begin(), Label->Path.end()); AccessLookup(To)->addSuccessor(AccessLookup(From), std::move(*Label)); } @@ -602,7 +602,7 @@ std::string yield::svg::callGraphSlice(const ::ptml::MarkupBuilder &B, // Ready the forwards facing part of the slice auto Forward = calls::makeCalleeTree(Relations.toYieldGraph(), SlicePoint); for (auto *From : Forward.nodes()) - for (auto [To, Label] : From->successor_edges()) + for (auto &&[To, Label] : From->successor_edges()) Label->IsBackwards = false; Helper.computeSizes(Forward); auto LaidOutForwardsGraph = layout::sugiyama::compute(Forward, @@ -615,7 +615,7 @@ std::string yield::svg::callGraphSlice(const ::ptml::MarkupBuilder &B, // Ready the backwards facing part of the slice auto Backwards = calls::makeCallerTree(Relations.toYieldGraph(), SlicePoint); for (auto *From : Backwards.nodes()) - for (auto [To, Label] : From->successor_edges()) + for (auto &&[To, Label] : From->successor_edges()) Label->IsBackwards = true; Helper.computeSizes(Backwards); auto LaidOutBackwardsGraph = layout::sugiyama::compute(Backwards, diff --git a/lib/Yield/Verify.cpp b/lib/Yield/Verify.cpp index 03ad42673..04bfbfa36 100644 --- a/lib/Yield/Verify.cpp +++ b/lib/Yield/Verify.cpp @@ -29,7 +29,7 @@ bool yield::TaggedString::verify(model::VerifyHelper &VH) const { } bool yield::TaggedLine::verify(model::VerifyHelper &VH) const { - for (auto [Index, String] : llvm::enumerate(Tags())) { + for (auto &&[Index, String] : llvm::enumerate(Tags())) { if (Index != String.Index()) return VH.fail("Tagged string indexing is broken."); @@ -48,7 +48,7 @@ bool yield::Instruction::verify(model::VerifyHelper &VH) const { if (Disassembled().empty()) return VH.fail("An instruction must have at least one tag."); - for (auto [Index, Tagged] : llvm::enumerate(Disassembled())) { + for (auto &&[Index, Tagged] : llvm::enumerate(Disassembled())) { if (Index != Tagged.Index()) return VH.fail("Tagged string indexing is broken."); @@ -56,14 +56,14 @@ bool yield::Instruction::verify(model::VerifyHelper &VH) const { return VH.fail(); } - for (auto [Index, Directive] : llvm::enumerate(PrecedingDirectives())) { + for (auto &&[Index, Directive] : llvm::enumerate(PrecedingDirectives())) { if (Index != Directive.Index()) return VH.fail("Preceding directive indexing is broken."); if (!Directive.verify(VH)) return VH.fail(); } - for (auto [Index, Directive] : llvm::enumerate(FollowingDirectives())) { + for (auto &&[Index, Directive] : llvm::enumerate(FollowingDirectives())) { if (Index != Directive.Index()) return VH.fail("Following directive indexing is broken."); diff --git a/lib/mlir/Dialect/Clift/IR/CliftOps.cpp b/lib/mlir/Dialect/Clift/IR/CliftOps.cpp index 68e91eab3..c66f86854 100644 --- a/lib/mlir/Dialect/Clift/IR/CliftOps.cpp +++ b/lib/mlir/Dialect/Clift/IR/CliftOps.cpp @@ -1154,7 +1154,7 @@ void CallOp::print(OpAsmPrinter &Printer) { auto ParameterTypes = FunctionTypeAttr.getArgumentTypes(); bool RequiresExplicitArgumentTypes = false; - for (auto [ArgumentT, ParameterT] : + for (auto &&[ArgumentT, ParameterT] : llvm::zip_equal(ArgumentTypes, ParameterTypes)) { auto ParameterValueT = mlir::cast(ParameterT); @@ -1187,7 +1187,7 @@ mlir::LogicalResult CallOp::verify() { << " argument count must match the number of function" " parameters."; - for (auto [ArgumentT, ParameterT] : + for (auto &&[ArgumentT, ParameterT] : llvm::zip_equal(ArgumentTypes, ParameterTypes)) { auto ArgumentValueT = mlir::cast(ArgumentT); auto ParameterValueT = mlir::cast(ParameterT); diff --git a/lib/mlir/Dialect/Clift/IR/CliftTypes.cpp b/lib/mlir/Dialect/Clift/IR/CliftTypes.cpp index ab1155b1c..5ada532ad 100644 --- a/lib/mlir/Dialect/Clift/IR/CliftTypes.cpp +++ b/lib/mlir/Dialect/Clift/IR/CliftTypes.cpp @@ -44,7 +44,7 @@ TypedefDecomposition clift::decomposeTypedef(ValueType Type) { } ValueType clift::dealias(ValueType Type, bool IgnoreQualifiers) { - auto [UnderlyingType, HasConstTypedef] = decomposeTypedef(Type); + auto &&[UnderlyingType, HasConstTypedef] = decomposeTypedef(Type); if (HasConstTypedef and not IgnoreQualifiers) UnderlyingType = UnderlyingType.addConst(); @@ -53,7 +53,7 @@ ValueType clift::dealias(ValueType Type, bool IgnoreQualifiers) { } bool clift::isModifiableType(ValueType Type) { - auto [UnderlyingType, HasConst] = decomposeTypedef(Type); + auto &&[UnderlyingType, HasConst] = decomposeTypedef(Type); return not HasConst and not UnderlyingType.isConst(); } diff --git a/tests/abi/tools/check-compatibility-with-abi/ABIRuntimeTestResultParser.cpp b/tests/abi/tools/check-compatibility-with-abi/ABIRuntimeTestResultParser.cpp index 138942ecf..044a469c7 100644 --- a/tests/abi/tools/check-compatibility-with-abi/ABIRuntimeTestResultParser.cpp +++ b/tests/abi/tools/check-compatibility-with-abi/ABIRuntimeTestResultParser.cpp @@ -160,7 +160,7 @@ static void verify(const abi::runtime_test::Deserialized &Data) { } size_t ExpectedIterationCount = Counter.begin()->second.full(); - for (auto [_, Counts] : Counter) { + for (auto &&[_, Counts] : Counter) { bool IsAnArgumentTest = Counts.ArgumentIterations != 0; bool IsAnReturnValueTest = Counts.ReturnValueIterations != 0; if (IsAnArgumentTest == IsAnReturnValueTest) { diff --git a/tests/abi/tools/check-compatibility-with-abi/Verify.cpp b/tests/abi/tools/check-compatibility-with-abi/Verify.cpp index c54864b7d..06790a54c 100644 --- a/tests/abi/tools/check-compatibility-with-abi/Verify.cpp +++ b/tests/abi/tools/check-compatibility-with-abi/Verify.cpp @@ -76,7 +76,7 @@ void VH::verifyValuePreservation(llvm::ArrayRef ExpectedBytes, } uint64_t MatchingByteCount = 0; - for (auto [FByte, EByte] : llvm::zip(FoundBytes, ExpectedBytes)) + for (auto &&[FByte, EByte] : llvm::zip(FoundBytes, ExpectedBytes)) if (FByte == EByte) ++MatchingByteCount; diff --git a/tests/abi/tools/ensure-rft-equivalence/Main.cpp b/tests/abi/tools/ensure-rft-equivalence/Main.cpp index a8af0480b..2a26dca19 100644 --- a/tests/abi/tools/ensure-rft-equivalence/Main.cpp +++ b/tests/abi/tools/ensure-rft-equivalence/Main.cpp @@ -96,7 +96,7 @@ ensureIDMatch(const model::TypeDefinition::Key &Left, auto NewPath = Model.getDefinitionReference(MovedOut->key()); // Reinsert the type. - auto [_, Success] = Model.TypeDefinitions().insert(std::move(MovedOut)); + auto &&[_, Success] = Model.TypeDefinitions().insert(std::move(MovedOut)); revng_assert(Success); // Return the "replacement pair", so that the caller is able to gather them @@ -165,7 +165,7 @@ int main(int Argc, char *Argv[]) { if (Left->ID() == LeftModel->defaultPrototype()->ID()) continue; // Skip the default prototype. - auto [It, Success] = Functions.try_emplace(LeftNameBuilder.name(F)); + auto &&[It, Success] = Functions.try_emplace(LeftNameBuilder.name(F)); revng_assert(Success); It->second.Left = Left->key(); } @@ -217,7 +217,7 @@ int main(int Argc, char *Argv[]) { revng_abort(Error.c_str()); } - auto [_, Success] = DeduplicationHelper.emplace(Iterator->second); + auto &&[_, Success] = DeduplicationHelper.emplace(Iterator->second); if (!Success) Iterator = Functions.erase(Iterator); else @@ -229,8 +229,8 @@ int main(int Argc, char *Argv[]) { // models instead of doing that manually, since the ID is the only piece // of the types that is allowed to change. std::map Replacements; - for (auto [Name, Pair] : Functions) { - auto [LKey, RKey] = Pair; + for (auto &&[Name, Pair] : Functions) { + auto &&[LKey, RKey] = Pair; auto LeftIt = LeftModel->TypeDefinitions().find(LKey.value()); revng_assert(LeftIt != LeftModel->TypeDefinitions().end()); diff --git a/tests/unit/ADT.cpp b/tests/unit/ADT.cpp index 651cf5067..b6b316d6e 100644 --- a/tests/unit/ADT.cpp +++ b/tests/unit/ADT.cpp @@ -92,7 +92,7 @@ consteval int takeAsTupleExample() { { // Edit some elements. - auto [First, Second, Third] = takeAsTuple<3>(Data); + auto &&[First, Second, Third] = takeAsTuple<3>(Data); ++First; Second = 2; Third = 3; @@ -100,7 +100,7 @@ consteval int takeAsTupleExample() { { // Read multiple elements through a view. - auto [Second, Third] = takeAsTuple<2>(Data | std::views::drop(1)); + auto &&[Second, Third] = takeAsTuple<2>(Data | std::views::drop(1)); return Second + Third; } } diff --git a/tests/unit/AdvancedValueInfo.cpp b/tests/unit/AdvancedValueInfo.cpp index 1b4748303..87cda1956 100644 --- a/tests/unit/AdvancedValueInfo.cpp +++ b/tests/unit/AdvancedValueInfo.cpp @@ -127,7 +127,7 @@ static void checkAdvancedValueInfo(const char *Body, const CheckMap &Map) { for (auto &P : Map) Reference[instructionByName(F, P.first)] = P.second; - for (auto [ResultPair, ReferencePair] : zipmap_range(Results, Reference)) { + for (auto &&[ResultPair, ReferencePair] : zipmap_range(Results, Reference)) { std::set ResultSet; std::set ReferenceSet; @@ -145,7 +145,7 @@ static void checkAdvancedValueInfo(const char *Body, const CheckMap &Map) { dbg << "ResultSet.size() == " << ResultSet.size() << "\n"; dbg << "ReferenceSet.size() == " << ReferenceSet.size() << "\n"; - for (auto [ResultValue, ReferenceValue] : + for (auto &&[ResultValue, ReferenceValue] : zipmap_range(ResultSet, ReferenceSet)) { MaterializedValue Value; if (ResultValue != nullptr and ReferenceValue != nullptr) { diff --git a/tests/unit/Alignment.cpp b/tests/unit/Alignment.cpp index 4832ecf18..2ee7dbdca 100644 --- a/tests/unit/Alignment.cpp +++ b/tests/unit/Alignment.cpp @@ -27,7 +27,7 @@ struct Expected { template requires(same_as && ...) void testAlignment(model::UpcastableType &&Type, const Types &...TestCases) { - for (auto [ABI, Expected] : std::array{ TestCases... }) { + for (auto &&[ABI, Expected] : std::array{ TestCases... }) { std::optional TestResult = ABI.alignment(*Type); if (TestResult.value_or(0) != Expected) { std::string Error = "Alignment run failed for type:\n" + toString(Type) @@ -179,13 +179,13 @@ BOOST_AUTO_TEST_CASE(UnionTypes) { for (model::ABI::Values ABIName : TestedABIs) { const abi::Definition &ABI = abi::Definition::get(ABIName); - auto [SimpleDefinition, Simple] = Binary->makeUnionDefinition(); + auto &&[SimpleDefinition, Simple] = Binary->makeUnionDefinition(); SimpleDefinition.addField(Int32.copy()); SimpleDefinition.addField(Int64.copy()); if (ABIhasIntsOfSizes(ABI, { 4, 8 })) compareTypeAlignments(ABI, Int64, Simple); - auto [SmallFloatDefinition, SmallFloat] = Binary->makeUnionDefinition(); + auto &&[SmallFloatDefinition, SmallFloat] = Binary->makeUnionDefinition(); SmallFloatDefinition.addField(Int32.copy()); SmallFloatDefinition.addField(Float.copy()); if (ABIhasIntsOfSizes(ABI, { 4 }) && ABIhasFloatsOfSizes(ABI, { 4 })) { @@ -193,13 +193,13 @@ BOOST_AUTO_TEST_CASE(UnionTypes) { compareTypeAlignments(ABI, Float, SmallFloat); } - auto [BigFloatDefinition, BigFloat] = Binary->makeUnionDefinition(); + auto &&[BigFloatDefinition, BigFloat] = Binary->makeUnionDefinition(); BigFloatDefinition.addField(LongDouble.copy()); BigFloatDefinition.addField(Int64.copy()); if (ABIhasIntsOfSizes(ABI, { 8 }) && ABIhasFloatsOfSizes(ABI, { 16 })) compareTypeAlignments(ABI, LongDouble, BigFloat); - auto [WeirdFloatDefinition, WeirdFloat] = Binary->makeUnionDefinition(); + auto &&[WeirdFloatDefinition, WeirdFloat] = Binary->makeUnionDefinition(); WeirdFloatDefinition.addField(WeirdLD.copy()); WeirdFloatDefinition.addField(Int32.copy()); if (ABIhasIntsOfSizes(ABI, { 4 }) && ABIhasFloatsOfSizes(ABI, { 12 })) @@ -207,13 +207,14 @@ BOOST_AUTO_TEST_CASE(UnionTypes) { // Test the case where on top of the float field, there's also another // stricter-aligned field, which "eclipses" the float one. - auto [EclipsedFloatDefinition, EclipsedFl] = Binary->makeUnionDefinition(); + auto &&[EclipsedFloatDefinition, + EclipsedFl] = Binary->makeUnionDefinition(); EclipsedFloatDefinition.addField(Float.copy()); EclipsedFloatDefinition.addField(Int64.copy()); if (ABIhasIntsOfSizes(ABI, { 8 }) && ABIhasFloatsOfSizes(ABI, { 4 })) compareTypeAlignments(ABI, Int64, EclipsedFl); - auto [NestedDefinition, Nested] = Binary->makeUnionDefinition(); + auto &&[NestedDefinition, Nested] = Binary->makeUnionDefinition(); NestedDefinition.addField(SmallFloat.copy()); NestedDefinition.addField(Int16.copy()); if (ABIhasIntsOfSizes(ABI, { 2, 4 }) && ABIhasFloatsOfSizes(ABI, { 4 })) { @@ -222,7 +223,8 @@ BOOST_AUTO_TEST_CASE(UnionTypes) { compareTypeAlignments(ABI, SmallFloat, Nested); } - auto [EclipsedNestedDefinition, EclipsedN] = Binary->makeUnionDefinition(); + auto &&[EclipsedNestedDefinition, + EclipsedN] = Binary->makeUnionDefinition(); EclipsedNestedDefinition.addField(SmallFloat.copy()); EclipsedNestedDefinition.addField(Int64.copy()); if (ABIhasIntsOfSizes(ABI, { 4, 8 }) && ABIhasFloatsOfSizes(ABI, { 4 })) @@ -245,13 +247,13 @@ BOOST_AUTO_TEST_CASE(StructTypes) { for (model::ABI::Values ABIName : TestedABIs) { const abi::Definition &ABI = abi::Definition::get(ABIName); - auto [SimpleDefinition, Simple] = Binary->makeStructDefinition(); + auto &&[SimpleDefinition, Simple] = Binary->makeStructDefinition(); SimpleDefinition.addField(0, Int32.copy()); SimpleDefinition.addField(8, Int64.copy()); if (ABIhasIntsOfSizes(ABI, { 4, 8 })) compareTypeAlignments(ABI, Int64, Simple); - auto [SmallFloatDefinition, SmallFloat] = Binary->makeStructDefinition(); + auto &&[SmallFloatDefinition, SmallFloat] = Binary->makeStructDefinition(); SmallFloatDefinition.addField(0, Int32.copy()); SmallFloatDefinition.addField(4, Float.copy()); if (ABIhasIntsOfSizes(ABI, { 4 }) && ABIhasFloatsOfSizes(ABI, { 4 })) { @@ -259,13 +261,13 @@ BOOST_AUTO_TEST_CASE(StructTypes) { compareTypeAlignments(ABI, Float, SmallFloat); } - auto [BigFloatDefinition, BigFloat] = Binary->makeStructDefinition(); + auto &&[BigFloatDefinition, BigFloat] = Binary->makeStructDefinition(); BigFloatDefinition.addField(0, LongDouble.copy()); BigFloatDefinition.addField(16, Int64.copy()); if (ABIhasIntsOfSizes(ABI, { 8 }) && ABIhasFloatsOfSizes(ABI, { 16 })) compareTypeAlignments(ABI, LongDouble, BigFloat); - auto [WeirdFloatDefinition, WeirdFloat] = Binary->makeStructDefinition(); + auto &&[WeirdFloatDefinition, WeirdFloat] = Binary->makeStructDefinition(); WeirdFloatDefinition.addField(0, WeirdLD.copy()); WeirdFloatDefinition.addField(12, Int32.copy()); if (ABIhasIntsOfSizes(ABI, { 4 }) && ABIhasFloatsOfSizes(ABI, { 12 })) @@ -273,13 +275,14 @@ BOOST_AUTO_TEST_CASE(StructTypes) { // Test the case where on top of the float field, there's also another // stricter-aligned field, which "eclipses" the float one. - auto [EclipsedFloatDefinition, EclipsedFl] = Binary->makeStructDefinition(); + auto &&[EclipsedFloatDefinition, + EclipsedFl] = Binary->makeStructDefinition(); EclipsedFloatDefinition.addField(0, Float.copy()); EclipsedFloatDefinition.addField(8, Int64.copy()); if (ABIhasIntsOfSizes(ABI, { 8 }) && ABIhasFloatsOfSizes(ABI, { 4 })) compareTypeAlignments(ABI, Int64, EclipsedFl); - auto [NestedDefinition, Nested] = Binary->makeStructDefinition(); + auto &&[NestedDefinition, Nested] = Binary->makeStructDefinition(); NestedDefinition.addField(0, SmallFloat.copy()); NestedDefinition.addField(8, Int16.copy()); if (ABIhasIntsOfSizes(ABI, { 2, 4 }) && ABIhasFloatsOfSizes(ABI, { 4 })) { @@ -288,7 +291,8 @@ BOOST_AUTO_TEST_CASE(StructTypes) { compareTypeAlignments(ABI, SmallFloat, Nested); } - auto [EclipsedNestedDefinition, EclipsedN] = Binary->makeStructDefinition(); + auto &&[EclipsedNestedDefinition, + EclipsedN] = Binary->makeStructDefinition(); EclipsedNestedDefinition.addField(0, SmallFloat.copy()); EclipsedNestedDefinition.addField(8, Int64.copy()); if (ABIhasIntsOfSizes(ABI, { 4, 8 }) && ABIhasFloatsOfSizes(ABI, { 4 })) diff --git a/tests/unit/DepthFirstVisit.h b/tests/unit/DepthFirstVisit.h index c9945183b..aa3be79b5 100644 --- a/tests/unit/DepthFirstVisit.h +++ b/tests/unit/DepthFirstVisit.h @@ -219,7 +219,7 @@ inline RecursiveCoroutine findMaxDepthRet(Node *Current, std::set &Stack) { size_t MaxChildDepth = 0ULL; for (Node *Child : Current->children()) { - auto [_, New] = Stack.insert(Child); + auto &&[_, New] = Stack.insert(Child); if (New) MaxChildDepth = std::max(MaxChildDepth, rc_recur findMaxDepthRet(Child, Stack)); diff --git a/tests/unit/GenericGraph.cpp b/tests/unit/GenericGraph.cpp index d47e5e27f..92b472566 100644 --- a/tests/unit/GenericGraph.cpp +++ b/tests/unit/GenericGraph.cpp @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(TestCompile) { using NodeType = ForwardNode; - auto [A, B] = Edge{ nullptr }; + auto &&[A, B] = Edge{ nullptr }; GenericGraph Graph; auto *Node = Graph.addNode(3); @@ -469,7 +469,7 @@ BOOST_AUTO_TEST_CASE(BasicMutableEdgeNodeTest) { for (auto *Node : G.nodes()) { revng_check(!Node->Text.empty()); - for (auto [Neighbor, Edge] : Node->successor_edges()) { + for (auto &&[Neighbor, Edge] : Node->successor_edges()) { revng_check(!Neighbor->Text.empty()); for (auto &Point : Edge->Points) revng_check(Point.X == 1.0 && Point.Y < 0.4 && Point.Y > 0.0); @@ -477,7 +477,7 @@ BOOST_AUTO_TEST_CASE(BasicMutableEdgeNodeTest) { } for (auto *Node : G.nodes()) { revng_check(!Node->Text.empty()); - for (auto [Neighbor, Edge] : Node->predecessor_edges()) { + for (auto &&[Neighbor, Edge] : Node->predecessor_edges()) { revng_check(!Neighbor->Text.empty()); for (auto &Point : Edge->Points) revng_check(Point.X == 1.0 && Point.Y < 0.4 && Point.Y > 0.0); diff --git a/tests/unit/KeyedObjectsContainers.cpp b/tests/unit/KeyedObjectsContainers.cpp index f65406666..db0ef0566 100644 --- a/tests/unit/KeyedObjectsContainers.cpp +++ b/tests/unit/KeyedObjectsContainers.cpp @@ -18,7 +18,7 @@ bool init_unit_test(); template static void assertInsert(T &Set, uint64_t Key, uint64_t Value) { - auto [It, Success] = Set.insert({ Key, Value }); + auto &&[It, Success] = Set.insert({ Key, Value }); revng_check(It->key() == Key and It->value() == Value); revng_check(Success); } @@ -74,7 +74,7 @@ void testSet() { { revng_check(!Set.contains(0x1500)); - auto [It, Success] = Set.insert({ 0x1500, 0xEEEE }); + auto &&[It, Success] = Set.insert({ 0x1500, 0xEEEE }); revng_check(Success); auto Next = Set.erase(It); revng_check(Next == Set.find(0x2000)); @@ -97,14 +97,14 @@ void testSet() { // insert vs insert_or_assign { - auto [It, Success] = Set.insert({ 0x1000, 0x5555 }); + auto &&[It, Success] = Set.insert({ 0x1000, 0x5555 }); revng_check(Set.find(0x1000) == It); revng_check(not Success); revng_check(Set[0x1000].value() == 0xDEADDEAD); } { - auto [It, Success] = Set.insert_or_assign({ 0x1000, 0x6666 }); + auto &&[It, Success] = Set.insert_or_assign({ 0x1000, 0x6666 }); revng_check(not Success); revng_check(Set[0x1000].value() == 0x6666); Set.insert_or_assign({ 0x1000, 0xDEADDEAD }); diff --git a/tests/unit/Location.cpp b/tests/unit/Location.cpp index fc512dedc..f871b7cb3 100644 --- a/tests/unit/Location.cpp +++ b/tests/unit/Location.cpp @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(TypeIDAsTheKey) { TupleTree NewModel; // Define a new union - auto [Definition, _] = NewModel->makeUnionDefinition(); + auto &&[Definition, _] = NewModel->makeUnionDefinition(); Definition.CustomName() = "my_cool_union"; auto &ThirdField = Definition.Fields()[2]; ThirdField.CustomName() = "third_field"; diff --git a/tests/unit/Model.cpp b/tests/unit/Model.cpp index 925fde28f..fd9a82f0f 100644 --- a/tests/unit/Model.cpp +++ b/tests/unit/Model.cpp @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(TestPathAccess) { revng_check(getByPath("/Functions/:Invalid", Binary) == &F); // Test UpcastablePointer - auto [Typedef, TypedefType] = Binary.makeTypedefDefinition(); + auto &&[Typedef, TypedefType] = Binary.makeTypedefDefinition(); Typedef.UnderlyingType() = model::PrimitiveType::make(PrimitiveKind::Unsigned, 8); @@ -220,8 +220,8 @@ BOOST_AUTO_TEST_CASE(TestModelDeduplication) { { using Pointer = model::PointerType; - auto [LeftStruct1, LeftType1] = Model->makeStructDefinition(); - auto [LeftStruct2, LeftType2] = Model->makeStructDefinition(); + auto &&[LeftStruct1, LeftType1] = Model->makeStructDefinition(); + auto &&[LeftStruct2, LeftType2] = Model->makeStructDefinition(); LeftStruct1.Fields()[0].Type() = Pointer::make(std::move(LeftType2), 8); LeftStruct2.Fields()[0].Type() = Pointer::make(std::move(LeftType1), 8); @@ -229,8 +229,8 @@ BOOST_AUTO_TEST_CASE(TestModelDeduplication) { LeftStruct1.OriginalName() = "LoopingStructs1"; LeftStruct2.OriginalName() = "LoopingStructs2"; - auto [RightStruct1, RightType1] = Model->makeStructDefinition(); - auto [RightStruct2, RightType2] = Model->makeStructDefinition(); + auto &&[RightStruct1, RightType1] = Model->makeStructDefinition(); + auto &&[RightStruct2, RightType2] = Model->makeStructDefinition(); RightStruct1.Fields()[0].Type() = Pointer::make(std::move(RightType2), 8); diff --git a/tests/unit/PointerArrayEmission.cpp b/tests/unit/PointerArrayEmission.cpp index 290426500..76240e42e 100644 --- a/tests/unit/PointerArrayEmission.cpp +++ b/tests/unit/PointerArrayEmission.cpp @@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(PointerArrayEmission) { auto Int = model::PrimitiveType::makeConstSigned(4); Tests.emplace_back(Int, "const int32_t test"); - auto [TypedefDef, Typedef] = Binary->makeTypedefDefinition(Void.copy()); + auto &&[TypedefDef, Typedef] = Binary->makeTypedefDefinition(Void.copy()); Tests.emplace_back(Typedef, "typedef_0 test"); auto VoidP = model::PointerType::make(Void.copy(), 8); @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(PointerArrayEmission) { std::string FailureLog; ptml::CTypeBuilder B(llvm::nulls(), *Binary, /* EnableTaglessMode = */ true); - for (auto [Type, ExpectedOutput] : Tests) { + for (auto &&[Type, ExpectedOutput] : Tests) { std::string ActualOutput = B.getNamedCInstance(*Type, "test").str().str(); if (ActualOutput != ExpectedOutput) { FailureLog += "Output of `getNamedCInstance` (\"" + ActualOutput diff --git a/tests/unit/TypeBucket.cpp b/tests/unit/TypeBucket.cpp index e52d384ff..68fdbbd32 100644 --- a/tests/unit/TypeBucket.cpp +++ b/tests/unit/TypeBucket.cpp @@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(Commit) { { model::TypeBucket Bucket = *Binary; - auto [Type, Path] = Bucket.makeStructDefinition(); + auto &&[Type, Path] = Bucket.makeStructDefinition(); Bucket.commit(); } @@ -28,7 +28,7 @@ BOOST_AUTO_TEST_CASE(Drop) { { model::TypeBucket Bucket = *Binary; - auto [Type, Path] = Bucket.makeStructDefinition(); + auto &&[Type, Path] = Bucket.makeStructDefinition(); Bucket.drop(); } @@ -40,14 +40,14 @@ BOOST_AUTO_TEST_CASE(Multiple) { { model::TypeBucket Bucket = *Binary; - auto [Type, Path] = Bucket.makeStructDefinition(); + auto &&[Type, Path] = Bucket.makeStructDefinition(); Type.OriginalName() = "First"; Bucket.commit(); } { model::TypeBucket Bucket = *Binary; - auto [Type, Path] = Bucket.makeStructDefinition(); + auto &&[Type, Path] = Bucket.makeStructDefinition(); Type.OriginalName() = "Second"; Bucket.commit(); } @@ -62,21 +62,21 @@ BOOST_AUTO_TEST_CASE(Reused) { TupleTree Binary; model::TypeBucket Bucket = *Binary; - auto [Type, Path] = Bucket.makeStructDefinition(); + auto &&[Type, Path] = Bucket.makeStructDefinition(); Type.OriginalName() = "First"; Bucket.commit(); revng_check(Binary->TypeDefinitions().size() == 1); revng_check((*Binary->TypeDefinitions().begin())->OriginalName() == "First"); - auto [AnotherType, AP] = Bucket.makeStructDefinition(); + auto &&[AnotherType, AP] = Bucket.makeStructDefinition(); AnotherType.OriginalName() = "Second"; Bucket.drop(); revng_check(Binary->TypeDefinitions().size() == 1); revng_check((*Binary->TypeDefinitions().begin())->OriginalName() == "First"); - auto [OneMoreType, _] = Bucket.makeStructDefinition(); + auto &&[OneMoreType, _] = Bucket.makeStructDefinition(); OneMoreType.OriginalName() = "Third"; Bucket.commit(); @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(Paths) { model::UpcastableType Saved; { model::TypeBucket Bucket = *Binary; - auto [Definition, Type] = Bucket.makeStructDefinition(); + auto &&[Definition, Type] = Bucket.makeStructDefinition(); Definition.OriginalName() = "Valid"; revng_check(Binary->TypeDefinitions().size() == 0); diff --git a/tools/pipeline/Main.cpp b/tools/pipeline/Main.cpp index 57dd1f06d..f8d80ffa5 100644 --- a/tools/pipeline/Main.cpp +++ b/tools/pipeline/Main.cpp @@ -114,7 +114,7 @@ parseProductionRequest(Runner &Pipeline, const auto &Registry = Pipeline.getKindsRegistry(); for (const auto &Target : Targets) { - auto [StepName, Rest] = Target.split("/"); + auto &&[StepName, Rest] = Target.split("/"); auto &Step = ToProduce[StepName]; AbortOnError(parseTarget(Pipeline.getContext(), Step, Rest, Registry)); } @@ -125,8 +125,8 @@ parseProductionRequest(Runner &Pipeline, static void runAnalysis(Runner &Pipeline, llvm::StringRef Target) { const auto &Registry = Pipeline.getKindsRegistry(); - auto [Step, Rest] = Target.split("/"); - auto [AnalysisName, Rest2] = Rest.split("/"); + auto &&[Step, Rest] = Target.split("/"); + auto &&[AnalysisName, Rest2] = Rest.split("/"); ContainerToTargetsMap ToProduce; TargetInStepSet Map; diff --git a/tools/pipeline/invalidate/Main.cpp b/tools/pipeline/invalidate/Main.cpp index 0431ab3c4..73f5254d8 100644 --- a/tools/pipeline/invalidate/Main.cpp +++ b/tools/pipeline/invalidate/Main.cpp @@ -54,7 +54,7 @@ static TargetInStepSet getTargetInStepSet(Runner &Pipeline) { const auto &Registry = Pipeline.getKindsRegistry(); for (llvm::StringRef Target : Targets) { - auto [StepName, Rest] = Target.split("/"); + auto &&[StepName, Rest] = Target.split("/"); auto &ToInvalidate = Invalidations[StepName]; auto &Context = Pipeline.getContext(); AbortOnError(parseTarget(Context, ToInvalidate, Rest, Registry)); diff --git a/tools/trace/inspect/Main.cpp b/tools/trace/inspect/Main.cpp index 88ee20f5c..cf1a07cbe 100644 --- a/tools/trace/inspect/Main.cpp +++ b/tools/trace/inspect/Main.cpp @@ -84,8 +84,8 @@ int main(int argc, char *argv[]) { size_t CommandNo = 0; size_t ArgNo = 0; - auto [CommandNoStr, - ArgNoStr] = StringRef(Options::ExtractBuffer).split(":"); + auto &&[CommandNoStr, + ArgNoStr] = StringRef(Options::ExtractBuffer).split(":"); if (CommandNoStr.getAsInteger(10, CommandNo) || ArgNoStr.getAsInteger(10, ArgNo)) { dbg << "Error parsing extract value\n";