diff options
Diffstat (limited to 'clang/Lex')
-rw-r--r-- | clang/Lex/IdentifierTable.cpp | 18 | ||||
-rw-r--r-- | clang/Lex/Lexer.cpp | 2 | ||||
-rw-r--r-- | clang/Lex/PPExpressions.cpp | 4 | ||||
-rw-r--r-- | clang/Lex/Pragma.cpp | 15 | ||||
-rw-r--r-- | clang/Lex/Preprocessor.cpp | 62 |
5 files changed, 50 insertions, 51 deletions
diff --git a/clang/Lex/IdentifierTable.cpp b/clang/Lex/IdentifierTable.cpp index a7da508906f..6b322f971d7 100644 --- a/clang/Lex/IdentifierTable.cpp +++ b/clang/Lex/IdentifierTable.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements the IdentifierTokenInfo, IdentifierVisitor, and +// This file implements the IdentifierInfo, IdentifierVisitor, and // IdentifierTable interfaces. // //===----------------------------------------------------------------------===// @@ -19,10 +19,10 @@ using namespace llvm; using namespace clang; //===----------------------------------------------------------------------===// -// IdentifierTokenInfo Implementation +// IdentifierInfo Implementation //===----------------------------------------------------------------------===// -void IdentifierTokenInfo::Destroy() { +void IdentifierInfo::Destroy() { delete Macro; } @@ -57,7 +57,7 @@ public: NextPtr = (char*)(this+1); // FIXME: uses GCC extension. - unsigned Alignment = __alignof__(IdentifierTokenInfo); + unsigned Alignment = __alignof__(IdentifierInfo); NextPtr = (char*)((intptr_t)(NextPtr+Alignment-1) & ~(intptr_t)(Alignment-1)); } @@ -71,7 +71,7 @@ public: /// void *Allocate(unsigned AllocSize, MemRegion **RegPtr) { // FIXME: uses GCC extension. - unsigned Alignment = __alignof__(IdentifierTokenInfo); + unsigned Alignment = __alignof__(IdentifierInfo); // Round size up to an even multiple of the alignment. AllocSize = (AllocSize+Alignment-1) & ~(Alignment-1); @@ -112,13 +112,13 @@ public: //===----------------------------------------------------------------------===// -/// IdentifierLink - There is one of these allocated by IdentifierTokenInfo. +/// IdentifierLink - There is one of these allocated by IdentifierInfo. /// These form the linked list of buckets for the hash table. struct IdentifierBucket { /// Next - This is the next bucket in the linked list. IdentifierBucket *Next; - IdentifierTokenInfo TokInfo; + IdentifierInfo TokInfo; // NOTE: TokInfo must be the last element in this structure, as the string // information for the identifier is allocated right after it. }; @@ -170,7 +170,7 @@ static unsigned HashString(const char *Start, const char *End) { return Result; } -IdentifierTokenInfo &IdentifierTable::get(const char *NameStart, +IdentifierInfo &IdentifierTable::get(const char *NameStart, const char *NameEnd) { IdentifierBucket **TableArray = (IdentifierBucket**)TheTable; @@ -212,7 +212,7 @@ IdentifierTokenInfo &IdentifierTable::get(const char *NameStart, return Identifier->TokInfo; } -IdentifierTokenInfo &IdentifierTable::get(const std::string &Name) { +IdentifierInfo &IdentifierTable::get(const std::string &Name) { // Don't use c_str() here: no need to be null terminated. const char *NameBytes = &Name[0]; unsigned Size = Name.size(); diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 0fd13eef396..325c013cdee 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -354,7 +354,7 @@ FinishIdentifier: Result.SetKind(tok::identifier); // Look up this token, see if it is a macro, or if it is a language keyword. - IdentifierTokenInfo *II; + IdentifierInfo *II; if (!Result.needsCleaning()) { // No cleaning needed, just use the characters from the lexed buffer. II = PP.getIdentifierInfo(IdStart, IdEnd); diff --git a/clang/Lex/PPExpressions.cpp b/clang/Lex/PPExpressions.cpp index 979cb171106..393b780eed7 100644 --- a/clang/Lex/PPExpressions.cpp +++ b/clang/Lex/PPExpressions.cpp @@ -29,7 +29,7 @@ using namespace clang; /// may occur after a #if or #elif directive. If the /// expression is equivalent to "!defined(X)" return X in IfNDefMacro. bool Preprocessor:: -EvaluateDirectiveExpression(IdentifierTokenInfo *&IfNDefMacro) { +EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { // Peek ahead one token. LexerToken Tok; Lex(Tok); @@ -62,7 +62,7 @@ bool Preprocessor::EvaluateValue(int &Result, LexerToken &PeekTok) { // If this token's spelling is a pp-identifier, check to see if it is // 'defined' or if it is a macro. Note that we check here because many // keywords are pp-identifiers, so we can't check the kind. - if (const IdentifierTokenInfo *II = PeekTok.getIdentifierInfo()) { + if (const IdentifierInfo *II = PeekTok.getIdentifierInfo()) { // If this identifier isn't 'defined' and it wasn't macro expanded, it turns // into a simple 0. if (strcmp(II->getName(), "defined")) { diff --git a/clang/Lex/Pragma.cpp b/clang/Lex/Pragma.cpp index 9b0fe5f495a..fd9aba8c24c 100644 --- a/clang/Lex/Pragma.cpp +++ b/clang/Lex/Pragma.cpp @@ -39,7 +39,7 @@ PragmaNamespace::~PragmaNamespace() { /// specified name. If not, return the handler for the null identifier if it /// exists, otherwise return null. If IgnoreNull is true (the default) then /// the null handler isn't returned on failure to match. -PragmaHandler *PragmaNamespace::FindHandler(const IdentifierTokenInfo *Name, +PragmaHandler *PragmaNamespace::FindHandler(const IdentifierInfo *Name, bool IgnoreNull) const { PragmaHandler *NullHandler = 0; for (unsigned i = 0, e = Handlers.size(); i != e; ++i) { @@ -206,8 +206,7 @@ void Preprocessor::HandlePragmaPoison(LexerToken &PoisonTok) { // Look up the identifier info for the token. std::string TokStr = getSpelling(Tok); - IdentifierTokenInfo *II = - getIdentifierInfo(&TokStr[0], &TokStr[0]+TokStr.size()); + IdentifierInfo *II =getIdentifierInfo(&TokStr[0], &TokStr[0]+TokStr.size()); // Already poisoned. if (II->isPoisoned()) continue; @@ -293,7 +292,7 @@ void Preprocessor::AddPragmaHandler(const char *Namespace, // If this is specified to be in a namespace, step down into it. if (Namespace) { - IdentifierTokenInfo *NSID = getIdentifierInfo(Namespace); + IdentifierInfo *NSID = getIdentifierInfo(Namespace); // If there is already a pragma handler with the name of this namespace, // we either have an error (directive with the same name as a namespace) or @@ -318,7 +317,7 @@ void Preprocessor::AddPragmaHandler(const char *Namespace, namespace { struct PragmaOnceHandler : public PragmaHandler { - PragmaOnceHandler(const IdentifierTokenInfo *OnceID) : PragmaHandler(OnceID){} + PragmaOnceHandler(const IdentifierInfo *OnceID) : PragmaHandler(OnceID) {} virtual void HandlePragma(Preprocessor &PP, LexerToken &OnceTok) { PP.CheckEndOfDirective("#pragma once"); PP.HandlePragmaOnce(OnceTok); @@ -326,21 +325,21 @@ struct PragmaOnceHandler : public PragmaHandler { }; struct PragmaPoisonHandler : public PragmaHandler { - PragmaPoisonHandler(const IdentifierTokenInfo *ID) : PragmaHandler(ID) {} + PragmaPoisonHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {} virtual void HandlePragma(Preprocessor &PP, LexerToken &PoisonTok) { PP.HandlePragmaPoison(PoisonTok); } }; struct PragmaSystemHeaderHandler : public PragmaHandler { - PragmaSystemHeaderHandler(const IdentifierTokenInfo *ID) : PragmaHandler(ID){} + PragmaSystemHeaderHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {} virtual void HandlePragma(Preprocessor &PP, LexerToken &SHToken) { PP.HandlePragmaSystemHeader(SHToken); PP.CheckEndOfDirective("#pragma"); } }; struct PragmaDependencyHandler : public PragmaHandler { - PragmaDependencyHandler(const IdentifierTokenInfo *ID) : PragmaHandler(ID) {} + PragmaDependencyHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {} virtual void HandlePragma(Preprocessor &PP, LexerToken &DepToken) { PP.HandlePragmaDependency(DepToken); } diff --git a/clang/Lex/Preprocessor.cpp b/clang/Lex/Preprocessor.cpp index 7c3b7138ec5..b5cae2df2f6 100644 --- a/clang/Lex/Preprocessor.cpp +++ b/clang/Lex/Preprocessor.cpp @@ -421,7 +421,7 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer, /// EnterMacro - Add a Macro to the top of the include stack and start lexing /// tokens from it instead of the current buffer. void Preprocessor::EnterMacro(LexerToken &Tok) { - IdentifierTokenInfo *Identifier = Tok.getIdentifierInfo(); + IdentifierInfo *Identifier = Tok.getIdentifierInfo(); MacroInfo &MI = *Identifier->getMacroInfo(); IncludeMacroStack.push_back(IncludeStackInfo(CurLexer, CurDirLookup, CurMacroExpander)); @@ -442,9 +442,9 @@ void Preprocessor::EnterMacro(LexerToken &Tok) { /// RegisterBuiltinMacro - Register the specified identifier in the identifier /// table and mark it as a builtin macro to be expanded. -IdentifierTokenInfo *Preprocessor::RegisterBuiltinMacro(const char *Name) { +IdentifierInfo *Preprocessor::RegisterBuiltinMacro(const char *Name) { // Get the identifier. - IdentifierTokenInfo *Id = getIdentifierInfo(Name); + IdentifierInfo *Id = getIdentifierInfo(Name); // Mark it as being a macro that is builtin. MacroInfo *MI = new MacroInfo(SourceLocation()); @@ -578,12 +578,12 @@ static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc, /// as a builtin macro, handle it and return the next token as 'Tok'. void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) { // Figure out which token this is. - IdentifierTokenInfo *ITI = Tok.getIdentifierInfo(); - assert(ITI && "Can't be a macro without id info!"); + IdentifierInfo *II = Tok.getIdentifierInfo(); + assert(II && "Can't be a macro without id info!"); // If this is an _Pragma directive, expand it, invoke the pragma handler, then // lex the token after it. - if (ITI == Ident_Pragma) + if (II == Ident_Pragma) return Handle_Pragma(Tok); char TmpBuffer[100]; @@ -592,16 +592,16 @@ void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) { Tok.SetIdentifierInfo(0); Tok.ClearFlag(LexerToken::NeedsCleaning); - if (ITI == Ident__LINE__) { + if (II == Ident__LINE__) { // __LINE__ expands to a simple numeric value. sprintf(TmpBuffer, "%u", SourceMgr.getLineNumber(Tok.getLocation())); unsigned Length = strlen(TmpBuffer); Tok.SetKind(tok::numeric_constant); Tok.SetLength(Length); Tok.SetLocation(ScratchBuf->getToken(TmpBuffer, Length, Tok.getLocation())); - } else if (ITI == Ident__FILE__ || ITI == Ident__BASE_FILE__) { + } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) { SourceLocation Loc = Tok.getLocation(); - if (ITI == Ident__BASE_FILE__) { + if (II == Ident__BASE_FILE__) { Diag(Tok, diag::ext_pp_base_file); SourceLocation NextLoc = SourceMgr.getIncludeLoc(Loc.getFileID()); while (NextLoc.getFileID() != 0) { @@ -616,19 +616,19 @@ void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) { Tok.SetKind(tok::string_literal); Tok.SetLength(FN.size()); Tok.SetLocation(ScratchBuf->getToken(&FN[0], FN.size(), Tok.getLocation())); - } else if (ITI == Ident__DATE__) { + } else if (II == Ident__DATE__) { if (!DATELoc.isValid()) ComputeDATE_TIME(DATELoc, TIMELoc, ScratchBuf); Tok.SetKind(tok::string_literal); Tok.SetLength(strlen("\"Mmm dd yyyy\"")); Tok.SetLocation(SourceMgr.getInstantiationLoc(DATELoc, Tok.getLocation())); - } else if (ITI == Ident__TIME__) { + } else if (II == Ident__TIME__) { if (!TIMELoc.isValid()) ComputeDATE_TIME(DATELoc, TIMELoc, ScratchBuf); Tok.SetKind(tok::string_literal); Tok.SetLength(strlen("\"hh:mm:ss\"")); Tok.SetLocation(SourceMgr.getInstantiationLoc(TIMELoc, Tok.getLocation())); - } else if (ITI == Ident__INCLUDE_LEVEL__) { + } else if (II == Ident__INCLUDE_LEVEL__) { Diag(Tok, diag::ext_pp_include_level); // Compute the include depth of this token. @@ -643,7 +643,7 @@ void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) { Tok.SetKind(tok::numeric_constant); Tok.SetLength(Length); Tok.SetLocation(ScratchBuf->getToken(TmpBuffer, Length, Tok.getLocation())); - } else if (ITI == Ident__TIMESTAMP__) { + } else if (II == Ident__TIMESTAMP__) { // MSVC, ICC, GCC, VisualAge C++ extension. The generated string should be // of the form "Ddd Mmm dd hh::mm::ss yyyy", which is returned by asctime. Diag(Tok, diag::ext_pp_timestamp); @@ -682,9 +682,9 @@ struct UnusedIdentifierReporter : public IdentifierVisitor { Preprocessor &PP; UnusedIdentifierReporter(Preprocessor &pp) : PP(pp) {} - void VisitIdentifier(IdentifierTokenInfo &ITI) const { - if (ITI.getMacroInfo() && !ITI.getMacroInfo()->isUsed()) - PP.Diag(ITI.getMacroInfo()->getDefinitionLoc(), diag::pp_macro_not_used); + void VisitIdentifier(IdentifierInfo &II) const { + if (II.getMacroInfo() && !II.getMacroInfo()->isUsed()) + PP.Diag(II.getMacroInfo()->getDefinitionLoc(), diag::pp_macro_not_used); } }; } @@ -703,23 +703,23 @@ void Preprocessor::HandleIdentifier(LexerToken &Identifier) { assert(isSkipping() && "Token isn't an identifier?"); return; } - IdentifierTokenInfo &ITI = *Identifier.getIdentifierInfo(); + IdentifierInfo &II = *Identifier.getIdentifierInfo(); // If this identifier was poisoned, and if it was not produced from a macro // expansion, emit an error. - if (ITI.isPoisoned() && CurLexer) + if (II.isPoisoned() && CurLexer) Diag(Identifier, diag::err_pp_used_poisoned_id); - if (MacroInfo *MI = ITI.getMacroInfo()) + if (MacroInfo *MI = II.getMacroInfo()) if (MI->isEnabled() && !DisableMacroExpansion) return HandleMacroExpandedIdentifier(Identifier, MI); // Change the kind of this identifier to the appropriate token kind, e.g. // turning "for" into a keyword. - Identifier.SetKind(ITI.getTokenID()); + Identifier.SetKind(II.getTokenID()); // If this is an extension token, diagnose its use. - if (ITI.isExtensionToken()) Diag(Identifier, diag::ext_token_used); + if (II.isExtensionToken()) Diag(Identifier, diag::ext_token_used); } /// HandleEndOfFile - This callback is invoked when the lexer hits the end of @@ -743,7 +743,7 @@ void Preprocessor::HandleEndOfFile(LexerToken &Result, bool isEndOfMacro) { // See if this file had a controlling macro. if (CurLexer) { // Not ending a macro, ignore it. - if (const IdentifierTokenInfo *ControllingMacro = + if (const IdentifierInfo *ControllingMacro = CurLexer->MIOpt.GetControllingMacroAtEndOfFile()) { // Okay, this has a controlling macro, remember in PerFileInfo. if (const FileEntry *FE = @@ -788,7 +788,7 @@ void Preprocessor::HandleEndOfFile(LexerToken &Result, bool isEndOfMacro) { CurLexer = 0; // This is the end of the top-level file. - IdentifierInfo.VisitIdentifiers(UnusedIdentifierReporter(*this)); + Identifiers.VisitIdentifiers(UnusedIdentifierReporter(*this)); } /// HandleEndOfMacro - This callback is invoked when the lexer hits the end of @@ -833,19 +833,19 @@ void Preprocessor::ReadMacroName(LexerToken &MacroNameTok, bool isDefineUndef) { if (MacroNameTok.getKind() == tok::eom) return Diag(MacroNameTok, diag::err_pp_missing_macro_name); - IdentifierTokenInfo *ITI = MacroNameTok.getIdentifierInfo(); - if (ITI == 0) { + IdentifierInfo *II = MacroNameTok.getIdentifierInfo(); + if (II == 0) { Diag(MacroNameTok, diag::err_pp_macro_not_identifier); // Fall through on error. } else if (0) { // FIXME: C++. Error if defining a C++ named operator. - } else if (isDefineUndef && ITI->getName()[0] == 'd' && // defined - !strcmp(ITI->getName()+1, "efined")) { + } else if (isDefineUndef && II->getName()[0] == 'd' && // defined + !strcmp(II->getName()+1, "efined")) { // Error if defining "defined": C99 6.10.8.4. Diag(MacroNameTok, diag::err_defined_macro_name); - } else if (isDefineUndef && ITI->getMacroInfo() && - ITI->getMacroInfo()->isBuiltinMacro()) { + } else if (isDefineUndef && II->getMacroInfo() && + II->getMacroInfo()->isBuiltinMacro()) { // Error if defining "__LINE__" and other builtins: C99 6.10.8.4. Diag(MacroNameTok, diag::pp_undef_builtin_macro); } else { @@ -1020,7 +1020,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, // looked up, etc, inside the #elif expression. assert(SkippingContents && "We have to be skipping here!"); SkippingContents = false; - IdentifierTokenInfo *IfNDefMacro = 0; + IdentifierInfo *IfNDefMacro = 0; ShouldEnter = EvaluateDirectiveExpression(IfNDefMacro); SkippingContents = true; } @@ -1455,7 +1455,7 @@ void Preprocessor::HandleIfDirective(LexerToken &IfToken, ++NumIf; // Parse and evaluation the conditional expression. - IdentifierTokenInfo *IfNDefMacro = 0; + IdentifierInfo *IfNDefMacro = 0; bool ConditionalTrue = EvaluateDirectiveExpression(IfNDefMacro); // Should we include the stuff contained by this directive? |