From 5fee6936b8b241b36fadaf0dcd962e9c9adc8a69 Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Tue, 28 Apr 2020 23:43:48 +0100 Subject: [PATCH] [AST] Use PrintingPolicy for format string diagnosis Summary: This is a small improvement for OpenCL diagnostics, but is also useful for our CHERI fork, as our __capability qualifier is suppressed from diagnostics when all pointers are capabilities, only being used when pointers need to be explicitly opted-in to being capabilities. Reviewers: rsmith, Anastasia, aaron.ballman Reviewed By: Anastasia, aaron.ballman Subscribers: aaron.ballman, arichardson, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78777 --- clang/lib/AST/FormatString.cpp | 2 +- clang/test/SemaOpenCL/printf-format-strings.cl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index fcc0b3b..e9f6b88 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -539,7 +539,7 @@ QualType ArgType::getRepresentativeType(ASTContext &C) const { } std::string ArgType::getRepresentativeTypeName(ASTContext &C) const { - std::string S = getRepresentativeType(C).getAsString(); + std::string S = getRepresentativeType(C).getAsString(C.getPrintingPolicy()); std::string Alias; if (Name) { diff --git a/clang/test/SemaOpenCL/printf-format-strings.cl b/clang/test/SemaOpenCL/printf-format-strings.cl index 0cfeeb1..6cdfc7e 100644 --- a/clang/test/SemaOpenCL/printf-format-strings.cl +++ b/clang/test/SemaOpenCL/printf-format-strings.cl @@ -65,8 +65,8 @@ kernel void format_v4f64(half4 arg_h, float4 arg_f, double4 arg_d) kernel void format_v4f16(half4 arg_h, float4 arg_f, double4 arg_d) { - printf("%v4hf\n", arg_d); // expected-warning{{format specifies type '__fp16 __attribute__((ext_vector_type(4)))' but the argument has type 'double4' (vector of 4 'double' values)}} - printf("%v4hf\n", arg_f); // expected-warning{{format specifies type '__fp16 __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} + printf("%v4hf\n", arg_d); // expected-warning{{format specifies type 'half __attribute__((ext_vector_type(4)))' but the argument has type 'double4' (vector of 4 'double' values)}} + printf("%v4hf\n", arg_f); // expected-warning{{format specifies type 'half __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}} printf("%v4hf\n", arg_h); } -- 2.7.4