Skip decls using names from defs like typedef struct {} structName

This commit is contained in:
manasij7479 2014-08-06 03:34:27 +05:30 committed by sftnight
parent 620fc072d0
commit 7b99ddcfa1
3 changed files with 44 additions and 7 deletions

View File

@ -791,14 +791,14 @@ namespace cling {
void ForwardDeclPrinter::
VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl* D) {
const TemplateArgumentList& iargs = D->getTemplateInstantiationArgs();
if (llvm::isa<ClassTemplatePartialSpecializationDecl>(D)) {
if (shouldSkip(D)) {
skipCurrentDecl();
//TODO: How to print partial specializations?
return;
}
const TemplateArgumentList& iargs = D->getTemplateInstantiationArgs();
m_Out << "template <> ";
VisitCXXRecordDecl(D->getCanonicalDecl());
@ -826,8 +826,13 @@ namespace cling {
bool ForwardDeclPrinter::isIncompatibleType(QualType q) {
//FIXME: This is a workaround and filters out many acceptable cases
if (q.getTypePtr()->isAnyPointerType())
q = q.getTypePtr()->getPointeeType();
q.removeLocalConst();
q.removeLocalRestrict();
q.removeLocalVolatile();
llvm::StringRef str = q.getAsString();
// llvm::outs() << "Q:"<<str<<"\n";
return m_IncompatibleTypes.find(str) != m_IncompatibleTypes.end()
|| str.find("::") != llvm::StringRef::npos;
@ -867,9 +872,24 @@ namespace cling {
m_IncompatibleTypes.insert(D->getName());
return true;
}
if (isa<RecordType>(ET->getNamedType())) {
m_IncompatibleTypes.insert(D->getName());
return true;
}
}
if (const TemplateSpecializationType* tst
= dyn_cast<TemplateSpecializationType>(D->getTypeSourceInfo()->getType().getTypePtr())){
for (uint i = 0; i < tst->getNumArgs(); ++i ) {
const TemplateArgument& arg = tst->getArg(i);
if (arg.getKind() == TemplateArgument::ArgKind::Type)
if (m_IncompatibleTypes.find(arg.getAsType().getAsString())!=m_IncompatibleTypes.end())
return true;
}
}
if (isIncompatibleType(D->getTypeSourceInfo()->getType())) {
m_IncompatibleTypes.insert(D->getName());
// llvm::outs() << "I: "<<D->getName()<<"\n";
return true;
}
return false;
@ -889,6 +909,24 @@ namespace cling {
}
m_TotalDecls++;
}
bool ForwardDeclPrinter::shouldSkip(ClassTemplateSpecializationDecl *D) {
if (llvm::isa<ClassTemplatePartialSpecializationDecl>(D)) {
//TODO: How to print partial specializations?
return true;
}
const TemplateArgumentList& iargs = D->getTemplateInstantiationArgs();
for (uint i = 0; i < iargs.size(); ++i) {
const TemplateArgument& arg = iargs[i];
if (arg.getKind() == TemplateArgument::ArgKind::Type)
if (m_IncompatibleTypes.find(arg.getAsType().getAsString())!=m_IncompatibleTypes.end())
return true;
}
return false;
}
void ForwardDeclPrinter::printStats() {
llvm::outs() << m_SkipCounter << " decls skipped out of " << m_TotalDecls << "\n";
}

View File

@ -121,7 +121,7 @@ namespace cling {
bool shouldSkip(clang::TypedefDecl* D);
bool shouldSkip(clang::VarDecl* D);
bool shouldSkip(clang::EnumDecl* D);
bool shouldSkip(clang::ClassTemplateSpecializationDecl* D){return true;}
bool shouldSkip(clang::ClassTemplateSpecializationDecl* D);
bool shouldSkip(clang::UsingDecl* D){return true;}
bool shouldSkip(clang::UsingShadowDecl* D){return true;}

View File

@ -8,8 +8,7 @@
// RUN: cat %s | %cling -I %S -Xclang -verify
// Test incompleteType
//XFAIL: *
//Becasue functionality is disabled now
#include "cling/Interpreter/Interpreter.h"
gCling->EnableAutoloading();