]> granicus.if.org Git - clang/commitdiff
add a static form of the efficient PP::getSpelling method.
authorChris Lattner <sabre@nondot.org>
Wed, 17 Nov 2010 06:31:48 +0000 (06:31 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 17 Nov 2010 06:31:48 +0000 (06:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119469 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Preprocessor.h
lib/Lex/LiteralSupport.cpp
lib/Lex/Preprocessor.cpp

index b45f47bf117e1a3dd2aa3b4a9bf76f188a823fba..380d1163865610addd0744c1a0525e2e601f1b98 100644 (file)
@@ -664,7 +664,13 @@ public:
   /// copy).  The caller is not allowed to modify the returned buffer pointer
   /// if an internal buffer is returned.
   unsigned getSpelling(const Token &Tok, const char *&Buffer, 
-                       bool *Invalid = 0) const;
+                       bool *Invalid = 0) const {
+    return getSpelling(Tok, Buffer, SourceMgr, Features, Invalid);
+  }
+  static unsigned getSpelling(const Token &Tok, const char *&Buffer, 
+                              const SourceManager &SourceMgr,
+                              const LangOptions &Features,
+                              bool *Invalid = 0);
 
   /// getSpelling - This method is used to get the spelling of a token into a
   /// SmallVector. Note that the returned StringRef may not point to the
index 10adb67814aef6308d12fe23b2b45326924a40ef..26be1d0ae1e7f15635c04133b342eec651ec5968 100644 (file)
@@ -1016,7 +1016,10 @@ unsigned StringLiteralParser::getOffsetOfStringByte(const Token &Tok,
 
   bool StringInvalid = false;
   const char *SpellingPtr = &SpellingBuffer[0];
-  unsigned TokLen = PP.getSpelling(Tok, SpellingPtr, &StringInvalid);
+  unsigned TokLen = Preprocessor::getSpelling(Tok, SpellingPtr,
+                                              PP.getSourceManager(),
+                                              PP.getLangOptions(),
+                                              &StringInvalid);
   if (StringInvalid)
     return 0;
 
index ff18c3f32456f4195faec4d67cdfb1d7705d8c38..e9b854306aa7d88e4dcc2497f239b1f6be360591 100644 (file)
@@ -339,8 +339,10 @@ std::string Preprocessor::getSpelling(const Token &Tok, bool *Invalid) const {
 /// to point to a constant buffer with the data already in it (avoiding a
 /// copy).  The caller is not allowed to modify the returned buffer pointer
 /// if an internal buffer is returned.
-unsigned Preprocessor::getSpelling(const Token &Tok,
-                                   const char *&Buffer, bool *Invalid) const {
+unsigned Preprocessor::getSpelling(const Token &Tok, const char *&Buffer, 
+                                   const SourceManager &SourceMgr,
+                                   const LangOptions &Features,
+                                   bool *Invalid) {
   assert((int)Tok.getLength() >= 0 && "Token character range is bogus!");
 
   // If this token is an identifier, just return the string from the identifier