summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2019-10-22 17:44:08 -0700
committerRichard Smith <richard@metafoo.co.uk>2019-10-22 18:16:17 -0700
commitd052a578de58cbbb638cbe2dba05242d1ff443b9 (patch)
tree2f3ed903007c6a0459234ce4d05c40e8a33889a6 /clang/lib/AST/Decl.cpp
parent437e0e5191ca255db27e86d232020844c1fd08c8 (diff)
downloadbcm5719-llvm-d052a578de58cbbb638cbe2dba05242d1ff443b9.tar.gz
bcm5719-llvm-d052a578de58cbbb638cbe2dba05242d1ff443b9.zip
[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.
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp23
1 files changed, 9 insertions, 14 deletions
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<FunctionTypeLoc>();
+ return TSI ? TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>()
+ : 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<FunctionTypeLoc>();
- 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
OpenPOWER on IntegriCloud