forked from OSchip/llvm-project
Revert "[clang] Dont print implicit forrange initializer"
This reverts commit 32805e60c9
.
Broke check-clang, see comments on https://reviews.llvm.org/D127863
This commit is contained in:
parent
a504086041
commit
7aac15d5df
|
@ -895,15 +895,12 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
|
|||
Expr *Init = D->getInit();
|
||||
if (!Policy.SuppressInitializers && Init) {
|
||||
bool ImplicitInit = false;
|
||||
if (D->isCXXForRangeDecl()) {
|
||||
// FIXME: We should print the range expression instead.
|
||||
ImplicitInit = true;
|
||||
} else if (CXXConstructExpr *Construct =
|
||||
dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
|
||||
if (CXXConstructExpr *Construct =
|
||||
dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
|
||||
if (D->getInitStyle() == VarDecl::CallInit &&
|
||||
!Construct->isListInitialization()) {
|
||||
ImplicitInit = Construct->getNumArgs() == 0 ||
|
||||
Construct->getArg(0)->isDefaultArgument();
|
||||
Construct->getArg(0)->isDefaultArgument();
|
||||
}
|
||||
}
|
||||
if (!ImplicitInit) {
|
||||
|
|
|
@ -1426,7 +1426,4 @@ TEST(DeclPrinter, VarDeclWithInitializer) {
|
|||
ASSERT_TRUE(PrintedDeclCXX17Matches(
|
||||
"int a = 0x15;", namedDecl(hasName("a")).bind("id"), "int a = 0x15",
|
||||
[](PrintingPolicy &Policy) { Policy.ConstantsAsWritten = true; }));
|
||||
ASSERT_TRUE(
|
||||
PrintedDeclCXX17Matches("void foo() {int arr[42]; for(int a : arr);}",
|
||||
namedDecl(hasName("a")).bind("id"), "int a"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue