forked from OSchip/llvm-project
Decl printer: fix CXXConstructExpr with implicit default argument
Patch by Will Wilson. llvm-svn: 173630
This commit is contained in:
parent
f2ecd40929
commit
6835e37cec
|
@ -646,9 +646,13 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
|
|||
Expr *Init = D->getInit();
|
||||
if (!Policy.SuppressInitializers && Init) {
|
||||
bool ImplicitInit = false;
|
||||
if (CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init))
|
||||
ImplicitInit = D->getInitStyle() == VarDecl::CallInit &&
|
||||
Construct->getNumArgs() == 0 && !Construct->isListInitialization();
|
||||
if (CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init)) {
|
||||
if (D->getInitStyle() == VarDecl::CallInit &&
|
||||
!Construct->isListInitialization()) {
|
||||
ImplicitInit = Construct->getNumArgs() == 0 ||
|
||||
Construct->getArg(0)->isDefaultArgument();
|
||||
}
|
||||
}
|
||||
if (!ImplicitInit) {
|
||||
if ((D->getInitStyle() == VarDecl::CallInit) && !isa<ParenListExpr>(Init))
|
||||
Out << "(";
|
||||
|
|
|
@ -99,3 +99,24 @@ int test11() {
|
|||
return test10::M::X<INT>::value;
|
||||
}
|
||||
|
||||
|
||||
struct DefaultArgClass
|
||||
{
|
||||
DefaultArgClass(int a = 1) {}
|
||||
};
|
||||
|
||||
struct NoArgClass
|
||||
{
|
||||
NoArgClass() {}
|
||||
};
|
||||
|
||||
// CHECK: test12
|
||||
// CHECK-NEXT: DefaultArgClass useDefaultArg;
|
||||
// CHECK-NEXT: DefaultArgClass overrideDefaultArg(1);
|
||||
// CHECK-NEXT: NoArgClass noArg;
|
||||
void test12() {
|
||||
DefaultArgClass useDefaultArg;
|
||||
DefaultArgClass overrideDefaultArg(1);
|
||||
NoArgClass noArg;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue