[AST] Use PrintingPolicy for format string diagnosis
authorJessica Clarke <jrtc27@jrtc27.com>
Tue, 28 Apr 2020 22:43:48 +0000 (23:43 +0100)
committerJessica Clarke <jrtc27@jrtc27.com>
Tue, 28 Apr 2020 22:43:48 +0000 (23:43 +0100)
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
clang/test/SemaOpenCL/printf-format-strings.cl

index fcc0b3b..e9f6b88 100644 (file)
@@ -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) {
index 0cfeeb1..6cdfc7e 100644 (file)
@@ -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);
 }