summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/SourceLocation.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-11-09 19:40:48 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-11-09 19:40:48 +0000
commitdc6bb4982fa74d9faf8350793ba589a0cd06c959 (patch)
treefac8edb1a3d463780877282d513b3c8af73acd01 /clang/lib/Basic/SourceLocation.cpp
parent6566e23e131ae73c9724152ce9797cd9a6a4401f (diff)
downloadbcm5719-llvm-dc6bb4982fa74d9faf8350793ba589a0cd06c959.tar.gz
bcm5719-llvm-dc6bb4982fa74d9faf8350793ba589a0cd06c959.zip
Add a SourceLocation::printToString() that returns in a std::string what dump()
writes to stderr; for debugging purposes. llvm-svn: 167629
Diffstat (limited to 'clang/lib/Basic/SourceLocation.cpp')
-rw-r--r--clang/lib/Basic/SourceLocation.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceLocation.cpp b/clang/lib/Basic/SourceLocation.cpp
index bb5a10a9c7e..0d62f7bb4b8 100644
--- a/clang/lib/Basic/SourceLocation.cpp
+++ b/clang/lib/Basic/SourceLocation.cpp
@@ -61,6 +61,13 @@ void SourceLocation::print(raw_ostream &OS, const SourceManager &SM)const{
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);
}
OpenPOWER on IntegriCloud