From d052a578de58cbbb638cbe2dba05242d1ff443b9 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Oct 2019 17:44:08 -0700 Subject: [c++2a] Allow comparison functions to be explicitly defaulted. This adds some initial syntactic checking that only the appropriate function signatures can be defaulted. No implicit definitions are generated yet. --- clang/lib/AST/Decl.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'clang/lib/AST/Decl.cpp') diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 80235d8496d..dae4af8bb24 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3322,12 +3322,14 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const { return FoundBody; } -SourceRange FunctionDecl::getReturnTypeSourceRange() const { +FunctionTypeLoc FunctionDecl::getFunctionTypeLoc() const { const TypeSourceInfo *TSI = getTypeSourceInfo(); - if (!TSI) - return SourceRange(); - FunctionTypeLoc FTL = - TSI->getTypeLoc().IgnoreParens().getAs(); + return TSI ? TSI->getTypeLoc().IgnoreParens().getAs() + : FunctionTypeLoc(); +} + +SourceRange FunctionDecl::getReturnTypeSourceRange() const { + FunctionTypeLoc FTL = getFunctionTypeLoc(); if (!FTL) return SourceRange(); @@ -3343,15 +3345,8 @@ SourceRange FunctionDecl::getReturnTypeSourceRange() const { } SourceRange FunctionDecl::getExceptionSpecSourceRange() const { - const TypeSourceInfo *TSI = getTypeSourceInfo(); - if (!TSI) - return SourceRange(); - FunctionTypeLoc FTL = - TSI->getTypeLoc().IgnoreParens().getAs(); - if (!FTL) - return SourceRange(); - - return FTL.getExceptionSpecRange(); + FunctionTypeLoc FTL = getFunctionTypeLoc(); + return FTL ? FTL.getExceptionSpecRange() : SourceRange(); } /// For an inline function definition in C, or for a gnu_inline function -- cgit v1.2.3