From: Axel Naumann Date: Tue, 23 Sep 2014 13:17:04 +0000 (+0200) Subject: Remove skip counting; centralize skip logging. X-Git-Tag: v6-02-00-rc1~21 X-Git-Url: https://root.cern.ch/gitweb?p=root.git;a=commitdiff_plain;h=6981e120a48223c423da26b93fdc5fac66f71149 Remove skip counting; centralize skip logging. --- diff --git a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp index adf195b..449d51f 100644 --- a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp +++ b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.cpp @@ -36,9 +36,6 @@ namespace cling { m_StreamStack.push(&OutS); - m_SkipCounter = 0; - m_TotalDecls = 0; - llvm::SmallVector builtinNames; m_Ctx.BuiltinInfo.GetBuiltinNames(builtinNames); @@ -94,7 +91,7 @@ namespace cling { // continue; Visit(*dit); - skipCurrentDecl(false); + resetSkip(); } } @@ -117,12 +114,12 @@ namespace cling { // Already fwd declared or skipped. if (!Insert.first->second) { // Already skipped before; notify callers. - skipCurrentDecl(true); + skipDecl(D, 0); } return; } if (shouldSkip(D)) { - skipCurrentDecl(true); + // shouldSkip() called skipDecl() m_Visited[getCanonicalOrNamespace(D)] = false; } else { StreamRAII Stream(*this); @@ -130,7 +127,7 @@ namespace cling { clang::DeclVisitor::Visit(D); if (m_SkipFlag) { // D was not good, flag it. - skipCurrentDecl(true); + skipDecl(D, "Dependency skipped"); m_Visited[getCanonicalOrNamespace(D)] = false; } else { Out() << closeBraces; @@ -225,7 +222,7 @@ namespace cling { QualType q = D->getTypeSourceInfo()->getType(); Visit(q); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "Underlying type failed"); return; } @@ -297,7 +294,7 @@ namespace cling { Visit(D->getReturnType()); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "Return type failed"); return; } @@ -344,7 +341,7 @@ namespace cling { if (i) Out() << ", "; Visit(D->getParamDecl(i)); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "Parameter failed"); return; } } @@ -523,9 +520,6 @@ namespace cling { // D->getBody()->printPretty(Out, 0, SubPolicy, Indentation); } - if (m_SkipFlag) { - return; - } } void ForwardDeclPrinter::VisitFriendDecl(FriendDecl *D) { @@ -568,7 +562,7 @@ namespace cling { Visit(T); if (m_SkipFlag) { - skipCurrentDecl(); + skipDecl(D, "Variable type failed."); return; } @@ -694,7 +688,7 @@ namespace cling { for (auto dit=D->decls_begin();dit!=D->decls_end();++dit) { Visit(*dit); haveAnyDecl |= !m_SkipFlag; - skipCurrentDecl(false); + m_SkipFlag = false; } if (!haveAnyDecl) { // make sure at least one redecl of this namespace is fwd declared. @@ -708,7 +702,7 @@ namespace cling { void ForwardDeclPrinter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { Visit(D->getNominatedNamespace()); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "Using directive's underlying namespace failed"); return; } @@ -724,7 +718,7 @@ namespace cling { Visit(Shadow); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "shadow decl failed"); return; } D->print(Out(),m_Policy); @@ -733,7 +727,7 @@ namespace cling { void ForwardDeclPrinter::VisitUsingShadowDecl(UsingShadowDecl *D) { Visit(D->getTargetDecl()); if (m_SkipFlag) - skipCurrentDecl(true); + skipDecl(D, "target decl failed."); } void ForwardDeclPrinter::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { @@ -764,7 +758,7 @@ namespace cling { void ForwardDeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) { for (auto it = D->decls_begin(); it != D->decls_end(); ++it) { Visit(*it); - skipCurrentDecl(false); + resetSkip(); } } @@ -807,7 +801,7 @@ namespace cling { = utils::TypeName::GetFullyQualifiedType(ArgQT, m_Ctx); Visit(ArgFQQT); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(0, "type template param default failed"); return; } Stream << " = "; @@ -830,7 +824,7 @@ namespace cling { if (DeclRefExpr* DRE = dyn_cast(DefArg)) { Visit(DRE->getFoundDecl()); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(0, "expression template param default failed"); return; } } @@ -865,7 +859,7 @@ namespace cling { PrintTemplateParameters(D->getTemplateParameters()); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(0, "Template parameters failed"); return; } @@ -889,14 +883,14 @@ namespace cling { E = D->spec_end(); I != E; ++I) { PrintTemplateParameters(Params, (*I)->getTemplateSpecializationArgs()); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "Template parameters failed"); return; } Visit(*I); } if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "specialization failed"); return; } std::string output = stream.take(true); @@ -915,12 +909,12 @@ namespace cling { E = D->spec_end(); I != E; ++I) { PrintTemplateParameters(Params, &(*I)->getTemplateArgs()); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "template parameters failed"); return; } Visit(*I); if (m_SkipFlag) { - skipCurrentDecl(true); + skipDecl(D, "template instance failed"); return; } std::string output = stream.take(true); @@ -936,7 +930,7 @@ namespace cling { D->printName(Log()); Log() << " ClassTemplateSpecialization : Skipped by default\n"; // if (shouldSkip(D)) { -// skipCurrentDecl(); +// skipDecl(); // return; // } @@ -954,7 +948,7 @@ namespace cling { // iargs[i].print(m_Policy,Out()); // } // Out() << ">"; -// skipCurrentDecl(false); +// skipDecl(false); Visit(D->getSpecializedTemplate()); //Above code doesn't work properly @@ -1102,12 +1096,12 @@ namespace cling { case clang::NestedNameSpecifier::TypeSpec: // fall-through: case clang::NestedNameSpecifier::TypeSpecWithTemplate: // We cannot fwd declare nested types. - skipCurrentDecl(true); + skipDecl(0, "NestedNameSpec TypeSpec/TypeSpecWithTemplate"); break; default: Log() << "VisitNestedNameSpecifier: Unexpected kind " << NNS->getKind() << '\n'; - skipCurrentDecl(true); + skipDecl(0, 0); break; }; } @@ -1171,11 +1165,13 @@ namespace cling { return false; } - void ForwardDeclPrinter::skipCurrentDecl(bool skip) { - m_SkipFlag = skip; - if (skip) - m_SkipCounter++; - m_TotalDecls++; + void ForwardDeclPrinter::skipDecl(Decl* D, const char* Reason) { + m_SkipFlag = true; + if (Reason) { + if (D) + Log() << D->getDeclKindName() << " " << getNameIfPossible(D) << " "; + Log() << Reason << '\n'; + } } bool ForwardDeclPrinter::shouldSkipImpl(ClassTemplateSpecializationDecl *D) { @@ -1239,7 +1235,7 @@ namespace cling { ++numClose; } else { Log() << "Skipping unhandled " << DC->getDeclKindName() << '\n'; - skipCurrentDecl(false); + skipDecl(0, 0); return ""; } } diff --git a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.h b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.h index af978e1..8d16b7a 100644 --- a/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.h +++ b/interpreter/cling/lib/Interpreter/ForwardDeclPrinter.h @@ -100,8 +100,6 @@ namespace cling { //False by default, true if current item is not to be printed llvm::DenseMap m_Visited; // fwd decl success - int m_SkipCounter; - int m_TotalDecls; std::stack m_StreamStack; std::set m_BuiltinNames; @@ -183,18 +181,19 @@ namespace cling { if (DCKind != clang::Decl::Namespace && DCKind != clang::Decl::TranslationUnit && DCKind != clang::Decl::LinkageSpec) { - Log() << getNameIfPossible(D) <<" Incompatible DeclContext\n"; - skipCurrentDecl(true); + Log() << getNameIfPossible(D) <<" \n"; + skipDecl(D, "Incompatible DeclContext"); } else { if (clang::NamedDecl* ND = clang::dyn_cast(D)) { if (clang::IdentifierInfo* II = ND->getIdentifier()) { if (m_BuiltinNames.find(II->getNameStart()) != m_BuiltinNames.end() || !strncmp(II->getNameStart(), "__builtin_", 10)) - skipCurrentDecl(true); + skipDecl(D, "builtin"); } } if (!m_SkipFlag) - skipCurrentDecl(shouldSkipImpl(D)); + if (shouldSkipImpl(D)) + skipDecl(D, "shouldSkip"); } if (m_SkipFlag) { // Remember that we have tried to fwd declare this already. @@ -206,7 +205,8 @@ namespace cling { bool ContainsIncompatibleName(clang::TemplateParameterList* Params); - void skipCurrentDecl(bool skip = true); + void skipDecl(clang::Decl* D, const char* Reason); + void resetSkip() { m_SkipFlag = false; } void printStats(); private: