[cfe-commits] r98340 - /cfe/trunk/lib/Basic/IdentifierTable.cpp

Kovarththanan Rajaratnam kovarththanan.rajaratnam at gmail.com
Fri Mar 12 03:06:42 PST 2010


Hey Benjamin,

On 12-03-2010 12:04, Benjamin Kramer wrote:
>
> On 12.03.2010, at 11:14, Kovarththanan Rajaratnam wrote:
>
>> Author: krj
>> Date: Fri Mar 12 04:14:26 2010
>> New Revision: 98340
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=98340&view=rev
>> Log:
>> Add keywords using StringRef
>>
>> Modified:
>>     cfe/trunk/lib/Basic/IdentifierTable.cpp
>>
>> Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=98340&r1=98339&r2=98340&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
>> +++ cfe/trunk/lib/Basic/IdentifierTable.cpp Fri Mar 12 04:14:26 2010
>> @@ -16,6 +16,7 @@
>> #include "clang/Basic/LangOptions.h"
>> #include "llvm/ADT/FoldingSet.h"
>> #include "llvm/ADT/DenseMap.h"
>> +#include "llvm/ADT/StringRef.h"
>> #include "llvm/Support/raw_ostream.h"
>> #include<cstdio>
>>
>> @@ -81,7 +82,7 @@
>> /// enabled in the specified langauge, set to 1 if it is an extension
>> /// in the specified language, and set to 2 if disabled in the
>> /// specified language.
>> -static void AddKeyword(const char *Keyword, unsigned KWLen,
>> +static void AddKeyword(llvm::StringRef Keyword,
>>                         tok::TokenKind TokenCode, unsigned Flags,
>>                         const LangOptions&LangOpts, IdentifierTable&Table) {
>>    unsigned AddResult = 0;
>> @@ -97,17 +98,17 @@
>>    // Don't add this keyword if disabled in this language.
>>    if (AddResult == 0) return;
>>
>> -  IdentifierInfo&Info = Table.get(Keyword, Keyword+KWLen);
>> +  IdentifierInfo&Info = Table.get(Keyword);
>>    Info.setTokenID(TokenCode);
>>    Info.setIsExtensionToken(AddResult == 1);
>> }
>>
>> /// AddCXXOperatorKeyword - Register a C++ operator keyword alternative
>> /// representations.
>> -static void AddCXXOperatorKeyword(const char *Keyword, unsigned KWLen,
>> +static void AddCXXOperatorKeyword(llvm::StringRef Keyword,
>>                                    tok::TokenKind TokenCode,
>>                                    IdentifierTable&Table) {
>> -  IdentifierInfo&Info = Table.get(Keyword, Keyword + KWLen);
>> +  IdentifierInfo&Info = Table.get(Keyword);
>>    Info.setTokenID(TokenCode);
>>    Info.setIsCPlusPlusOperatorKeyword();
>> }
>> @@ -115,9 +116,9 @@
>> /// AddObjCKeyword - Register an Objective-C @keyword like "class" "selector" or
>> /// "property".
>> static void AddObjCKeyword(tok::ObjCKeywordKind ObjCID,
>> -                           const char *Name, unsigned NameLen,
>> +                           llvm::StringRef Name,
>>                             IdentifierTable&Table) {
>> -  Table.get(Name, Name+NameLen).setObjCKeywordID(ObjCID);
>> +  Table.get(Name).setObjCKeywordID(ObjCID);
>> }
>>
>> /// AddKeywords - Add all keywords to the symbol table.
>> @@ -125,20 +126,20 @@
>> void IdentifierTable::AddKeywords(const LangOptions&LangOpts) {
>>    // Add keywords and tokens for the current language.
>> #define KEYWORD(NAME, FLAGS) \
>> -  AddKeyword(#NAME, strlen(#NAME), tok::kw_ ## NAME,  \
>> +  AddKeyword(llvm::StringRef(#NAME), tok::kw_ ## NAME,  \
>>               FLAGS, LangOpts, *this);
>> #define ALIAS(NAME, TOK, FLAGS) \
>> -  AddKeyword(NAME, strlen(NAME), tok::kw_ ## TOK,  \
>> +  AddKeyword(llvm::StringRef(#NAME), tok::kw_ ## TOK,  \
>>               FLAGS, LangOpts, *this);
>
> The # (in #NAME) doesn't belong there.

Oops. Copy/paste. I'll fix it.

Thanks.

-- 
Best regards,
Kovarththanan Rajaratnam




More information about the cfe-commits mailing list