From 01aefc6d20fbfd50bfb83926226dee86dd31c9c5 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 30 Jan 2010 15:49:20 +0000 Subject: [PATCH] Recognize 'q' as a format length modifier (from BSD). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94894 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Analysis/Analyses/PrintfFormatString.h | 2 +- lib/Analysis/PrintfFormatString.cpp | 1 + test/Sema/format-strings.c | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/clang/Analysis/Analyses/PrintfFormatString.h b/include/clang/Analysis/Analyses/PrintfFormatString.h index e2c0d232fa..0431be143e 100644 --- a/include/clang/Analysis/Analyses/PrintfFormatString.h +++ b/include/clang/Analysis/Analyses/PrintfFormatString.h @@ -105,7 +105,7 @@ enum LengthModifier { AsChar, // 'hh' AsShort, // 'h' AsLong, // 'l' - AsLongLong, // 'll' + AsLongLong, // 'll', 'q' (BSD, deprecated) AsIntMax, // 'j' AsSizeT, // 'z' AsPtrDiff, // 't' diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp index 05b5d9cceb..d2bcbb04f9 100644 --- a/lib/Analysis/PrintfFormatString.cpp +++ b/lib/Analysis/PrintfFormatString.cpp @@ -185,6 +185,7 @@ static FormatSpecifierResult ParseFormatSpecifier(FormatStringHandler &H, case 'z': lm = AsSizeT; ++I; break; case 't': lm = AsPtrDiff; ++I; break; case 'L': lm = AsLongDouble; ++I; break; + case 'q': lm = AsLongLong; ++I; break; } FS.setLengthModifier(lm); diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index 21d7770e12..02e39a426b 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -144,7 +144,7 @@ void torture(va_list v8) { } -void test10(int x, float f, int i) { +void test10(int x, float f, int i, long long lli) { printf("%@", 12); // expected-warning{{invalid conversion specifier '@'}} printf("\0"); // expected-warning{{format string contains '\0' within the string body}} printf("xs\0"); // expected-warning{{format string contains '\0' within the string body}} @@ -161,6 +161,7 @@ void test10(int x, float f, int i) { printf("%.d", x); // no-warning printf("%.", x); // expected-warning{{incomplete format specifier}} printf("%f", 4); // expected-warning{{conversion specifies type 'double' but the argument has type 'int'}} + printf("%qd", lli); } typedef struct __aslclient *aslclient; -- 2.40.0