Add a SourceLocation::printToString() that returns in a std::string what dump()
writes to stderr; for debugging purposes.

llvm-svn: 167629
diff --git a/clang/lib/Basic/SourceLocation.cpp b/clang/lib/Basic/SourceLocation.cpp
index bb5a10a..0d62f7b 100644
--- a/clang/lib/Basic/SourceLocation.cpp
+++ b/clang/lib/Basic/SourceLocation.cpp
@@ -61,6 +61,13 @@
   OS << '>';
 }
 
+std::string SourceLocation::printToString(const SourceManager &SM) const {
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+  print(OS, SM);
+  return S;
+}
+
 void SourceLocation::dump(const SourceManager &SM) const {
   print(llvm::errs(), SM);
 }