]> granicus.if.org Git - clang/commitdiff
Move method out-of-line. I thought this would be a candidate for inlining but I was...
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 27 Feb 2010 17:05:45 +0000 (17:05 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 27 Feb 2010 17:05:45 +0000 (17:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97330 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 1ae0a7ea3f93238e9cb0dbacba8fed3a3e52d1e3..db9c884662ab4b166e048acd7c547b30ff2e1943 100644 (file)
@@ -574,19 +574,7 @@ public:
   /// SmallVector. Note that the returned StringRef may not point to the
   /// supplied buffer if a copy can be avoided.
   llvm::StringRef getSpelling(const Token &Tok,
-                              llvm::SmallVectorImpl<char> &Buffer) const {
-    // Try the fast path.
-    if (const IdentifierInfo *II = Tok.getIdentifierInfo())
-      return II->getName();
-
-    // Resize the buffer if we need to copy into it.
-    if (Tok.needsCleaning())
-      Buffer.resize(Tok.getLength());
-
-    const char *Ptr = Buffer.data();
-    unsigned Len = getSpelling(Tok, Ptr);
-    return llvm::StringRef(Ptr, Len);
-  }
+                              llvm::SmallVectorImpl<char> &Buffer) const;
 
   /// getSpellingOfSingleCharacterNumericConstant - Tok is a numeric constant
   /// with length 1, return the character.
index 84ce062a6ab9e488d1d3a8ae61ee426db89bf665..2c6ad6ee462c79e868c4032bf3eac6ff4967898b 100644 (file)
@@ -40,7 +40,6 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
-#include <cstdio>
 using namespace clang;
 
 //===----------------------------------------------------------------------===//
@@ -365,6 +364,24 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
   return OutBuf-Buffer;
 }
 
+/// 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
+/// supplied buffer if a copy can be avoided.
+llvm::StringRef Preprocessor::getSpelling(const Token &Tok,
+                                    llvm::SmallVectorImpl<char> &Buffer) const {
+  // Try the fast path.
+  if (const IdentifierInfo *II = Tok.getIdentifierInfo())
+    return II->getName();
+
+  // Resize the buffer if we need to copy into it.
+  if (Tok.needsCleaning())
+    Buffer.resize(Tok.getLength());
+
+  const char *Ptr = Buffer.data();
+  unsigned Len = getSpelling(Tok, Ptr);
+  return llvm::StringRef(Ptr, Len);
+}
+
 /// CreateString - Plop the specified string into a scratch buffer and return a
 /// location for it.  If specified, the source location provides a source
 /// location for the token.