From 3da736c1143126be19b253804b3b135ebcd3d6ff Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 5 Nov 2009 01:53:39 +0000 Subject: [PATCH] StringRefize Preprocessor::getIdentifierInfo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86105 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/Preprocessor.h | 8 ++------ lib/Lex/Preprocessor.cpp | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 3a401c999d..765c26cbc5 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -296,12 +296,8 @@ public: /// pointers is preferred unless the identifier is already available as a /// string (this avoids allocation and copying of memory to construct an /// std::string). - IdentifierInfo *getIdentifierInfo(const char *NameStart, - const char *NameEnd) { - return &Identifiers.get(NameStart, NameEnd); - } - IdentifierInfo *getIdentifierInfo(const char *NameStr) { - return getIdentifierInfo(NameStr, NameStr+strlen(NameStr)); + IdentifierInfo *getIdentifierInfo(llvm::StringRef Name) { + return &Identifiers.get(Name); } /// AddPragmaHandler - Add the specified pragma handler to the preprocessor. diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index b175a49856..eddff746f6 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -409,14 +409,14 @@ IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier, IdentifierInfo *II; if (BufPtr && !Identifier.needsCleaning()) { // No cleaning needed, just use the characters from the lexed buffer. - II = getIdentifierInfo(BufPtr, BufPtr+Identifier.getLength()); + II = getIdentifierInfo(llvm::StringRef(BufPtr, Identifier.getLength())); } else { // Cleaning needed, alloca a buffer, clean into it, then use the buffer. llvm::SmallVector IdentifierBuffer; IdentifierBuffer.resize(Identifier.getLength()); const char *TmpBuf = &IdentifierBuffer[0]; unsigned Size = getSpelling(Identifier, TmpBuf); - II = getIdentifierInfo(TmpBuf, TmpBuf+Size); + II = getIdentifierInfo(llvm::StringRef(TmpBuf, Size)); } Identifier.setIdentifierInfo(II); return II; -- 2.40.0