]> granicus.if.org Git - clang/commitdiff
Don't claim that things that are Objective-C keywords if preceded by an @ are keyword...
authorDavid Chisnall <csdavec@swan.ac.uk>
Wed, 13 Oct 2010 21:44:48 +0000 (21:44 +0000)
committerDavid Chisnall <csdavec@swan.ac.uk>
Wed, 13 Oct 2010 21:44:48 +0000 (21:44 +0000)
For example, don't claim that end is a keyword in:

unsigned end;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116439 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndex.cpp

index a5b342dbe75f4e80c43badf84998dbbf5045e2c7..1d7efe42082fe1e241cba403ae6a42b519a17ebc 100644 (file)
@@ -3533,6 +3533,7 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
   const char *EffectiveBufferEnd = Buffer.data() + EndLocInfo.second;
   llvm::SmallVector<CXToken, 32> CXTokens;
   Token Tok;
+  bool previousWasAt = false;
   do {
     // Lex the next token
     Lex.LexFromRawLexer(Tok);
@@ -3565,7 +3566,7 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
       IdentifierInfo *II
         = CXXUnit->getPreprocessor().LookUpIdentifierInfo(Tok, StartPos);
 
-      if (II->getObjCKeywordID() != tok::objc_not_keyword) {
+      if ((II->getObjCKeywordID() != tok::objc_not_keyword) && previousWasAt) {
         CXTok.int_data[0] = CXToken_Keyword;
       }
       else {
@@ -3582,6 +3583,7 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
       CXTok.ptr_data = 0;
     }
     CXTokens.push_back(CXTok);
+    previousWasAt = Tok.is(tok::at);
   } while (Lex.getBufferLocation() <= EffectiveBufferEnd);
 
   if (CXTokens.empty())