@@ -442,12 +442,13 @@ static bool shouldShowAKA(Type type, StringRef typeName) {
442
442
// / with the same string representation, it should be qualified during
443
443
// / formatting.
444
444
static bool typeSpellingIsAmbiguous (Type type,
445
- ArrayRef<DiagnosticArgument> Args) {
445
+ ArrayRef<DiagnosticArgument> Args,
446
+ PrintOptions &PO) {
446
447
for (auto arg : Args) {
447
448
if (arg.getKind () == DiagnosticArgumentKind::Type) {
448
449
auto argType = arg.getAsType ();
449
450
if (argType && !argType->isEqual (type) &&
450
- argType->getWithoutParens ().getString () == type.getString ()) {
451
+ argType->getWithoutParens ().getString (PO ) == type.getString (PO )) {
451
452
return true ;
452
453
}
453
454
}
@@ -543,12 +544,22 @@ static void formatDiagnosticArgument(StringRef Modifier,
543
544
Type type;
544
545
bool needsQualification = false ;
545
546
547
+ // TODO: We should use PrintOptions::printForDiagnostic here, or we should
548
+ // rename that method.
549
+ PrintOptions printOptions{};
550
+
546
551
if (Arg.getKind () == DiagnosticArgumentKind::Type) {
547
552
type = Arg.getAsType ()->getWithoutParens ();
548
- needsQualification = typeSpellingIsAmbiguous (type, Args);
553
+ if (type->getASTContext ().TypeCheckerOpts .PrintFullConvention )
554
+ printOptions.PrintFunctionRepresentationAttrs =
555
+ PrintOptions::FunctionRepresentationMode::Full;
556
+ needsQualification = typeSpellingIsAmbiguous (type, Args, printOptions);
549
557
} else {
550
558
assert (Arg.getKind () == DiagnosticArgumentKind::FullyQualifiedType);
551
559
type = Arg.getAsFullyQualifiedType ().getType ()->getWithoutParens ();
560
+ if (type->getASTContext ().TypeCheckerOpts .PrintFullConvention )
561
+ printOptions.PrintFunctionRepresentationAttrs =
562
+ PrintOptions::FunctionRepresentationMode::Full;
552
563
needsQualification = true ;
553
564
}
554
565
@@ -574,12 +585,11 @@ static void formatDiagnosticArgument(StringRef Modifier,
574
585
auto descriptiveKind = opaqueTypeDecl->getDescriptiveKind ();
575
586
576
587
Out << llvm::format (FormatOpts.OpaqueResultFormatString .c_str (),
577
- type->getString ().c_str (),
588
+ type->getString (printOptions ).c_str (),
578
589
Decl::getDescriptiveKindName (descriptiveKind).data (),
579
590
NamingDeclText.c_str ());
580
591
581
592
} else {
582
- auto printOptions = PrintOptions ();
583
593
printOptions.FullyQualifiedTypes = needsQualification;
584
594
std::string typeName = type->getString (printOptions);
585
595
@@ -1016,8 +1026,11 @@ DiagnosticEngine::diagnosticInfoForDiagnostic(const Diagnostic &diagnostic) {
1016
1026
// Pretty-print the declaration we've picked.
1017
1027
llvm::raw_svector_ostream out (buffer);
1018
1028
TrackingPrinter printer (entries, out, bufferAccessLevel);
1019
- ppDecl->print (printer,
1020
- PrintOptions::printForDiagnostics (bufferAccessLevel));
1029
+ ppDecl->print (
1030
+ printer,
1031
+ PrintOptions::printForDiagnostics (
1032
+ bufferAccessLevel,
1033
+ decl->getASTContext ().TypeCheckerOpts .PrintFullConvention ));
1021
1034
}
1022
1035
1023
1036
// Build a buffer with the pretty-printed declaration.
0 commit comments