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

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 30 04:08:16 PDT 2018


nhaehnle 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(); }
----------------
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.


https://reviews.llvm.org/D47525





More information about the llvm-commits mailing list