From: Ted Kremenek Date: Tue, 7 Sep 2010 22:21:59 +0000 (+0000) Subject: Fix DeclPrinter to not include '=' in printing when no initializer is provided for... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bccfd31ac3b7769d681d56d514ad3a0a6e7b5d93;p=clang Fix DeclPrinter to not include '=' in printing when no initializer is provided for a VarDecl. Patch by Jim Goodnow II! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113296 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index f18d2f0215..e8c24965bd 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -518,12 +518,12 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { T = Parm->getOriginalType(); T.getAsStringInternal(Name, Policy); Out << Name; - if (D->getInit()) { + if (Expr *Init = D->getInit()) { if (D->hasCXXDirectInitializer()) Out << "("; - else + else if (!dyn_cast(Init)) Out << " = "; - D->getInit()->printPretty(Out, Context, 0, Policy, Indentation); + Init->printPretty(Out, Context, 0, Policy, Indentation); if (D->hasCXXDirectInitializer()) Out << ")"; }