[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (5/7)
Juan Manuel Martinez CaamaƱo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 20 05:22:22 PDT 2023
jmmartinez accepted this revision.
jmmartinez added inline comments.
This revision is now accepted and ready to land.
================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:712-714
+ assert(!getAbstractScopeDIEs().count(DS) &&
+ "Abstract DIE for this scope exists!");
+ getAbstractScopeDIEs()[DS] = ScopeDIE;
----------------
krisb wrote:
> jmmartinez wrote:
> > NIT: You could use `insert/try_emplace` instead of using `count` and `operator[]`. The assertion would become something like:
> > ```
> > auto Inserted = getAbstractScopeDIEs().try_emplace(DS, ScopeDIE);
> > assert(Inserted.second && "Abstract DIE for this scope exists!");
> > return ScopeDIE;
> > ```
> I'd slightly prefer to keep the original code as it looks a bit more readable to me (in your example, there should be another line to void out unused `Inserted` variable, otherwise it'd cause a warning).
> Additional `count()` call in the `assert()` doesn't seem too expensive to me, but if you still think `try_emplace()` is better, I'll change to it.
Ok for me. If the use of count was outside the assert I would have argued against.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144006/new/
https://reviews.llvm.org/D144006
More information about the llvm-commits
mailing list