|
39 | 39 | #include "swift/Parse/Lexer.h" // bad dependency
|
40 | 40 | #include "clang/AST/ASTContext.h"
|
41 | 41 | #include "clang/AST/Decl.h"
|
| 42 | +#include "clang/AST/PrettyPrinter.h" |
| 43 | +#include "clang/AST/Type.h" |
42 | 44 | #include "llvm/ADT/SmallString.h"
|
43 | 45 | #include "llvm/ADT/Twine.h"
|
44 | 46 | #include "llvm/Support/CommandLine.h"
|
@@ -752,6 +754,11 @@ void swift::printClangDeclName(const clang::NamedDecl *ND,
|
752 | 754 | ND->getNameForDiagnostic(os, ND->getASTContext().getPrintingPolicy(), false);
|
753 | 755 | }
|
754 | 756 |
|
| 757 | +void swift::printClangTypeName(const clang::Type *Ty, llvm::raw_ostream &os) { |
| 758 | + clang::QualType::print(Ty, clang::Qualifiers(), os, |
| 759 | + clang::PrintingPolicy{clang::LangOptions()}, ""); |
| 760 | +} |
| 761 | + |
755 | 762 | /// Format a single diagnostic argument and write it to the given
|
756 | 763 | /// stream.
|
757 | 764 | static void formatDiagnosticArgument(StringRef Modifier,
|
@@ -1094,6 +1101,13 @@ static void formatDiagnosticArgument(StringRef Modifier,
|
1094 | 1101 | printClangDeclName(Arg.getAsClangDecl(), Out);
|
1095 | 1102 | Out << FormatOpts.ClosingQuotationMark;
|
1096 | 1103 | break;
|
| 1104 | + |
| 1105 | + case DiagnosticArgumentKind::ClangType: |
| 1106 | + assert(Modifier.empty() && "Improper modifier for ClangDecl argument"); |
| 1107 | + Out << FormatOpts.OpeningQuotationMark; |
| 1108 | + printClangTypeName(Arg.getAsClangType(), Out); |
| 1109 | + Out << FormatOpts.ClosingQuotationMark; |
| 1110 | + break; |
1097 | 1111 | }
|
1098 | 1112 | }
|
1099 | 1113 |
|
|
0 commit comments