[PATCH] D47525: [TableGen] Make DAGInstruction own Pattern to avoid leaking it.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 30 04:42:59 PDT 2018


fhahn added inline comments.


================
Comment at: utils/TableGen/CodeGenDAGPatterns.h:924-925
 
-  TreePattern *getPattern() const { return Pattern; }
+  std::unique_ptr<TreePattern> &getPattern() { return Pattern; }
+  const std::unique_ptr<TreePattern> &getPattern() const { return Pattern; }
   unsigned getNumResults() const { return Results.size(); }
----------------
nhaehnle wrote:
> Why do you need a non-const overload here? The pointer itself should never be changed.
> 
> Actually, it would arguably be nicer to just return a reference here, since the fact that the TreePattern is stored in a unique_ptr seems like an implementation detail that callers should not have to worry about.
> Actually, it would arguably be nicer to just return a reference here, since the fact that the TreePattern is stored in a unique_ptr seems like an implementation detail that callers should not have to worry about.

There are some places that check that the pattern is not null, before accessing the value. Having a unique_ptr there seemed just easier. But I suppose we could have something like hasPattern, if you think that would be better?


https://reviews.llvm.org/D47525





More information about the llvm-commits mailing list