Do not print the inherited default arguments.

This commit is contained in:
Vassil Vassilev 2014-07-29 22:18:03 +02:00 committed by sftnight
parent 151a0109f6
commit 03f4edd3c1
3 changed files with 23 additions and 10 deletions

View File

@ -668,8 +668,7 @@ namespace cling {
void ForwardDeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
if(/*ClassDeclNames.find(D->getNameAsString()) != ClassDeclNames.end()
|| */D->getNameAsString().size() == 0) {
if(D->getNameAsString().size() == 0) {
m_SkipFlag = true;
return;
}
@ -712,8 +711,6 @@ namespace cling {
// }
Out << ";\n";
m_SkipFlag = true;
if(D->isCompleteDefinition())
ClassDeclNames.insert(D->getNameAsString());
}
void ForwardDeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
@ -771,7 +768,8 @@ namespace cling {
if (Args) {
Out << " = ";
Args->get(i).print(Policy, Out);
} else if (TTP->hasDefaultArgument() && TTP->getName().size() != 0 /*Workaround*/) {
} else if (TTP->hasDefaultArgument() &&
!TTP->defaultArgumentWasInherited()) {
Out << " = ";
Out << TTP->getDefaultArgument().getAsString(Policy);
};
@ -789,7 +787,8 @@ namespace cling {
if (Args) {
Out << " = ";
Args->get(i).print(Policy, Out);
} else if (NTTP->hasDefaultArgument()) {
} else if (NTTP->hasDefaultArgument() &&
!NTTP->defaultArgumentWasInherited()) {
Out << " = ";
NTTP->getDefaultArgument()->printPretty(Out, 0, Policy, Indentation);
}
@ -837,8 +836,7 @@ namespace cling {
}
void ForwardDeclPrinter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
if(/*ClassDeclNames.find(D->getNameAsString()) != ClassDeclNames.end()
|| */D->getName().size() == 0 ) {
if(D->getName().size() == 0 ) {
m_SkipFlag = true;
return;
}

View File

@ -29,7 +29,6 @@ namespace cling {
void Print(clang::AccessSpecifier AS);
std::set<std::string> ClassDeclNames;
clang::SourceManager& m_SMgr;
bool m_SkipFlag;
//False by default, true if current item is not to be printed
@ -39,7 +38,7 @@ namespace cling {
unsigned Indentation = 0, bool PrintInstantiation = false)
: Out(Out), Policy(Policy), Indentation(Indentation),
PrintInstantiation(PrintInstantiation),m_SMgr(smgr),m_SkipFlag(false) {
this->Policy.SuppressTagKeyword=true;
this->Policy.SuppressTagKeyword=true;
}
void VisitDeclContext(clang::DeclContext *DC, bool Indent = true);

View File

@ -1,3 +1,19 @@
// NonTemplateParmDecls should only print one default fwd decl, i.e it should
// omit the inheritant default arguments.
template<typename, unsigned = 0>
struct extent;
template<typename, unsigned _Uint>
struct extent{ };
// The same holds for TemplateParmDecls.
template <typename T=int>
class Foo {};
template <typename T>
class Foo;
namespace M {
namespace N {
template<typename T>