diff options
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 15a20bd050..f0d32c75de 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -341,6 +341,26 @@ bool FunctionDecl::isExternC(ASTContext &Context) const { return false; } +bool FunctionDecl::isGlobal() const { + if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(this)) + return Method->isStatic(); + + if (getStorageClass() == Static) + return false; + + for (const DeclContext *DC = getDeclContext(); + DC->isNamespace(); + DC = DC->getParent()) { + if (const NamespaceDecl *Namespace = cast<NamespaceDecl>(DC)) { + if (!Namespace->getDeclName()) + return false; + break; + } + } + + return true; +} + /// \brief Returns a value indicating whether this function /// corresponds to a builtin function. /// |