[PATCH] D78781: [mlir][DictionaryAttr] Add a new getWithSorted and use it when possible

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 17:22:13 PDT 2020


mehdi_amini added inline comments.


================
Comment at: mlir/lib/IR/Attributes.cpp:101
+  // a difference.
+  return strncmp(attr.first.data(), name.data(), name.size()) < 0;
+}
----------------
rriddle wrote:
> mehdi_amini wrote:
> > If Attr is a non zero terminated string that is a prefix of name, won’t this read out of bound?
> Attr guarantees null termination because it uses Identifier.
Oh I was on my phone and mis-read ` This is correct even when attr.first.data() is not a zero terminated string`

Actually the comment is adding more confusion than it helps for me: the comparison is obviously correct as long as attr is null terminated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78781





More information about the llvm-commits mailing list