[all-commits] [llvm/llvm-project] cb08f4: Support warn_unused_result on typedefs

David Blaikie via All-commits all-commits at lists.llvm.org
Thu Jun 2 13:57:47 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cb08f4aa4467cf562b62e542725f5351c5482495
      https://github.com/llvm/llvm-project/commit/cb08f4aa4467cf562b62e542725f5351c5482495
  Author: David Blaikie <dblaikie at gmail.com>
  Date:   2022-06-02 (Thu, 02 Jun 2022)

  Changed paths:
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttributeCommonInfo.h
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/AST/Expr.cpp
    M clang/lib/Basic/Attributes.cpp
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp
    M clang/test/Misc/pragma-attribute-supported-attributes-list.test
    M clang/test/Sema/c2x-nodiscard.c
    M clang/test/Sema/unused-expr.c
    M clang/test/SemaCXX/warn-unused-result.cpp

  Log Message:
  -----------
  Support warn_unused_result on typedefs

While it's not as robust as using the attribute on enums/classes (the
type information may be lost through a function pointer, a declaration
or use of the underlying type without using the typedef, etc) but I
think there's still value in being able to attribute a typedef and have
all return types written with that typedef pick up the
warn_unused_result behavior.

Specifically I'd like to be able to annotate LLVMErrorRef (a wrapper for
llvm::Error used in the C API - the underlying type is a raw pointer, so
it can't be attributed itself) to reduce the chance of unhandled errors.

Differential Revision: https://reviews.llvm.org/D102122




More information about the All-commits mailing list