aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2019-06-11 22:40:33 +0100
committerSergio Martins <smartins@kde.org>2019-06-11 22:40:33 +0100
commit5e226f6cf876137f2e71c9e57bd2a1e5221a64b4 (patch)
tree2a7821918f776c4a3487e694d304eb4160c24087
parent019f936ee7377e21c9649415efce399933adf7a1 (diff)
Add FunctionUtils::getFunctionDeclaration()
-rw-r--r--src/FunctionUtils.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/FunctionUtils.h b/src/FunctionUtils.h
index 37504b0b..ca7f6cc0 100644
--- a/src/FunctionUtils.h
+++ b/src/FunctionUtils.h
@@ -114,5 +114,25 @@ inline bool classImplementsMethod(const clang::CXXRecordDecl *record, const clan
return false;
}
+inline clang::FunctionDecl* getFunctionDeclaration(clang::CXXMethodDecl *method)
+{
+ if (!method->doesThisDeclarationHaveABody() || method->hasInlineBody())
+ return method;
+
+ for (auto redecl : method->redecls()) {
+ auto redecl_method = llvm::dyn_cast<clang::CXXMethodDecl>(redecl);
+ if (!redecl_method->doesThisDeclarationHaveABody() || redecl_method->hasInlineBody()) {
+ return redecl;
+ }
+ }
+
+ if (method->isTemplateInstantiation()) {
+ // When specializing a method template we don't declarate it again. The definition is the declaration.
+ return method;
+ }
+
+ return nullptr;
+}
+
}
#endif