diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 521fc3f2cbc..ec062852789 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9695,6 +9695,30 @@ void Sema::computeNRVO(Stmt *Body, FunctionScopeInfo *Scope) { const_cast<VarDecl*>(NRVOCandidate)->setNRVOVariable(true); } +bool Sema::canDelayFunctionBody(const Declarator &D) { + // We can't delay parsing the body of a constexpr function template (yet). + if (D.getDeclSpec().isConstexprSpecified()) + return false; + + // We can't delay parsing the body of a function template with a deduced + // return type (yet). + if (D.getDeclSpec().containsPlaceholderType()) { + // If the placeholder introduces a non-deduced trailing return type, + // we can still delay parsing it. + if (D.getNumTypeObjects()) { + const auto &Outer = D.getTypeObject(D.getNumTypeObjects() - 1); + if (Outer.Kind == DeclaratorChunk::Function && + Outer.Fun.hasTrailingReturnType()) { + QualType Ty = GetTypeFromParser(Outer.Fun.getTrailingReturnType()); + return Ty.isNull() || !Ty->isUndeducedType(); + } + } + return false; + } + + return true; +} + bool Sema::canSkipFunctionBody(Decl *D) { // We cannot skip the body of a function (or function template) which is // constexpr, since we may need to evaluate its body in order to parse the |