diff options
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/AST/TemplateBase.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/AST/TypePrinter.cpp | 19 |
3 files changed, 16 insertions, 11 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index edbbc6a8c4f..243d4055840 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1434,8 +1434,10 @@ void NamedDecl::printQualifiedName(raw_ostream &OS, if (P.SuppressUnwrittenScope && (ND->isAnonymousNamespace() || ND->isInline())) continue; - if (ND->isAnonymousNamespace()) - OS << "(anonymous namespace)"; + if (ND->isAnonymousNamespace()) { + OS << (P.MSVCFormatting ? "`anonymous namespace\'" + : "(anonymous namespace)"); + } else OS << *ND; } else if (const auto *RD = dyn_cast<RecordDecl>(*I)) { diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp index 8c5a6918360..7103ecb5bb4 100644 --- a/clang/lib/AST/TemplateBase.cpp +++ b/clang/lib/AST/TemplateBase.cpp @@ -53,7 +53,7 @@ static void printIntegral(const TemplateArgument &TemplArg, } } - if (T->isBooleanType()) { + if (T->isBooleanType() && !Policy.MSVCFormatting) { Out << (Val.getBoolValue() ? "true" : "false"); } else if (T->isCharType()) { const char Ch = Val.getZExtValue(); diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index e360512462f..4617e1d3803 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -925,12 +925,13 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) { } else { // Make an unambiguous representation for anonymous types, e.g. // (anonymous enum at /usr/include/string.h:120:9) - + OS << (Policy.MSVCFormatting ? '`' : '('); + if (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda()) { - OS << "(lambda"; + OS << "lambda"; HasKindDecoration = true; } else { - OS << "(anonymous"; + OS << "anonymous"; } if (Policy.AnonymousTagLocations) { @@ -948,8 +949,8 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) { << ':' << PLoc.getColumn(); } } - - OS << ')'; + + OS << (Policy.MSVCFormatting ? '\'' : ')'); } // If this is a class template specialization, print the template @@ -1401,6 +1402,7 @@ TemplateSpecializationType::PrintTemplateArgumentList( unsigned NumArgs, const PrintingPolicy &Policy, bool SkipBrackets) { + const char *Comma = Policy.MSVCFormatting ? "," : ", "; if (!SkipBrackets) OS << '<'; @@ -1411,14 +1413,14 @@ TemplateSpecializationType::PrintTemplateArgumentList( llvm::raw_svector_ostream ArgOS(Buf); if (Args[Arg].getKind() == TemplateArgument::Pack) { if (Args[Arg].pack_size() && Arg > 0) - OS << ", "; + OS << Comma; PrintTemplateArgumentList(ArgOS, Args[Arg].pack_begin(), Args[Arg].pack_size(), Policy, true); } else { if (Arg > 0) - OS << ", "; + OS << Comma; Args[Arg].print(Policy, ArgOS); } StringRef ArgString = ArgOS.str(); @@ -1450,11 +1452,12 @@ PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgumentLoc *Args, unsigned NumArgs, const PrintingPolicy &Policy) { OS << '<'; + const char *Comma = Policy.MSVCFormatting ? "," : ", "; bool needSpace = false; for (unsigned Arg = 0; Arg < NumArgs; ++Arg) { if (Arg > 0) - OS << ", "; + OS << Comma; // Print the argument into a string. SmallString<128> Buf; |

