|
16 | 16 | #include "clang/AST/APNumericStorage.h"
|
17 | 17 | #include "clang/AST/APValue.h"
|
18 | 18 | #include "clang/AST/ASTVector.h"
|
| 19 | +#include "clang/AST/Attr.h" |
19 | 20 | #include "clang/AST/ComputeDependence.h"
|
20 | 21 | #include "clang/AST/Decl.h"
|
21 | 22 | #include "clang/AST/DeclAccessPair.h"
|
@@ -262,6 +263,12 @@ class Expr : public ValueStmt {
|
262 | 263 | SourceRange &R1, SourceRange &R2,
|
263 | 264 | ASTContext &Ctx) const;
|
264 | 265 |
|
| 266 | + /// Returns the WarnUnusedResultAttr that is declared on the callee |
| 267 | + /// or its return type declaration, together with a NamedDecl that |
| 268 | + /// refers to the declaration the attribute is attached to. |
| 269 | + static std::pair<const NamedDecl *, const WarnUnusedResultAttr *> |
| 270 | + getUnusedResultAttrImpl(const Decl *Callee, QualType ReturnType); |
| 271 | + |
265 | 272 | /// isLValue - True if this expression is an "l-value" according to
|
266 | 273 | /// the rules of the current language. C and C++ give somewhat
|
267 | 274 | /// different rules for this concept, but in general, the result of
|
@@ -3190,11 +3197,13 @@ class CallExpr : public Expr {
|
3190 | 3197 | /// type.
|
3191 | 3198 | QualType getCallReturnType(const ASTContext &Ctx) const;
|
3192 | 3199 |
|
3193 |
| - /// Returns the WarnUnusedResultAttr that is either declared on the called |
3194 |
| - /// function, or its return type declaration, together with a NamedDecl that |
3195 |
| - /// refers to the declaration the attribute is attached onto. |
3196 |
| - std::pair<const NamedDecl *, const Attr *> |
3197 |
| - getUnusedResultAttr(const ASTContext &Ctx) const; |
| 3200 | + /// Returns the WarnUnusedResultAttr that is declared on the callee |
| 3201 | + /// or its return type declaration, together with a NamedDecl that |
| 3202 | + /// refers to the declaration the attribute is attached to. |
| 3203 | + std::pair<const NamedDecl *, const WarnUnusedResultAttr *> |
| 3204 | + getUnusedResultAttr(const ASTContext &Ctx) const { |
| 3205 | + return getUnusedResultAttrImpl(getCalleeDecl(), getCallReturnType(Ctx)); |
| 3206 | + } |
3198 | 3207 |
|
3199 | 3208 | /// Returns true if this call expression should warn on unused results.
|
3200 | 3209 | bool hasUnusedResultAttr(const ASTContext &Ctx) const {
|
|
0 commit comments