[PATCH] D44105: TableGen: add !isa operation

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 5 17:55:59 PST 2018


tra added inline comments.


================
Comment at: docs/TableGen/LangIntro.rst:213-216
+    Note that this does not consider the possibility of casting between
+    records/objects and strings. That is, a string 'foo' is-not-a 'Bar', even
+    if a record named 'foo' with superclass 'Bar' exists.
+
----------------
I've found this confusing. Why would anyone expect a string argument to !isa<>() to be magically cast to a record? I would after this comment, though. :-) IMO the first line of the description alone is sufficient.


================
Comment at: lib/TableGen/Record.cpp:1235-1238
+  using Key = std::pair<RecTy *, Init *>;
+  static DenseMap<Key, IsAOpInit *> ThePool;
+
+  Key TheKey(std::make_pair(CheckType, Expr));
----------------
Why not use FoldingSet we use everywhere else?

I can't tell whether we're in danger of pointer reuse here, though if we are we'd need both `CheckType` and `Expr` to be freed, reallocated and passed to this function simultaneously in order to trigger a problem. Still...



================
Comment at: lib/TableGen/TGParser.cpp:958
+    if (Lex.getCode() != tgtok::r_paren) {
+      TokError("expected ')' in unary operator");
+      return nullptr;
----------------
Did you mean "in `!isa` operator" ?


Repository:
  rL LLVM

https://reviews.llvm.org/D44105





More information about the llvm-commits mailing list