[cfe-commits] r97330 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Lex/Preprocessor.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sat Feb 27 09:05:45 PST 2010
Author: d0k
Date: Sat Feb 27 11:05:45 2010
New Revision: 97330
URL: http://llvm.org/viewvc/llvm-project?rev=97330&view=rev
Log:
Move method out-of-line. I thought this would be a candidate for inlining but I was wrong.
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
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=97330&r1=97329&r2=97330&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Sat Feb 27 11:05:45 2010
@@ -574,19 +574,7 @@
/// 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.
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=97330&r1=97329&r2=97330&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Sat Feb 27 11:05:45 2010
@@ -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 @@
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.
More information about the cfe-commits
mailing list