]> granicus.if.org Git - clang/commitdiff
Thread Safety Analysis: Avoid infinite recursion in an operator<<
authorJustin Bogner <mail@justinbogner.com>
Thu, 11 Sep 2014 19:44:04 +0000 (19:44 +0000)
committerJustin Bogner <mail@justinbogner.com>
Thu, 11 Sep 2014 19:44:04 +0000 (19:44 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217621 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/Analyses/ThreadSafetyUtil.h

index 8c987b097c7e810d71aededecc766fd978d7133e..5a7572425c6a254a4cf8911040078a97401fee48 100644 (file)
@@ -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());
 }