summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-07-02 01:47:15 +0000
committerAlp Toker <alp@nuanti.com>2014-07-02 01:47:15 +0000
commitd0787ebf5e769ce81c182f8685ca1f6d22d5c592 (patch)
tree28c991916adef4ef6c170eb5a2bb87ae177874fc /clang/lib/AST/Decl.cpp
parent5b336a242c7402f4aecd60ab42f0efa07dacbde8 (diff)
downloadbcm5719-llvm-d0787ebf5e769ce81c182f8685ca1f6d22d5c592.tar.gz
bcm5719-llvm-d0787ebf5e769ce81c182f8685ca1f6d22d5c592.zip
Introduce a FunctionDecl::getReturnTypeSourceRange() utility
This source range is useful for all kinds of diagnostic QOI and refactoring work, so let's make it more discoverable. This commit also makes use of the new function to enhance various diagnostics relating to return types and resolves an old FIXME. llvm-svn: 212154
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index d910a669abf..702a2e32e3e 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2687,6 +2687,23 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
return FoundBody;
}
+SourceRange FunctionDecl::getReturnTypeSourceRange() const {
+ const TypeSourceInfo *TSI = getTypeSourceInfo();
+ if (!TSI)
+ return SourceRange();
+
+ TypeLoc TL = TSI->getTypeLoc();
+ FunctionTypeLoc FunctionTL = TL.getAs<FunctionTypeLoc>();
+ if (!FunctionTL)
+ return SourceRange();
+
+ TypeLoc ResultTL = FunctionTL.getReturnLoc();
+ if (ResultTL.getUnqualifiedLoc().getAs<BuiltinTypeLoc>())
+ return ResultTL.getSourceRange();
+
+ return SourceRange();
+}
+
/// \brief For an inline function definition in C, or for a gnu_inline function
/// in C++, determine whether the definition will be externally visible.
///
OpenPOWER on IntegriCloud