diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-11-09 19:40:48 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-11-09 19:40:48 +0000 |
commit | dc6bb4982fa74d9faf8350793ba589a0cd06c959 (patch) | |
tree | fac8edb1a3d463780877282d513b3c8af73acd01 /clang/lib/Basic/SourceLocation.cpp | |
parent | 6566e23e131ae73c9724152ce9797cd9a6a4401f (diff) | |
download | llvm-dc6bb4982fa74d9faf8350793ba589a0cd06c959.zip llvm-dc6bb4982fa74d9faf8350793ba589a0cd06c959.tar.gz llvm-dc6bb4982fa74d9faf8350793ba589a0cd06c959.tar.bz2 |
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.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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 @@ 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); } |