[PATCH] D74423: Use C++14-style return type deduction in clang.
This revision was automatically updated to reflect the committed changes. Closed by commit rGac66c61bf946: Use C++14-style return type deduction in clang. (authored by jlebar). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74423/new/ https://reviews.llvm.org/D74423 Files: clang/lib/AST/ASTImporter.cpp clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp Index: clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp @@ -54,7 +54,7 @@ OS.str(), Location, Range); } -auto callsName(const char *FunctionName) -> decltype(callee(functionDecl())) { +decltype(auto) callsName(const char *FunctionName) { return callee(functionDecl(hasName(FunctionName))); } Index: clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp @@ -100,8 +100,7 @@ return std::vector(V.begin(), V.end()); } -static auto callsNames(std::vector FunctionNames) --> decltype(callee(functionDecl())) { +static decltype(auto) callsNames(std::vector FunctionNames) { return callee(functionDecl(hasAnyName(toRefs(FunctionNames; } Index: clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp === --- clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp +++ clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp @@ -55,8 +55,7 @@ CE->getSourceRange()); } -static auto hasTypePointingTo(DeclarationMatcher DeclM) --> decltype(hasType(pointerType())) { +static decltype(auto) hasTypePointingTo(DeclarationMatcher DeclM) { return hasType(pointerType(pointee(hasDeclaration(DeclM; } Index: clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp @@ -52,18 +52,16 @@ BugReporter ) const; }; -auto callsName(const char *FunctionName) --> decltype(callee(functionDecl())) { +decltype(auto) callsName(const char *FunctionName) { return callee(functionDecl(hasName(FunctionName))); } -auto equalsBoundArgDecl(int ArgIdx, const char *DeclName) --> decltype(hasArgument(0, expr())) { +decltype(auto) equalsBoundArgDecl(int ArgIdx, const char *DeclName) { return hasArgument(ArgIdx, ignoringParenCasts(declRefExpr( to(varDecl(equalsBoundNode(DeclName)); } -auto bindAssignmentToDecl(const char *DeclName) -> decltype(hasLHS(expr())) { +decltype(auto) bindAssignmentToDecl(const char *DeclName) { return hasLHS(ignoringParenImpCasts( declRefExpr(to(varDecl().bind(DeclName); } Index: clang/lib/AST/ASTImporter.cpp === --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -204,9 +204,7 @@ // Wrapper for an overload set. template struct CallOverloadedCreateFun { - template - auto operator()(Args &&... args) - -> decltype(ToDeclT::Create(std::forward(args)...)) { + template decltype(auto) operator()(Args &&... args) { return ToDeclT::Create(std::forward(args)...); } }; Index: clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp @@ -54,7 +54,7 @@ OS.str(), Location, Range); } -auto callsName(const char *FunctionName) -> decltype(callee(functionDecl())) { +decltype(auto) callsName(const char *FunctionName) { return callee(functionDecl(hasName(FunctionName))); } Index: clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp @@ -100,8 +100,7 @@ return std::vector(V.begin(), V.end()); } -static auto callsNames(std::vector FunctionNames) --> decltype(callee(functionDecl())) { +static decltype(auto) callsNames(std::vector FunctionNames) { return
[PATCH] D74423: Use C++14-style return type deduction in clang.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. lg Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74423/new/ https://reviews.llvm.org/D74423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D74423: Use C++14-style return type deduction in clang.
jlebar created this revision. jlebar added reviewers: bkramer, MaskRay. Herald added a reviewer: martong. Herald added a reviewer: shafik. Herald added subscribers: cfe-commits, martong. Herald added a project: clang. Simplifies the C++11-style "-> decltype(...)" return-type deduction. Note that you have to be careful about whether the function return type is `auto` or `decltype(auto)`. The difference is that bare `auto` strips const and reference, just like lambda return type deduction. In some cases that's what we want (or more likely, we know that the return type is a value type), but whenever we're wrapping a templated function which might return a reference, we need to be sure that the return type is decltype(auto). No functional change. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D74423 Files: clang/lib/AST/ASTImporter.cpp clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp Index: clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp @@ -54,7 +54,7 @@ OS.str(), Location, Range); } -auto callsName(const char *FunctionName) -> decltype(callee(functionDecl())) { +decltype(auto) callsName(const char *FunctionName) { return callee(functionDecl(hasName(FunctionName))); } Index: clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/ObjCAutoreleaseWriteChecker.cpp @@ -100,8 +100,7 @@ return std::vector(V.begin(), V.end()); } -static auto callsNames(std::vector FunctionNames) --> decltype(callee(functionDecl())) { +static decltype(auto) callsNames(std::vector FunctionNames) { return callee(functionDecl(hasAnyName(toRefs(FunctionNames; } Index: clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp === --- clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp +++ clang/lib/StaticAnalyzer/Checkers/OSObjectCStyleCast.cpp @@ -55,8 +55,7 @@ CE->getSourceRange()); } -static auto hasTypePointingTo(DeclarationMatcher DeclM) --> decltype(hasType(pointerType())) { +static decltype(auto) hasTypePointingTo(DeclarationMatcher DeclM) { return hasType(pointerType(pointee(hasDeclaration(DeclM; } Index: clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp @@ -52,18 +52,16 @@ BugReporter ) const; }; -auto callsName(const char *FunctionName) --> decltype(callee(functionDecl())) { +decltype(auto) callsName(const char *FunctionName) { return callee(functionDecl(hasName(FunctionName))); } -auto equalsBoundArgDecl(int ArgIdx, const char *DeclName) --> decltype(hasArgument(0, expr())) { +decltype(auto) equalsBoundArgDecl(int ArgIdx, const char *DeclName) { return hasArgument(ArgIdx, ignoringParenCasts(declRefExpr( to(varDecl(equalsBoundNode(DeclName)); } -auto bindAssignmentToDecl(const char *DeclName) -> decltype(hasLHS(expr())) { +decltype(auto) bindAssignmentToDecl(const char *DeclName) { return hasLHS(ignoringParenImpCasts( declRefExpr(to(varDecl().bind(DeclName); } Index: clang/lib/AST/ASTImporter.cpp === --- clang/lib/AST/ASTImporter.cpp +++ clang/lib/AST/ASTImporter.cpp @@ -204,9 +204,7 @@ // Wrapper for an overload set. template struct CallOverloadedCreateFun { - template - auto operator()(Args &&... args) - -> decltype(ToDeclT::Create(std::forward(args)...)) { + template decltype(auto) operator()(Args &&... args) { return ToDeclT::Create(std::forward(args)...); } }; Index: clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp === --- clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp @@ -54,7 +54,7 @@ OS.str(), Location, Range); } -auto callsName(const char *FunctionName) -> decltype(callee(functionDecl())) { +decltype(auto) callsName(const char *FunctionName) { return callee(functionDecl(hasName(FunctionName))); } Index: