[llvm] 72e5786 - [DebugInfo] DWARF - Use const-ref iterator in for-range loop. NFCI.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 21 20:31:11 PDT 2021
On Fri, Sep 17, 2021 at 6:10 AM Simon Pilgrim via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
>
> Author: Simon Pilgrim
> Date: 2021-09-17T14:04:54+01:00
> New Revision: 72e57862818c92617e22595923cb0a2ed49d603c
>
> URL:
> https://github.com/llvm/llvm-project/commit/72e57862818c92617e22595923cb0a2ed49d603c
> DIFF:
> https://github.com/llvm/llvm-project/commit/72e57862818c92617e22595923cb0a2ed49d603c.diff
>
> LOG: [DebugInfo] DWARF - Use const-ref iterator in for-range loop. NFCI.
>
Thanks for the cleanup - though the commit message confused me until I
checked the code: These aren't iterators that are being changed, they're
the "value" (for want of any other better term) in a range-based for loop.
(iterators, on the other hand, - generally should be handled by value - not
by reference)
>
> Avoid unnecessary copies, reported by MSVC static analyzer.
>
> Added:
>
>
> Modified:
> llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
> llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
> b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
> index 28d35b609c24..c77d4d4d989c 100644
> --- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
> +++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
> @@ -767,7 +767,7 @@ LLVM_DUMP_METHOD void
> DWARFDebugNames::NameIndex::dump(ScopedPrinter &W) const {
> }
>
> W.startLine() << "Hash table not present\n";
> - for (NameTableEntry NTE : *this)
> + for (const NameTableEntry &NTE : *this)
> dumpName(W, NTE, None);
> }
>
> @@ -799,7 +799,7 @@
> DWARFDebugNames::ValueIterator::findEntryOffsetInCurrentIndex() {
> const Header &Hdr = CurrentIndex->Hdr;
> if (Hdr.BucketCount == 0) {
> // No Hash Table, We need to search through all names in the Name
> Index.
> - for (NameTableEntry NTE : *CurrentIndex) {
> + for (const NameTableEntry &NTE : *CurrentIndex) {
> if (NTE.getString() == Key)
> return NTE.getEntryOffset();
> }
>
> diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
> b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
> index addf78ed4b2d..11301175768e 100644
> --- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
> +++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
> @@ -430,7 +430,7 @@ unsigned DWARFVerifier::verifyDieRanges(const DWARFDie
> &Die,
>
> if (!IsObjectFile || IsMachOObject || Die.getTag() !=
> DW_TAG_compile_unit) {
> bool DumpDieAfterError = false;
> - for (auto Range : Ranges) {
> + for (const auto &Range : Ranges) {
> if (!Range.valid()) {
> ++NumErrors;
> error() << "Invalid address range " << Range << "\n";
> @@ -1515,7 +1515,7 @@ unsigned DWARFVerifier::verifyDebugNames(const
> DWARFSection &AccelSection,
> if (NumErrors > 0)
> return NumErrors;
> for (const auto &NI : AccelTable)
> - for (DWARFDebugNames::NameTableEntry NTE : NI)
> + for (const DWARFDebugNames::NameTableEntry &NTE : NI)
> NumErrors += verifyNameIndexEntries(NI, NTE);
>
> if (NumErrors > 0)
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210921/62f53a89/attachment.html>
More information about the llvm-commits
mailing list