Move IsStdClass to cling::utils::Analyze

This commit is contained in:
Philippe Canal 2014-01-31 18:23:32 -06:00 committed by sftnight
parent d6dfcf82a8
commit 1004034c75
2 changed files with 30 additions and 0 deletions

View File

@ -77,6 +77,12 @@ namespace utils {
bool omitDeclStmts = true,
clang::Sema* S = 0);
///\brief Return true if the class or template is declared directly in the
/// std namespace (modulo inline namespace).
///
///\param[in] decl - The declaration being analyzed.
bool IsStdClass(const clang::NamedDecl &cl);
///\brief Return true if the decl has been declared in ths std namespace
/// or is a compiler details (in __gnu_cxx and starting with a leading
/// underscore).

View File

@ -534,6 +534,30 @@ namespace utils {
return false;
}
bool Analyze::IsStdClass(const clang::NamedDecl &cl)
{
// Return true if the class or template is declared directly in the
// std namespace (modulo inline namespace).
const clang::DeclContext *ctx = cl.getDeclContext();
while (ctx && ctx->isInlineNamespace()) {
ctx = ctx->getParent();
}
if (ctx && ctx->isNamespace())
{
const clang::NamedDecl *parent = llvm::dyn_cast<clang::NamedDecl> (ctx);
if (parent) {
if (parent->getDeclContext()->isTranslationUnit()
&& parent->getQualifiedNameAsString()=="std") {
return true;
}
}
}
return false;
}
static bool IsCompilerDetails(const TagType *tagTy)
{
// Return true if the TagType is a 'details' of the std implementation.