[PATCH] Extend s{, n}printf custom wrappers to support '*' in the format specifiers

Peter Collingbourne peter at pcc.me.uk
Wed Mar 18 22:04:04 PDT 2015

LGTM with my suggestions.

Comment at: lib/dfsan/dfsan_custom.cc:960
@@ +959,3 @@
+      for (formatter.fmt_size = 1; *++formatter.fmt && !end_fmt;) {
+        ++formatter.fmt_size;
If you keep track of the start of the chunk of the format string instead of its size, you will have only one thing to increment here and in the other loop.

Comment at: lib/dfsan/dfsan_custom.cc:962
@@ +961,3 @@
+        switch (*formatter.fmt) {
+        case 'd':
You could modify this switch statement to consume characters instead:

`switch (*++formatter.fmt) {`

Once you make the matching change to `build_format_string`, this will save you from having to confusingly increment and decrement `formatter.fmt` above.



More information about the llvm-commits mailing list