[PATCH] D102122: Support warn_unused_result on typedefs

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 25 19:20:47 PDT 2022


rsmith added inline comments.


================
Comment at: clang/include/clang/Basic/Attr.td:2943
+def WarnUnusedResultClang : InheritableAttr {
+  let Spellings = [CXX11<"clang", "warn_unused_result">];
+  let Subjects = SubjectList<[ObjCMethod, Enum, Record, FunctionLike, TypedefName]>;
----------------
Should we allow this new behavior for the GNU attribute spelling too? (Not `[[gnu::..]]` but `__attribute__((warn_unused_result))`). We don't generally avoid extending the meaning of `__attribute__((...))` compared to GCC.


================
Comment at: clang/lib/AST/Expr.cpp:1525-1527
+  if (const auto *TD = getCallReturnType(Ctx)->getAs<TypedefType>())
+    if (const auto *A = TD->getDecl()->getAttr<WarnUnusedResultAttr>())
+      return A;
----------------
This should loop over `TypedefType` sugar; the attribute could be in a nested typedef.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102122



More information about the cfe-commits mailing list