From c3222091e1ffa35d0264ca6b680a88c9dc84ede2 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 5 Nov 2009 01:53:52 +0000 Subject: [PATCH] Make LookUpIdentifierInfo const. This makes the Identifiers table mutable and is a little fuzzy, but conceptually it's just uniquing the identifier. Chris, please review. I debated splitting into const/non-const versions where the const one propogated constness to the resulting IdentifierInfo*. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86106 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/Preprocessor.h | 6 +++--- lib/Lex/Preprocessor.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 765c26cbc5..2783716b89 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -96,7 +96,7 @@ class Preprocessor { /// Identifiers - This is mapping/lookup information for all identifiers in /// the program, including program keywords. - IdentifierTable Identifiers; + mutable IdentifierTable Identifiers; /// Selectors - This table contains all the selectors in the program. Unlike /// IdentifierTable above, this table *isn't* populated by the preprocessor. @@ -296,7 +296,7 @@ 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(llvm::StringRef Name) { + IdentifierInfo *getIdentifierInfo(llvm::StringRef Name) const { return &Identifiers.get(Name); } @@ -579,7 +579,7 @@ public: /// LookUpIdentifierInfo - Given a tok::identifier token, look up the /// identifier information for the token and install it into the token. IdentifierInfo *LookUpIdentifierInfo(Token &Identifier, - const char *BufPtr = 0); + const char *BufPtr = 0) const; /// HandleIdentifier - This callback is invoked when the lexer reads an /// identifier and has filled in the tokens IdentifierInfo member. This diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index eddff746f6..487b9d63c1 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -401,7 +401,7 @@ void Preprocessor::EnterMainSourceFile() { /// LookUpIdentifierInfo - Given a tok::identifier token, look up the /// identifier information for the token and install it into the token. IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier, - const char *BufPtr) { + const char *BufPtr) const { assert(Identifier.is(tok::identifier) && "Not an identifier!"); assert(Identifier.getIdentifierInfo() == 0 && "Identinfo already exists!"); -- 2.40.0