зеркало из https://github.com/microsoft/clang-1.git
Decl printer: fix CXXConstructExpr with implicit default argument
Patch by Will Wilson. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173630 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d1e5c0df2a
Коммит
5250e2b24f
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче