[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 27 17:08:10 PDT 2020


njames93 added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6763
+/// (but not "nodiscard" or "clang::warn_unused_result").
+AST_MATCHER_P(Attr, hasAttrName, llvm::StringRef, Name) {
+  return Node.getAttrName() && Node.getAttrName()->isStr(Name);
----------------
AST_MATCHER macros that take `StringRef` paramaters don't own the data for the string, which will result in UB if they are passed a reference to a string that is destroyed while the matcher is still matching. It's much safer to use `std::string` in this case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743



More information about the cfe-commits mailing list