[PATCH] D27574: [sanitizer] Add workaround for empty strings
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 14:21:00 PST 2016
vitalybuka updated this revision to Diff 80824.
vitalybuka added a comment.
simplified code
https://reviews.llvm.org/D27574
Files:
lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
Index: lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
+++ lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
@@ -242,24 +242,22 @@
char *file_line_info = 0;
str = ExtractToken(str, "\n", &file_line_info);
CHECK(file_line_info);
- // Parse the last :<int>, which must be there.
- char *last_colon = internal_strrchr(file_line_info, ':');
- CHECK(last_colon);
- int line_or_column = internal_atoll(last_colon + 1);
- // Truncate the string at the last colon and find the next-to-last colon.
- *last_colon = '\0';
- last_colon = internal_strrchr(file_line_info, ':');
- if (last_colon && IsDigit(last_colon[1])) {
- // If the second-to-last colon is followed by a digit, it must be the line
- // number, and the previous parsed number was a column.
- info->line = internal_atoll(last_colon + 1);
- info->column = line_or_column;
- *last_colon = '\0';
- } else {
- // Otherwise, we have line info but no column info.
- info->line = line_or_column;
- info->column = 0;
+
+ info->column = 0;
+ info->line = 0;
+
+ char* back = file_line_info + internal_strlen(file_line_info) - 1;
+ for (int i = 0; i < 2; ++i) {
+ while (back > file_line_info && IsDigit(*back))
+ --back;
+ if (*back != ':' || !IsDigit(back[1]))
+ break;
+ info->column = info->line;
+ info->line = internal_atoll(back + 1);
+ *back = '\0';
+ --back;
}
+
ExtractToken(file_line_info, "", &info->file);
InternalFree(file_line_info);
return str;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27574.80824.patch
Type: text/x-patch
Size: 1625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161208/898cee2f/attachment.bin>
More information about the llvm-commits
mailing list