[PATCH] D125784: [llvm-debuginfo-analyzer] 09 - CodeView Reader
Carlos Alberto Enciso via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 19 08:26:25 PDT 2022
CarlosAlbertoEnciso added inline comments.
================
Comment at: llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.cpp:267
+ break;
+ }
+ return std::make_tuple(FirstNamespace, FirstNonNamespace);
----------------
probinson wrote:
> I think this loop could be replaced with something along the lines of
> ```
> LVStringRefs::iterator Iter = std::find_if(Components.begin(), Components.end(),
> [](StringRef Name) {
> return IdentifiedNamespaces.find(Name) == IdentifiedNamespaces.end();
> });
> LVStringRefs::size_type FirstNonNamespace = std::distance(Components.begin(), Iter);
> ```
> find_if returns an iterator into Components for the first non-namespace, and then std::distance gets the index.
Nice suggestion. I tried the change but it seems that `FirstNonNamespace` is always `+1` in relation to the value calculated by the `for` loop.
These version passes all internal/external tests:
```
LVStringRefs::iterator Iter =
std::find_if(Components.begin(), Components.end(), [&](StringRef Name) {
return IdentifiedNamespaces.find(Name) == IdentifiedNamespaces.end();
});
LVStringRefs::size_type FirstNonNamespace =
std::distance(Components.begin(), Iter) - 1;
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125784/new/
https://reviews.llvm.org/D125784
More information about the llvm-commits
mailing list