r217621 - Thread Safety Analysis: Avoid infinite recursion in an operator<<
Justin Bogner
mail at justinbogner.com
Thu Sep 11 12:44:05 PDT 2014
Author: bogner
Date: Thu Sep 11 14:44:04 2014
New Revision: 217621
URL: http://llvm.org/viewvc/llvm-project?rev=217621&view=rev
Log:
Thread Safety Analysis: Avoid infinite recursion in an operator<<
r217556 introduced an operator<<(std::ostream &, StringRef) that seems
to self recurse on some systems, because str.data(), which is a char *,
was being implicitly converted back to StringRef in overload
resolution.
This manifested as SemaCXX/warn-thread-safety-analysis.cpp timing out
in release builds and overflowing the stack in debug builds. One of
the failing systems that saw this is here:
http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/4636
Using ostream's write method instead of operator<< should get the bots
going again.
Modified:
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h?rev=217621&r1=217620&r2=217621&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h Thu Sep 11 14:44:04 2014
@@ -24,6 +24,7 @@
#include <cstddef>
#include <vector>
#include <utility>
+#include <ostream>
namespace clang {
namespace threadSafety {
@@ -360,8 +361,7 @@ private:
inline std::ostream& operator<<(std::ostream& ss, const StringRef str) {
- ss << str.data();
- return ss;
+ return ss.write(str.data(), str.size());
}
More information about the cfe-commits
mailing list