[PATCH] D125778: [llvm-dva] 03 - Logical elements

Pavel Samolysov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 01:51:09 PDT 2022


psamolysov added inline comments.


================
Comment at: llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h:188
+  }
+  LVObject &operator=(LVObject const &) = delete;
+  virtual ~LVObject() = default;
----------------
psamolysov wrote:
> CarlosAlbertoEnciso wrote:
> > psamolysov wrote:
> > > We have a copy constructor but no copy assigned operator. Could you explain why? Thank you.
> > Good question. We do not allow any copy/assignment of logical elements.
> > 
> > The only place where we allow copy an LVObject is in `printAttributes` when we need to print some modified attributes for the current object. Those modifications are temporary and are used to create a fake scope.
> > ```
> > void LVObject::printAttributes(raw_ostream &OS, bool Full, StringRef Name,
> >                                LVObject *Parent, StringRef Value,
> >                                bool UseQuotes, bool PrintRef) const {
> >   // The current object will be the enclosing scope, use its offset and level.
> >   LVObject Object(*Parent);
> >   Object.setLevel(Parent->getLevel() + 1);
> >   Object.setLineNumber(0);
> >   Object.printAttributes(OS, Full);
> >   ..
> > }
> > ```
> > 
> In this case, the copy constructor and assignment operator could be `protected`. Thank you for the explanation why the copy constructor is required but assignment operator is not.
Sorry, `protected` or even `private` I mean.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125778/new/

https://reviews.llvm.org/D125778



More information about the llvm-commits mailing list