From 27df8a662bbc1809b63e8b8d2fa3663ccc16100b Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Mon, 22 Sep 2014 15:51:59 +0200 Subject: [PATCH] Introduce ASTContext member. --- .../cling/lib/Interpreter/ForwardDeclPrinter.cpp | 20 ++++++++++++-------- .../cling/lib/Interpreter/ForwardDeclPrinter.h | 9 +++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp index 6edc818..bc5ce85 100644 --- a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp +++ b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp @@ -28,7 +28,7 @@ namespace cling { bool printMacros) : m_Policy(clang::PrintingPolicy(clang::LangOptions())), m_Log(LogS), m_Indentation(Indentation), m_SMgr(S.getSourceManager()), - m_SkipFlag(false) { + m_Ctx(S.getASTContext()), m_SkipFlag(false) { m_PrintInstantiation = false; m_Policy.SuppressTagKeyword = true; @@ -40,7 +40,7 @@ namespace cling { m_TotalDecls = 0; llvm::SmallVector builtinNames; - S.getASTContext().BuiltinInfo.GetBuiltinNames(builtinNames); + m_Ctx.BuiltinInfo.GetBuiltinNames(builtinNames); m_BuiltinNames.insert(builtinNames.begin(), builtinNames.end()); @@ -106,6 +106,10 @@ namespace cling { } } + void ForwardDeclPrinter::Visit(clang::QualType QT) { + QT = utils::TypeName::GetFullyQualifiedType(QT, m_Ctx); + Visit(QT.getTypePtr()); + } void ForwardDeclPrinter::Visit(clang::Decl *D) { auto Insert = m_Visited.insert(std::pair( getCanonicalOrNamespace(D), true)); @@ -525,7 +529,7 @@ namespace cling { Out() << "mutable "; if (!m_Policy.SuppressSpecifiers && D->isModulePrivate()) Out() << "__module_private__ "; - Out() << D->getASTContext().getUnqualifiedObjCPointerType(D->getType()). + Out() << m_Ctx.getUnqualifiedObjCPointerType(D->getType()). stream(m_Policy, D->getName()); if (D->isBitField()) { @@ -553,7 +557,7 @@ namespace cling { void ForwardDeclPrinter::VisitVarDecl(VarDecl *D) { QualType T = D->getTypeSourceInfo() ? D->getTypeSourceInfo()->getType() - : D->getASTContext().getUnqualifiedObjCPointerType(D->getType()); + : m_Ctx.getUnqualifiedObjCPointerType(D->getType()); Visit(T); if (m_SkipFlag) { @@ -814,8 +818,7 @@ namespace cling { } if (!ArgQT.isNull()) { QualType ArgFQQT - = utils::TypeName::GetFullyQualifiedType(ArgQT, - TTP->getASTContext()); + = utils::TypeName::GetFullyQualifiedType(ArgQT, m_Ctx); Out() << " = "; ArgFQQT.print(Out(), m_Policy); } @@ -1108,13 +1111,14 @@ namespace cling { break; case clang::NestedNameSpecifier::TypeSpec: // fall-through: case clang::NestedNameSpecifier::TypeSpecWithTemplate: - Visit(NNS->getAsType()); + // We cannot fwd declare nested types. + skipCurrentDecl(true); break; default: Log() << "VisitNestedNameSpecifier: Unexpected kind " << NNS->getKind() << '\n'; + skipCurrentDecl(true); break; - }; } diff --git a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.h b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.h index 34f7bc0..18ef30c 100644 --- a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.h +++ b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.h @@ -95,6 +95,7 @@ namespace cling { unsigned m_Indentation; bool m_PrintInstantiation; clang::SourceManager& m_SMgr; + clang::ASTContext& m_Ctx; bool m_SkipFlag; //False by default, true if current item is not to be printed @@ -144,11 +145,7 @@ namespace cling { void VisitTypeAliasTemplateDecl(clang::TypeAliasTemplateDecl* D); // Not coming from the RecursiveASTVisitor - void Visit(clang::QualType QT) { - QT = utils::TypeName::GetFullyQualifiedType(QT); - QT = utils::Transform::GetPartiallyDesugaredType(QT); - Visit(.getTypePtr()); - } + void Visit(clang::QualType QT); void Visit(const clang::Type* T); void VisitNestedNameSpecifier(const clang::NestedNameSpecifier* NNS); void VisitTemplateArgument(const clang::TemplateArgument& TA); @@ -181,7 +178,7 @@ namespace cling { } template bool shouldSkip(T* D) { - // Anything inside DCs except those bwloe cannot be fwd declared. + // Anything inside DCs except those below cannot be fwd declared. clang::Decl::Kind DCKind = D->getDeclContext()->getDeclKind(); if (DCKind != clang::Decl::Namespace && DCKind != clang::Decl::TranslationUnit -- 1.8.2