diff options
-rw-r--r-- | include/clang/Basic/SourceLocation.h | 1 | ||||
-rw-r--r-- | lib/Basic/SourceLocation.cpp | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index d6bba38563..0bd0c92b00 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -171,6 +171,7 @@ public: } void print(raw_ostream &OS, const SourceManager &SM) const; + LLVM_ATTRIBUTE_USED std::string printToString(const SourceManager &SM) const; void dump(const SourceManager &SM) const; }; diff --git a/lib/Basic/SourceLocation.cpp b/lib/Basic/SourceLocation.cpp index bb5a10a9c7..0d62f7bb4b 100644 --- a/lib/Basic/SourceLocation.cpp +++ b/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); } |