aboutsummaryrefslogtreecommitdiff
path: root/test/Misc
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-12-13 00:14:59 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-12-13 00:14:59 +0000
commit0fdcd1e81db7b8f5b3fd05154d966b215b20a2eb (patch)
tree4b7a9d90748562d6ca13f0181466275da9eb88d0 /test/Misc
parent3872b46ba9a5275ef0bf4fcefe2d7ef11ce75cc5 (diff)
More hacking on mapDiagnosticRanges to make it handle more cases.
This still isn't quite right, but it fixes a crash. I factored out findCommonParent because we need it on the result of getImmediateExpansionRange: for a function macro, the beginning and end of an expansion range can come out of different macros/macro arguments, which means the resulting range is a complete mess to handle consistently. I also made some changes to how findCommonParent works; it works somewhat better in some cases, and somewhat worse in others, but I think overall it's a better balance. I'm coming to the conclusion that mapDiagnosticRanges isn't using the right algorithm, though: chasing the caret is fundamentally more complicated than any algorithm which only considers one FileID for the caret can handle because each SourceLocation doesn't really have a single parent. We need to follow the same path of choosing expansion locations and spelling locations which the caret used to come up with the correct range in the general case. Fixes <rdar://problem/12847524>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Misc')
-rw-r--r--test/Misc/caret-diags-macros.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/Misc/caret-diags-macros.c b/test/Misc/caret-diags-macros.c
index ce62425e78..8fcfeb070c 100644
--- a/test/Misc/caret-diags-macros.c
+++ b/test/Misc/caret-diags-macros.c
@@ -181,10 +181,10 @@ void foo_aa()
}
// CHECK: {{.*}}:180:21: warning: expression result unused
// CHECK-NEXT: iequals(__LINE__, BARC(4,3,2,6,8), 8);
-// CHECK-NEXT: {{^ \^~~~~~~~~~~~~~~}}
+// CHECK-NEXT: {{^ \^ ~}}
// CHECK-NEXT: {{.*}}:179:51: note: expanded from macro 'BARC'
// CHECK-NEXT: #define /* */ BARC(c, /* */b, a, ...) (a+b+/* */c + __VA_ARGS__ +0)
-// CHECK-NEXT: {{^ ~~~~~~~~~~ \^}}
+// CHECK-NEXT: {{^ \^}}
#define APPEND2(NUM, SUFF) -1 != NUM ## SUFF
#define APPEND(NUM, SUFF) APPEND2(NUM, SUFF)
@@ -205,3 +205,24 @@ void foo_aa()
// CHECK-NEXT: {{.*}}:189:31: note: expanded from macro 'APPEND2'
// CHECK-NEXT: #define APPEND2(NUM, SUFF) -1 != NUM ## SUFF
// CHECK-NEXT: {{^ ~~ \^ ~~~~~~~~~~~}}
+
+
+unsigned long strlen_test(const char *s);
+#define __darwin_obsz(object) __builtin_object_size (object, 1)
+#define sprintf2(str, ...) \
+ __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
+#define Cstrlen(a) strlen_test(a)
+#define Csprintf sprintf2
+void f(char* pMsgBuf, char* pKeepBuf) {
+Csprintf(pMsgBuf,"\nEnter minimum anagram length (2-%1d): ", Cstrlen(pKeepBuf));
+}
+// CHECK: {{.*}}:217:62: warning: format specifies type 'int' but the argument has type 'unsigned long'
+// CHECK-NEXT: Csprintf(pMsgBuf,"\nEnter minimum anagram length (2-%1d): ", Cstrlen(pKeepBuf));
+// CHECK-NEXT: {{^ ~~~ \^~~~~~~~~~~~~~~~~}}
+// CHECK-NEXT: {{^ %1ld}}
+// CHECK-NEXT: {{.*}}:214:21: note: expanded from macro 'Cstrlen'
+// CHECK-NEXT: #define Cstrlen(a) strlen_test(a)
+// CHECK-NEXT: {{^ \^}}
+// CHECK-NEXT: {{.*}}:213:56: note: expanded from macro 'sprintf2'
+// CHECK-NEXT: __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
+// CHECK-NEXT: {{^ \^}}