diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index facef7b7ae54c056b561e89dccceca9c87bb1b85..1c0036e3edcb979a3b4cf3e03a0b9b3538a86c1c 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -503,6 +503,15 @@ public: /// UCNs, etc. std::string getSpelling(const Token &Tok) const; + /// getSpelling() - Return the 'spelling' of the Tok token. The spelling of a + /// token is the characters used to represent the token in the source file + /// after trigraph expansion and escaped-newline folding. In particular, this + /// wants to get the true, uncanonicalized, spelling of things like digraphs + /// UCNs, etc. + static std::string getSpelling(const Token &Tok, + const SourceManager &SourceMgr, + const LangOptions &Features); + /// getSpelling - This method is used to get the spelling of a token into a /// preallocated buffer, instead of as an std::string. The caller is required /// to allocate enough space for the token, which is guaranteed to be at least diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 96c6682ad7853e427e61fb7adb3b2d9d0c47e92d..066909475fe35c4c3c20f419eb0a85ba36c5463a 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -192,13 +192,14 @@ void Preprocessor::PrintStats() { // Token Spelling //===----------------------------------------------------------------------===// - /// getSpelling() - Return the 'spelling' of this token. The spelling of a /// token are the characters used to represent the token in the source file /// after trigraph expansion and escaped-newline folding. In particular, this /// wants to get the true, uncanonicalized, spelling of things like digraphs /// UCNs, etc. -std::string Preprocessor::getSpelling(const Token &Tok) const { +std::string Preprocessor::getSpelling(const Token &Tok, + const SourceManager &SourceMgr, + const LangOptions &Features) { assert((int)Tok.getLength() >= 0 && "Token character range is bogus!"); // If this token contains nothing interesting, return it directly. @@ -221,6 +222,15 @@ std::string Preprocessor::getSpelling(const Token &Tok) const { return Result; } +/// getSpelling() - Return the 'spelling' of this token. The spelling of a +/// token are the characters used to represent the token in the source file +/// after trigraph expansion and escaped-newline folding. In particular, this +/// wants to get the true, uncanonicalized, spelling of things like digraphs +/// UCNs, etc. +std::string Preprocessor::getSpelling(const Token &Tok) const { + return getSpelling(Tok, SourceMgr, Features); +} + /// getSpelling - This method is used to get the spelling of a token into a /// preallocated buffer, instead of as an std::string. The caller is required /// to allocate enough space for the token, which is guaranteed to be at least