diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-10-16 22:42:53 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-10-16 22:42:53 +0000 |
commit | dc6d797fc1dcf1a26aceaf7422d0f5833108668c (patch) | |
tree | db605e4bcd7e307878d78020e113c3e6b98c4ca2 /lib/Sema/SemaStmt.cpp | |
parent | 37b2d70b2ffbbafaf74427628e5d5c7b94b2498c (diff) |
Sema: handle additional case of qualified types
A second instance of attributed types escaped the previous change, identified
thanks to Richard Smith! When deducing the void case, we would also assume that
the type would not be attributed. Furthermore, properly handle multiple
attributes being applied to a single TypeLoc.
Properly handle this case and future-proof a bit by ignoring parenthesis
further. The test cases do use the additional parenthesis to ensure that this
case remains properly handled.
Addresses post-commit review comments from Richard Smith to SVN r219851.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219974 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 7efcb2e9c4..8a28b29a1c 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2755,17 +2755,20 @@ bool LocalTypedefNameReferencer::VisitRecordType(const RecordType *RT) { } } +TypeLoc Sema::getReturnTypeLoc(FunctionDecl *FD) const { + TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc(); + while (auto ATL = TL.getAs<AttributedTypeLoc>()) + TL = ATL.getModifiedLoc().IgnoreParens(); + return TL.IgnoreParens().castAs<FunctionProtoTypeLoc>().getReturnLoc(); +} + /// Deduce the return type for a function from a returned expression, per /// C++1y [dcl.spec.auto]p6. bool Sema::DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD, SourceLocation ReturnLoc, Expr *&RetExpr, AutoType *AT) { - TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc(); - if (auto ATL = TL.getAs<AttributedTypeLoc>()) - TL = ATL.getModifiedLoc(); - TypeLoc OrigResultType = - TL.IgnoreParens().castAs<FunctionProtoTypeLoc>().getReturnLoc(); + TypeLoc OrigResultType = getReturnTypeLoc(FD); QualType Deduced; if (RetExpr && isa<InitListExpr>(RetExpr)) { |