Default argument stripping for FunctionDecl Also, re-enabled the printing of function default arguments in ForwardDeclPrinter
This commit is contained in:
parent
ab048fa2dd
commit
6b48ac6804
@ -20,6 +20,7 @@ namespace clang {
|
||||
class Decl;
|
||||
class ClassTemplateDecl;
|
||||
class NamespaceDecl;
|
||||
class FunctionDecl;
|
||||
}
|
||||
|
||||
namespace cling {
|
||||
@ -68,6 +69,7 @@ namespace cling {
|
||||
void HandleDeclVector(std::vector<clang::Decl*> Decls);
|
||||
void HandleNamespace(clang::NamespaceDecl* NS);
|
||||
void HandleClassTemplate(clang::ClassTemplateDecl* CT);
|
||||
void HandleFunction(clang::FunctionDecl* F);
|
||||
};
|
||||
} // end namespace cling
|
||||
|
||||
|
@ -51,6 +51,13 @@ namespace cling {
|
||||
}
|
||||
}
|
||||
}
|
||||
void removeDefaultArg(FunctionDecl* fd) {
|
||||
for (unsigned i = 0, e = fd->getNumParams(); i != e; ++i) {
|
||||
if(fd->getParamDecl(i)->hasDefaultArg()) {
|
||||
fd->getParamDecl(i)->setDefaultArg(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AutoloadCallback::InclusionDirective(clang::SourceLocation HashLoc,
|
||||
const clang::Token &IncludeTok,
|
||||
@ -81,6 +88,10 @@ namespace cling {
|
||||
// llvm::outs() << ct->getName() <<"\n";
|
||||
removeDefaultArg(ct->getTemplateParameters());
|
||||
}
|
||||
if(llvm::isa<clang::FunctionDecl>(decl)) {
|
||||
clang::FunctionDecl* fd = llvm::cast<clang::FunctionDecl>(decl);
|
||||
removeDefaultArg(fd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -137,6 +148,10 @@ namespace cling {
|
||||
if(cxxr->hasAttr<AnnotateAttr>())
|
||||
InsertIntoAutoloadingState(CT,cxxr->getAttr<AnnotateAttr>()->getAnnotation());
|
||||
}
|
||||
void AutoloadCallback::HandleFunction(FunctionDecl *F) {
|
||||
if(F->hasAttr<AnnotateAttr>())
|
||||
InsertIntoAutoloadingState(F,F->getAttr<AnnotateAttr>()->getAnnotation());
|
||||
}
|
||||
|
||||
void AutoloadCallback::HandleDeclVector(std::vector<clang::Decl*> Decls) {
|
||||
for(auto decl : Decls ) {
|
||||
@ -144,6 +159,8 @@ namespace cling {
|
||||
HandleClassTemplate(ct);
|
||||
if(auto ns = llvm::dyn_cast<NamespaceDecl>(decl))
|
||||
HandleNamespace(ns);
|
||||
if(auto f = llvm::dyn_cast<FunctionDecl>(decl))
|
||||
HandleFunction(f);
|
||||
}
|
||||
}
|
||||
void AutoloadCallback::TransactionCommitted(const Transaction &T) {
|
||||
|
@ -592,9 +592,9 @@ namespace cling {
|
||||
if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
|
||||
Out << "(";
|
||||
else if (D->getInitStyle() == VarDecl::CInit) {
|
||||
// Out << " = "; //FOR skipping default function args
|
||||
Out << " = "; //Comment for skipping default function args
|
||||
}
|
||||
// Init->printPretty(Out, 0, Policy, Indentation);//FOR skipping defalt function args
|
||||
Init->printPretty(Out, 0, Policy, Indentation);//Comment for skipping defalt function args
|
||||
if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
|
||||
Out << ")";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user