summaryrefslogtreecommitdiffstats
path: root/clang/test/FixIt/fixit-unicode.c
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-07-16 20:52:12 +0000
committerJordan Rose <jordan_rose@apple.com>2012-07-16 20:52:12 +0000
commitfb12a53d5dd2bf37ed4304a5b01cc67b88d4c26a (patch)
tree64b183b1ed93031b00b7911bb1026de70bd398d0 /clang/test/FixIt/fixit-unicode.c
parent1f4ff15c91014fa72cbd6c1747b745d2b5911dce (diff)
downloadbcm5719-llvm-fb12a53d5dd2bf37ed4304a5b01cc67b88d4c26a.tar.gz
bcm5719-llvm-fb12a53d5dd2bf37ed4304a5b01cc67b88d4c26a.zip
Don't crash when emitting fixits following Unicode characters.
This code is very sensitive to the difference between "columns" as printed and "bytes" (SourceManager columns). All variables are now named explicitly and our assumptions are (hopefully) documented as both comment and assertion. Whether parseable fixits should use byte offsets or Unicode character counts is pending discussion on the mailing list; currently the implementation uses bytes (and has no problems on lines containing multibyte characters). This has been added to the user manual. <rdar://problem/11877454> llvm-svn: 160319
Diffstat (limited to 'clang/test/FixIt/fixit-unicode.c')
-rw-r--r--clang/test/FixIt/fixit-unicode.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/test/FixIt/fixit-unicode.c b/clang/test/FixIt/fixit-unicode.c
index d8e45923362..922d309643c 100644
--- a/clang/test/FixIt/fixit-unicode.c
+++ b/clang/test/FixIt/fixit-unicode.c
@@ -1,10 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s
-// PR13312
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s
struct Foo {
int bar;
};
+// PR13312
void test1() {
struct Foo foo;
(&foo)☃>bar = 42;
@@ -12,4 +13,19 @@ void test1() {
// Make sure we emit the fixit right in front of the snowman.
// CHECK: {{^ \^}}
// CHECK: {{^ ;}}
+
+// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{11:9-11:9}:";"
+}
+
+
+int printf(const char *, ...);
+void test2() {
+ printf("∆: %d", 1L);
+// CHECK: warning: format specifies type 'int' but the argument has type 'long'
+// Don't crash emitting a fixit after the delta.
+// CHECK-NEXT: printf("∆: %d", 1L);
+// CHECK-NEXT: {{^ ~~ \^~}}
+// CHECK-NEXT: {{^ %ld}}
+
+// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{23:16-23:18}:"%ld"
}
OpenPOWER on IntegriCloud