r285047 - Fix handling of %% format specifier in os_log builtins.
Mehdi Amini via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 24 17:48:48 PDT 2016
Author: mehdi_amini
Date: Mon Oct 24 19:48:48 2016
New Revision: 285047
URL: http://llvm.org/viewvc/llvm-project?rev=285047&view=rev
Log:
Fix handling of %% format specifier in os_log builtins.
Returning `false` was stopping the parsing of further arguments,
which wasn't intended.
Modified:
cfe/trunk/lib/Analysis/OSLog.cpp
cfe/trunk/test/CodeGen/builtins.c
Modified: cfe/trunk/lib/Analysis/OSLog.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/OSLog.cpp?rev=285047&r1=285046&r2=285047&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/OSLog.cpp (original)
+++ cfe/trunk/lib/Analysis/OSLog.cpp Mon Oct 24 19:48:48 2016
@@ -57,7 +57,7 @@ public:
if (!FS.consumesDataArgument() &&
FS.getConversionSpecifier().getKind() !=
clang::analyze_format_string::ConversionSpecifier::PrintErrno)
- return false;
+ return true;
ArgsData.emplace_back();
unsigned ArgIndex = FS.getArgIndex();
Modified: cfe/trunk/test/CodeGen/builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=285047&r1=285046&r2=285047&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Mon Oct 24 19:48:48 2016
@@ -490,19 +490,21 @@ void test_builtin_os_log_wide(void *buf,
}
// CHECK-LABEL: define void @test_builtin_os_log_percent
+// CHECK: (i8* [[BUF:%.*]], i8* [[DATA1:%.*]], i8* [[DATA2:%.*]])
// Check that the %% which does not consume any argument is correctly handled
-void test_builtin_os_log_percent(void *buf, const char *data) {
+void test_builtin_os_log_percent(void *buf, const char *data1, const char *data2) {
volatile int len;
// CHECK: store i8* [[BUF]], i8** [[BUF_ADDR:%.*]], align 8
- // CHECK: store i8* [[DATA]], i8** [[DATA_ADDR:%.*]], align 8
- // CHECK: store volatile i32 12
- len = __builtin_os_log_format_buffer_size("%s %%", data);
+ // CHECK: store i8* [[DATA1]], i8** [[DATA1_ADDR:%.*]], align 8
+ // CHECK: store i8* [[DATA2]], i8** [[DATA2_ADDR:%.*]], align 8
+ // CHECK: store volatile i32 22
+ len = __builtin_os_log_format_buffer_size("%s %% %s", data1, data2);
// CHECK: [[BUF2:%.*]] = load i8*, i8** [[BUF_ADDR]]
// CHECK: [[SUMMARY:%.*]] = getelementptr i8, i8* [[BUF2]], i64 0
// CHECK: store i8 2, i8* [[SUMMARY]]
// CHECK: [[NUM_ARGS:%.*]] = getelementptr i8, i8* [[BUF2]], i64 1
- // CHECK: store i8 1, i8* [[NUM_ARGS]]
+ // CHECK: store i8 2, i8* [[NUM_ARGS]]
//
// CHECK: [[ARG1_DESC:%.*]] = getelementptr i8, i8* [[BUF2]], i64 2
// CHECK: store i8 32, i8* [[ARG1_DESC]]
@@ -510,9 +512,18 @@ void test_builtin_os_log_percent(void *b
// CHECK: store i8 8, i8* [[ARG1_SIZE]]
// CHECK: [[ARG1:%.*]] = getelementptr i8, i8* [[BUF2]], i64 4
// CHECK: [[ARG1_PTR:%.*]] = bitcast i8* [[ARG1]] to i8**
- // CHECK: [[DATA2:%.*]] = load i8*, i8** [[DATA_ADDR]]
- // CHECK: store i8* [[DATA2]], i8** [[ARG1_PTR]]
- __builtin_os_log_format(buf, "%s %%", data);
+ // CHECK: [[DATA1:%.*]] = load i8*, i8** [[DATA1_ADDR]]
+ // CHECK: store i8* [[DATA1]], i8** [[ARG1_PTR]]
+ //
+ // CHECK: [[ARG2_DESC:%.*]] = getelementptr i8, i8* [[BUF2]], i64 12
+ // CHECK: store i8 32, i8* [[ARG2_DESC]]
+ // CHECK: [[ARG2_SIZE:%.*]] = getelementptr i8, i8* [[BUF2]], i64 13
+ // CHECK: store i8 8, i8* [[ARG2_SIZE]]
+ // CHECK: [[ARG2:%.*]] = getelementptr i8, i8* [[BUF2]], i64 14
+ // CHECK: [[ARG2_PTR:%.*]] = bitcast i8* [[ARG2]] to i8**
+ // CHECK: [[DATA2:%.*]] = load i8*, i8** [[DATA2_ADDR]]
+ // CHECK: store i8* [[DATA2]], i8** [[ARG2_PTR]]
+ __builtin_os_log_format(buf, "%s %% %s", data1, data2);
}
#endif
\ No newline at end of file
More information about the cfe-commits
mailing list