diff options
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 69e44573dc6..2ae73de5074 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2822,6 +2822,18 @@ SourceRange FunctionDecl::getReturnTypeSourceRange() const { return RTRange; } +bool FunctionDecl::hasUnusedResultAttr() const { + QualType RetType = getReturnType(); + if (RetType->isRecordType()) { + const CXXRecordDecl *Ret = RetType->getAsCXXRecordDecl(); + const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(this); + if (Ret && Ret->hasAttr<WarnUnusedResultAttr>() && + !(MD && MD->getCorrespondingMethodInClass(Ret, true))) + return true; + } + return hasAttr<WarnUnusedResultAttr>(); +} + /// \brief For an inline function definition in C, or for a gnu_inline function /// in C++, determine whether the definition will be externally visible. /// |

