diff options
author | Richard Trieu <rtrieu@google.com> | 2014-05-28 02:16:01 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2014-05-28 02:16:01 +0000 |
commit | c771d5d79f6ad3a9996cc6125791cce9b1a8a8f4 (patch) | |
tree | 2173f4a56c2b0cfedacbc5748392654d87f6210c /clang/lib/AST/DeclBase.cpp | |
parent | cda69a279dd71f50b87996eeee203bdd51b65961 (diff) | |
download | bcm5719-llvm-c771d5d79f6ad3a9996cc6125791cce9b1a8a8f4.tar.gz bcm5719-llvm-c771d5d79f6ad3a9996cc6125791cce9b1a8a8f4.zip |
Move the logic for testing for namespace std into one location. This check can
be performed by using Decl::isInStdNamespace or DeclContext::isStdNamespace
llvm-svn: 209708
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 1743b91454c..2b1506d191d 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -251,6 +251,10 @@ bool Decl::isInAnonymousNamespace() const { return false; } +bool Decl::isInStdNamespace() const { + return getDeclContext()->isStdNamespace(); +} + TranslationUnitDecl *Decl::getTranslationUnitDecl() { if (TranslationUnitDecl *TUD = dyn_cast<TranslationUnitDecl>(this)) return TUD; @@ -795,6 +799,22 @@ bool DeclContext::isInlineNamespace() const { cast<NamespaceDecl>(this)->isInline(); } +bool DeclContext::isStdNamespace() const { + if (!isNamespace()) + return false; + + const NamespaceDecl *ND = cast<NamespaceDecl>(this); + if (ND->isInline()) { + return ND->getParent()->isStdNamespace(); + } + + if (!getParent()->getRedeclContext()->isTranslationUnit()) + return false; + + const IdentifierInfo *II = ND->getIdentifier(); + return II && II->isStr("std"); +} + bool DeclContext::isDependentContext() const { if (isFileContext()) return false; |