[PATCH] D63888: [llvm] [Support] Clean PrintStackTrace() ptr arithmetic up
Michał Górny via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 12:22:01 PDT 2019
mgorny created this revision.
mgorny added reviewers: krytarowski, revane, zturner, gribozavr.
Herald added a subscriber: hiraditya.
Herald added a reviewer: jfb.
Herald added a project: LLVM.
Use '%tu' modifier for pointer arithmetic since we are using C++11
already. Prefer static_cast<> over C-style cast. Remove unnecessary
conversion of result, and add const qualifier to converted pointers,
to silence the following warning:
In file included from /home/mgorny/llvm-project/llvm/lib/Support/Signals.cpp:220:0:
/home/mgorny/llvm-project/llvm/lib/Support/Unix/Signals.inc: In function ‘void llvm::sys::PrintStackTrace(llvm::raw_ostream&)’:
/home/mgorny/llvm-project/llvm/lib/Support/Unix/Signals.inc:546:53: warning: cast from type ‘const void*’ to type ‘char*’ casts away qualifiers [-Wcast-qual]
(char*)dlinfo.dli_saddr));
^~~~~~~~~
https://reviews.llvm.org/D63888
Files:
llvm/lib/Support/Unix/Signals.inc
Index: llvm/lib/Support/Unix/Signals.inc
===================================================================
--- llvm/lib/Support/Unix/Signals.inc
+++ llvm/lib/Support/Unix/Signals.inc
@@ -539,11 +539,8 @@
else OS << d;
free(d);
- // FIXME: When we move to C++11, use %t length modifier. It's not in
- // C++03 and causes gcc to issue warnings. Losing the upper 32 bits of
- // the stack offset for a stack dump isn't likely to cause any problems.
- OS << format(" + %u",(unsigned)((char*)StackTrace[i]-
- (char*)dlinfo.dli_saddr));
+ OS << format(" + %tu", (static_cast<const char*>(StackTrace[i])-
+ static_cast<const char*>(dlinfo.dli_saddr)));
}
OS << '\n';
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63888.206904.patch
Type: text/x-patch
Size: 787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190627/a66e6ea3/attachment.bin>
More information about the llvm-commits
mailing list