[cfe-commits] r119469 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Lex/LiteralSupport.cpp lib/Lex/Preprocessor.cpp

Chris Lattner sabre at nondot.org
Tue Nov 16 22:31:48 PST 2010


Author: lattner
Date: Wed Nov 17 00:31:48 2010
New Revision: 119469

URL: http://llvm.org/viewvc/llvm-project?rev=119469&view=rev
Log:
add a static form of the efficient PP::getSpelling method.

Modified:
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Lex/LiteralSupport.cpp
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=119469&r1=119468&r2=119469&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Nov 17 00:31:48 2010
@@ -664,7 +664,13 @@
   /// 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

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=119469&r1=119468&r2=119469&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed Nov 17 00:31:48 2010
@@ -1016,7 +1016,10 @@
 
   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;
 

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=119469&r1=119468&r2=119469&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Nov 17 00:31:48 2010
@@ -339,8 +339,10 @@
 /// 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





More information about the cfe-commits mailing list