cxxMethodDecl(
allOf(isConst(), isDefinitionOrInline(),
unless(anyOf(
- returns(voidType()), isNoReturn(), isOverloadedOperator(),
+ returns(voidType()),
+ returns(hasDeclaration(decl(hasAttr(clang::attr::WarnUnusedResult)))),
+ isNoReturn(), isOverloadedOperator(),
isVariadic(), hasTemplateReturnType(),
hasClassMutableFields(), isConversionOperator(),
hasAttr(clang::attr::WarnUnusedResult),
typedef unsigned &my_unsigned_reference;
typedef const unsigned &my_unsigned_const_reference;
+struct NO_DISCARD NoDiscardStruct{};
+
class Foo {
public:
using size_type = unsigned;
// Do not add ``[[nodiscard]]`` to conversion functions.
// explicit operator bool() const { return true; }
+
+ // Do not add ``[[nodiscard]]`` to functions returning types marked [[nodiscard]].
+ NoDiscardStruct f50() const;
};
// Do not add ``[[nodiscard]]`` to Lambda.