Rename IdentifierTokenInfo -> IdentifierInfo.
llvm-svn: 38650
This commit is contained in:
parent
a8654ca2cf
commit
c79f6fb108
|
@ -7,7 +7,7 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// This file implements the IdentifierTokenInfo, IdentifierVisitor, and
|
// This file implements the IdentifierInfo, IdentifierVisitor, and
|
||||||
// IdentifierTable interfaces.
|
// IdentifierTable interfaces.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -19,10 +19,10 @@ using namespace llvm;
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// IdentifierTokenInfo Implementation
|
// IdentifierInfo Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
void IdentifierTokenInfo::Destroy() {
|
void IdentifierInfo::Destroy() {
|
||||||
delete Macro;
|
delete Macro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
NextPtr = (char*)(this+1);
|
NextPtr = (char*)(this+1);
|
||||||
|
|
||||||
// FIXME: uses GCC extension.
|
// FIXME: uses GCC extension.
|
||||||
unsigned Alignment = __alignof__(IdentifierTokenInfo);
|
unsigned Alignment = __alignof__(IdentifierInfo);
|
||||||
NextPtr = (char*)((intptr_t)(NextPtr+Alignment-1) &
|
NextPtr = (char*)((intptr_t)(NextPtr+Alignment-1) &
|
||||||
~(intptr_t)(Alignment-1));
|
~(intptr_t)(Alignment-1));
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
///
|
///
|
||||||
void *Allocate(unsigned AllocSize, MemRegion **RegPtr) {
|
void *Allocate(unsigned AllocSize, MemRegion **RegPtr) {
|
||||||
// FIXME: uses GCC extension.
|
// FIXME: uses GCC extension.
|
||||||
unsigned Alignment = __alignof__(IdentifierTokenInfo);
|
unsigned Alignment = __alignof__(IdentifierInfo);
|
||||||
// Round size up to an even multiple of the alignment.
|
// Round size up to an even multiple of the alignment.
|
||||||
AllocSize = (AllocSize+Alignment-1) & ~(Alignment-1);
|
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.
|
/// These form the linked list of buckets for the hash table.
|
||||||
struct IdentifierBucket {
|
struct IdentifierBucket {
|
||||||
/// Next - This is the next bucket in the linked list.
|
/// Next - This is the next bucket in the linked list.
|
||||||
IdentifierBucket *Next;
|
IdentifierBucket *Next;
|
||||||
|
|
||||||
IdentifierTokenInfo TokInfo;
|
IdentifierInfo TokInfo;
|
||||||
// NOTE: TokInfo must be the last element in this structure, as the string
|
// NOTE: TokInfo must be the last element in this structure, as the string
|
||||||
// information for the identifier is allocated right after it.
|
// information for the identifier is allocated right after it.
|
||||||
};
|
};
|
||||||
|
@ -170,7 +170,7 @@ static unsigned HashString(const char *Start, const char *End) {
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifierTokenInfo &IdentifierTable::get(const char *NameStart,
|
IdentifierInfo &IdentifierTable::get(const char *NameStart,
|
||||||
const char *NameEnd) {
|
const char *NameEnd) {
|
||||||
IdentifierBucket **TableArray = (IdentifierBucket**)TheTable;
|
IdentifierBucket **TableArray = (IdentifierBucket**)TheTable;
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ IdentifierTokenInfo &IdentifierTable::get(const char *NameStart,
|
||||||
return Identifier->TokInfo;
|
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.
|
// Don't use c_str() here: no need to be null terminated.
|
||||||
const char *NameBytes = &Name[0];
|
const char *NameBytes = &Name[0];
|
||||||
unsigned Size = Name.size();
|
unsigned Size = Name.size();
|
||||||
|
|
|
@ -354,7 +354,7 @@ FinishIdentifier:
|
||||||
Result.SetKind(tok::identifier);
|
Result.SetKind(tok::identifier);
|
||||||
|
|
||||||
// Look up this token, see if it is a macro, or if it is a language keyword.
|
// Look up this token, see if it is a macro, or if it is a language keyword.
|
||||||
IdentifierTokenInfo *II;
|
IdentifierInfo *II;
|
||||||
if (!Result.needsCleaning()) {
|
if (!Result.needsCleaning()) {
|
||||||
// No cleaning needed, just use the characters from the lexed buffer.
|
// No cleaning needed, just use the characters from the lexed buffer.
|
||||||
II = PP.getIdentifierInfo(IdStart, IdEnd);
|
II = PP.getIdentifierInfo(IdStart, IdEnd);
|
||||||
|
|
|
@ -29,7 +29,7 @@ using namespace clang;
|
||||||
/// may occur after a #if or #elif directive. If the
|
/// may occur after a #if or #elif directive. If the
|
||||||
/// expression is equivalent to "!defined(X)" return X in IfNDefMacro.
|
/// expression is equivalent to "!defined(X)" return X in IfNDefMacro.
|
||||||
bool Preprocessor::
|
bool Preprocessor::
|
||||||
EvaluateDirectiveExpression(IdentifierTokenInfo *&IfNDefMacro) {
|
EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) {
|
||||||
// Peek ahead one token.
|
// Peek ahead one token.
|
||||||
LexerToken Tok;
|
LexerToken Tok;
|
||||||
Lex(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
|
// 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
|
// '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.
|
// 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
|
// If this identifier isn't 'defined' and it wasn't macro expanded, it turns
|
||||||
// into a simple 0.
|
// into a simple 0.
|
||||||
if (strcmp(II->getName(), "defined")) {
|
if (strcmp(II->getName(), "defined")) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ PragmaNamespace::~PragmaNamespace() {
|
||||||
/// specified name. If not, return the handler for the null identifier if it
|
/// specified name. If not, return the handler for the null identifier if it
|
||||||
/// exists, otherwise return null. If IgnoreNull is true (the default) then
|
/// exists, otherwise return null. If IgnoreNull is true (the default) then
|
||||||
/// the null handler isn't returned on failure to match.
|
/// 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 {
|
bool IgnoreNull) const {
|
||||||
PragmaHandler *NullHandler = 0;
|
PragmaHandler *NullHandler = 0;
|
||||||
for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
|
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.
|
// Look up the identifier info for the token.
|
||||||
std::string TokStr = getSpelling(Tok);
|
std::string TokStr = getSpelling(Tok);
|
||||||
IdentifierTokenInfo *II =
|
IdentifierInfo *II =getIdentifierInfo(&TokStr[0], &TokStr[0]+TokStr.size());
|
||||||
getIdentifierInfo(&TokStr[0], &TokStr[0]+TokStr.size());
|
|
||||||
|
|
||||||
// Already poisoned.
|
// Already poisoned.
|
||||||
if (II->isPoisoned()) continue;
|
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 this is specified to be in a namespace, step down into it.
|
||||||
if (Namespace) {
|
if (Namespace) {
|
||||||
IdentifierTokenInfo *NSID = getIdentifierInfo(Namespace);
|
IdentifierInfo *NSID = getIdentifierInfo(Namespace);
|
||||||
|
|
||||||
// If there is already a pragma handler with the name of this 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
|
// 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 {
|
namespace {
|
||||||
struct PragmaOnceHandler : public PragmaHandler {
|
struct PragmaOnceHandler : public PragmaHandler {
|
||||||
PragmaOnceHandler(const IdentifierTokenInfo *OnceID) : PragmaHandler(OnceID){}
|
PragmaOnceHandler(const IdentifierInfo *OnceID) : PragmaHandler(OnceID) {}
|
||||||
virtual void HandlePragma(Preprocessor &PP, LexerToken &OnceTok) {
|
virtual void HandlePragma(Preprocessor &PP, LexerToken &OnceTok) {
|
||||||
PP.CheckEndOfDirective("#pragma once");
|
PP.CheckEndOfDirective("#pragma once");
|
||||||
PP.HandlePragmaOnce(OnceTok);
|
PP.HandlePragmaOnce(OnceTok);
|
||||||
|
@ -326,21 +325,21 @@ struct PragmaOnceHandler : public PragmaHandler {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PragmaPoisonHandler : 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) {
|
virtual void HandlePragma(Preprocessor &PP, LexerToken &PoisonTok) {
|
||||||
PP.HandlePragmaPoison(PoisonTok);
|
PP.HandlePragmaPoison(PoisonTok);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PragmaSystemHeaderHandler : public PragmaHandler {
|
struct PragmaSystemHeaderHandler : public PragmaHandler {
|
||||||
PragmaSystemHeaderHandler(const IdentifierTokenInfo *ID) : PragmaHandler(ID){}
|
PragmaSystemHeaderHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
|
||||||
virtual void HandlePragma(Preprocessor &PP, LexerToken &SHToken) {
|
virtual void HandlePragma(Preprocessor &PP, LexerToken &SHToken) {
|
||||||
PP.HandlePragmaSystemHeader(SHToken);
|
PP.HandlePragmaSystemHeader(SHToken);
|
||||||
PP.CheckEndOfDirective("#pragma");
|
PP.CheckEndOfDirective("#pragma");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct PragmaDependencyHandler : public PragmaHandler {
|
struct PragmaDependencyHandler : public PragmaHandler {
|
||||||
PragmaDependencyHandler(const IdentifierTokenInfo *ID) : PragmaHandler(ID) {}
|
PragmaDependencyHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
|
||||||
virtual void HandlePragma(Preprocessor &PP, LexerToken &DepToken) {
|
virtual void HandlePragma(Preprocessor &PP, LexerToken &DepToken) {
|
||||||
PP.HandlePragmaDependency(DepToken);
|
PP.HandlePragmaDependency(DepToken);
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,7 +421,7 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
|
||||||
/// EnterMacro - Add a Macro to the top of the include stack and start lexing
|
/// EnterMacro - Add a Macro to the top of the include stack and start lexing
|
||||||
/// tokens from it instead of the current buffer.
|
/// tokens from it instead of the current buffer.
|
||||||
void Preprocessor::EnterMacro(LexerToken &Tok) {
|
void Preprocessor::EnterMacro(LexerToken &Tok) {
|
||||||
IdentifierTokenInfo *Identifier = Tok.getIdentifierInfo();
|
IdentifierInfo *Identifier = Tok.getIdentifierInfo();
|
||||||
MacroInfo &MI = *Identifier->getMacroInfo();
|
MacroInfo &MI = *Identifier->getMacroInfo();
|
||||||
IncludeMacroStack.push_back(IncludeStackInfo(CurLexer, CurDirLookup,
|
IncludeMacroStack.push_back(IncludeStackInfo(CurLexer, CurDirLookup,
|
||||||
CurMacroExpander));
|
CurMacroExpander));
|
||||||
|
@ -442,9 +442,9 @@ void Preprocessor::EnterMacro(LexerToken &Tok) {
|
||||||
|
|
||||||
/// RegisterBuiltinMacro - Register the specified identifier in the identifier
|
/// RegisterBuiltinMacro - Register the specified identifier in the identifier
|
||||||
/// table and mark it as a builtin macro to be expanded.
|
/// 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.
|
// Get the identifier.
|
||||||
IdentifierTokenInfo *Id = getIdentifierInfo(Name);
|
IdentifierInfo *Id = getIdentifierInfo(Name);
|
||||||
|
|
||||||
// Mark it as being a macro that is builtin.
|
// Mark it as being a macro that is builtin.
|
||||||
MacroInfo *MI = new MacroInfo(SourceLocation());
|
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'.
|
/// as a builtin macro, handle it and return the next token as 'Tok'.
|
||||||
void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) {
|
void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) {
|
||||||
// Figure out which token this is.
|
// Figure out which token this is.
|
||||||
IdentifierTokenInfo *ITI = Tok.getIdentifierInfo();
|
IdentifierInfo *II = Tok.getIdentifierInfo();
|
||||||
assert(ITI && "Can't be a macro without id info!");
|
assert(II && "Can't be a macro without id info!");
|
||||||
|
|
||||||
// If this is an _Pragma directive, expand it, invoke the pragma handler, then
|
// If this is an _Pragma directive, expand it, invoke the pragma handler, then
|
||||||
// lex the token after it.
|
// lex the token after it.
|
||||||
if (ITI == Ident_Pragma)
|
if (II == Ident_Pragma)
|
||||||
return Handle_Pragma(Tok);
|
return Handle_Pragma(Tok);
|
||||||
|
|
||||||
char TmpBuffer[100];
|
char TmpBuffer[100];
|
||||||
|
@ -592,16 +592,16 @@ void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) {
|
||||||
Tok.SetIdentifierInfo(0);
|
Tok.SetIdentifierInfo(0);
|
||||||
Tok.ClearFlag(LexerToken::NeedsCleaning);
|
Tok.ClearFlag(LexerToken::NeedsCleaning);
|
||||||
|
|
||||||
if (ITI == Ident__LINE__) {
|
if (II == Ident__LINE__) {
|
||||||
// __LINE__ expands to a simple numeric value.
|
// __LINE__ expands to a simple numeric value.
|
||||||
sprintf(TmpBuffer, "%u", SourceMgr.getLineNumber(Tok.getLocation()));
|
sprintf(TmpBuffer, "%u", SourceMgr.getLineNumber(Tok.getLocation()));
|
||||||
unsigned Length = strlen(TmpBuffer);
|
unsigned Length = strlen(TmpBuffer);
|
||||||
Tok.SetKind(tok::numeric_constant);
|
Tok.SetKind(tok::numeric_constant);
|
||||||
Tok.SetLength(Length);
|
Tok.SetLength(Length);
|
||||||
Tok.SetLocation(ScratchBuf->getToken(TmpBuffer, Length, Tok.getLocation()));
|
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();
|
SourceLocation Loc = Tok.getLocation();
|
||||||
if (ITI == Ident__BASE_FILE__) {
|
if (II == Ident__BASE_FILE__) {
|
||||||
Diag(Tok, diag::ext_pp_base_file);
|
Diag(Tok, diag::ext_pp_base_file);
|
||||||
SourceLocation NextLoc = SourceMgr.getIncludeLoc(Loc.getFileID());
|
SourceLocation NextLoc = SourceMgr.getIncludeLoc(Loc.getFileID());
|
||||||
while (NextLoc.getFileID() != 0) {
|
while (NextLoc.getFileID() != 0) {
|
||||||
|
@ -616,19 +616,19 @@ void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) {
|
||||||
Tok.SetKind(tok::string_literal);
|
Tok.SetKind(tok::string_literal);
|
||||||
Tok.SetLength(FN.size());
|
Tok.SetLength(FN.size());
|
||||||
Tok.SetLocation(ScratchBuf->getToken(&FN[0], FN.size(), Tok.getLocation()));
|
Tok.SetLocation(ScratchBuf->getToken(&FN[0], FN.size(), Tok.getLocation()));
|
||||||
} else if (ITI == Ident__DATE__) {
|
} else if (II == Ident__DATE__) {
|
||||||
if (!DATELoc.isValid())
|
if (!DATELoc.isValid())
|
||||||
ComputeDATE_TIME(DATELoc, TIMELoc, ScratchBuf);
|
ComputeDATE_TIME(DATELoc, TIMELoc, ScratchBuf);
|
||||||
Tok.SetKind(tok::string_literal);
|
Tok.SetKind(tok::string_literal);
|
||||||
Tok.SetLength(strlen("\"Mmm dd yyyy\""));
|
Tok.SetLength(strlen("\"Mmm dd yyyy\""));
|
||||||
Tok.SetLocation(SourceMgr.getInstantiationLoc(DATELoc, Tok.getLocation()));
|
Tok.SetLocation(SourceMgr.getInstantiationLoc(DATELoc, Tok.getLocation()));
|
||||||
} else if (ITI == Ident__TIME__) {
|
} else if (II == Ident__TIME__) {
|
||||||
if (!TIMELoc.isValid())
|
if (!TIMELoc.isValid())
|
||||||
ComputeDATE_TIME(DATELoc, TIMELoc, ScratchBuf);
|
ComputeDATE_TIME(DATELoc, TIMELoc, ScratchBuf);
|
||||||
Tok.SetKind(tok::string_literal);
|
Tok.SetKind(tok::string_literal);
|
||||||
Tok.SetLength(strlen("\"hh:mm:ss\""));
|
Tok.SetLength(strlen("\"hh:mm:ss\""));
|
||||||
Tok.SetLocation(SourceMgr.getInstantiationLoc(TIMELoc, Tok.getLocation()));
|
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);
|
Diag(Tok, diag::ext_pp_include_level);
|
||||||
|
|
||||||
// Compute the include depth of this token.
|
// Compute the include depth of this token.
|
||||||
|
@ -643,7 +643,7 @@ void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) {
|
||||||
Tok.SetKind(tok::numeric_constant);
|
Tok.SetKind(tok::numeric_constant);
|
||||||
Tok.SetLength(Length);
|
Tok.SetLength(Length);
|
||||||
Tok.SetLocation(ScratchBuf->getToken(TmpBuffer, Length, Tok.getLocation()));
|
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
|
// 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.
|
// of the form "Ddd Mmm dd hh::mm::ss yyyy", which is returned by asctime.
|
||||||
Diag(Tok, diag::ext_pp_timestamp);
|
Diag(Tok, diag::ext_pp_timestamp);
|
||||||
|
@ -682,9 +682,9 @@ struct UnusedIdentifierReporter : public IdentifierVisitor {
|
||||||
Preprocessor &PP;
|
Preprocessor &PP;
|
||||||
UnusedIdentifierReporter(Preprocessor &pp) : PP(pp) {}
|
UnusedIdentifierReporter(Preprocessor &pp) : PP(pp) {}
|
||||||
|
|
||||||
void VisitIdentifier(IdentifierTokenInfo &ITI) const {
|
void VisitIdentifier(IdentifierInfo &II) const {
|
||||||
if (ITI.getMacroInfo() && !ITI.getMacroInfo()->isUsed())
|
if (II.getMacroInfo() && !II.getMacroInfo()->isUsed())
|
||||||
PP.Diag(ITI.getMacroInfo()->getDefinitionLoc(), diag::pp_macro_not_used);
|
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?");
|
assert(isSkipping() && "Token isn't an identifier?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IdentifierTokenInfo &ITI = *Identifier.getIdentifierInfo();
|
IdentifierInfo &II = *Identifier.getIdentifierInfo();
|
||||||
|
|
||||||
// If this identifier was poisoned, and if it was not produced from a macro
|
// If this identifier was poisoned, and if it was not produced from a macro
|
||||||
// expansion, emit an error.
|
// expansion, emit an error.
|
||||||
if (ITI.isPoisoned() && CurLexer)
|
if (II.isPoisoned() && CurLexer)
|
||||||
Diag(Identifier, diag::err_pp_used_poisoned_id);
|
Diag(Identifier, diag::err_pp_used_poisoned_id);
|
||||||
|
|
||||||
if (MacroInfo *MI = ITI.getMacroInfo())
|
if (MacroInfo *MI = II.getMacroInfo())
|
||||||
if (MI->isEnabled() && !DisableMacroExpansion)
|
if (MI->isEnabled() && !DisableMacroExpansion)
|
||||||
return HandleMacroExpandedIdentifier(Identifier, MI);
|
return HandleMacroExpandedIdentifier(Identifier, MI);
|
||||||
|
|
||||||
// Change the kind of this identifier to the appropriate token kind, e.g.
|
// Change the kind of this identifier to the appropriate token kind, e.g.
|
||||||
// turning "for" into a keyword.
|
// turning "for" into a keyword.
|
||||||
Identifier.SetKind(ITI.getTokenID());
|
Identifier.SetKind(II.getTokenID());
|
||||||
|
|
||||||
// If this is an extension token, diagnose its use.
|
// 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
|
/// 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.
|
// See if this file had a controlling macro.
|
||||||
if (CurLexer) { // Not ending a macro, ignore it.
|
if (CurLexer) { // Not ending a macro, ignore it.
|
||||||
if (const IdentifierTokenInfo *ControllingMacro =
|
if (const IdentifierInfo *ControllingMacro =
|
||||||
CurLexer->MIOpt.GetControllingMacroAtEndOfFile()) {
|
CurLexer->MIOpt.GetControllingMacroAtEndOfFile()) {
|
||||||
// Okay, this has a controlling macro, remember in PerFileInfo.
|
// Okay, this has a controlling macro, remember in PerFileInfo.
|
||||||
if (const FileEntry *FE =
|
if (const FileEntry *FE =
|
||||||
|
@ -788,7 +788,7 @@ void Preprocessor::HandleEndOfFile(LexerToken &Result, bool isEndOfMacro) {
|
||||||
CurLexer = 0;
|
CurLexer = 0;
|
||||||
|
|
||||||
// This is the end of the top-level file.
|
// 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
|
/// 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)
|
if (MacroNameTok.getKind() == tok::eom)
|
||||||
return Diag(MacroNameTok, diag::err_pp_missing_macro_name);
|
return Diag(MacroNameTok, diag::err_pp_missing_macro_name);
|
||||||
|
|
||||||
IdentifierTokenInfo *ITI = MacroNameTok.getIdentifierInfo();
|
IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
|
||||||
if (ITI == 0) {
|
if (II == 0) {
|
||||||
Diag(MacroNameTok, diag::err_pp_macro_not_identifier);
|
Diag(MacroNameTok, diag::err_pp_macro_not_identifier);
|
||||||
// Fall through on error.
|
// Fall through on error.
|
||||||
} else if (0) {
|
} else if (0) {
|
||||||
// FIXME: C++. Error if defining a C++ named operator.
|
// FIXME: C++. Error if defining a C++ named operator.
|
||||||
|
|
||||||
} else if (isDefineUndef && ITI->getName()[0] == 'd' && // defined
|
} else if (isDefineUndef && II->getName()[0] == 'd' && // defined
|
||||||
!strcmp(ITI->getName()+1, "efined")) {
|
!strcmp(II->getName()+1, "efined")) {
|
||||||
// Error if defining "defined": C99 6.10.8.4.
|
// Error if defining "defined": C99 6.10.8.4.
|
||||||
Diag(MacroNameTok, diag::err_defined_macro_name);
|
Diag(MacroNameTok, diag::err_defined_macro_name);
|
||||||
} else if (isDefineUndef && ITI->getMacroInfo() &&
|
} else if (isDefineUndef && II->getMacroInfo() &&
|
||||||
ITI->getMacroInfo()->isBuiltinMacro()) {
|
II->getMacroInfo()->isBuiltinMacro()) {
|
||||||
// Error if defining "__LINE__" and other builtins: C99 6.10.8.4.
|
// Error if defining "__LINE__" and other builtins: C99 6.10.8.4.
|
||||||
Diag(MacroNameTok, diag::pp_undef_builtin_macro);
|
Diag(MacroNameTok, diag::pp_undef_builtin_macro);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1020,7 +1020,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
|
||||||
// looked up, etc, inside the #elif expression.
|
// looked up, etc, inside the #elif expression.
|
||||||
assert(SkippingContents && "We have to be skipping here!");
|
assert(SkippingContents && "We have to be skipping here!");
|
||||||
SkippingContents = false;
|
SkippingContents = false;
|
||||||
IdentifierTokenInfo *IfNDefMacro = 0;
|
IdentifierInfo *IfNDefMacro = 0;
|
||||||
ShouldEnter = EvaluateDirectiveExpression(IfNDefMacro);
|
ShouldEnter = EvaluateDirectiveExpression(IfNDefMacro);
|
||||||
SkippingContents = true;
|
SkippingContents = true;
|
||||||
}
|
}
|
||||||
|
@ -1455,7 +1455,7 @@ void Preprocessor::HandleIfDirective(LexerToken &IfToken,
|
||||||
++NumIf;
|
++NumIf;
|
||||||
|
|
||||||
// Parse and evaluation the conditional expression.
|
// Parse and evaluation the conditional expression.
|
||||||
IdentifierTokenInfo *IfNDefMacro = 0;
|
IdentifierInfo *IfNDefMacro = 0;
|
||||||
bool ConditionalTrue = EvaluateDirectiveExpression(IfNDefMacro);
|
bool ConditionalTrue = EvaluateDirectiveExpression(IfNDefMacro);
|
||||||
|
|
||||||
// Should we include the stuff contained by this directive?
|
// Should we include the stuff contained by this directive?
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// This file defines the IdentifierTokenInfo, IdentifierVisitor, and
|
// This file defines the IdentifierInfo, IdentifierVisitor, and
|
||||||
// IdentifierTable interfaces.
|
// IdentifierTable interfaces.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -23,12 +23,12 @@ namespace clang {
|
||||||
class IdentifierTable;
|
class IdentifierTable;
|
||||||
class MacroInfo;
|
class MacroInfo;
|
||||||
|
|
||||||
/// IdentifierTokenInfo - One of these records is kept for each identifier that
|
/// IdentifierInfo - One of these records is kept for each identifier that
|
||||||
/// is lexed. This contains information about whether the token was #define'd,
|
/// is lexed. This contains information about whether the token was #define'd,
|
||||||
/// is a language keyword, or if it is a front-end token of some sort (e.g. a
|
/// is a language keyword, or if it is a front-end token of some sort (e.g. a
|
||||||
/// variable or function name). The preprocessor keeps this information in a
|
/// variable or function name). The preprocessor keeps this information in a
|
||||||
/// set, and all tok::identifier tokens have a pointer to one of these.
|
/// set, and all tok::identifier tokens have a pointer to one of these.
|
||||||
class IdentifierTokenInfo {
|
class IdentifierInfo {
|
||||||
unsigned NameLen; // String that is the identifier.
|
unsigned NameLen; // String that is the identifier.
|
||||||
MacroInfo *Macro; // Set if this identifier is #define'd.
|
MacroInfo *Macro; // Set if this identifier is #define'd.
|
||||||
tok::TokenKind TokenID:8; // Front-end token ID or tok::identifier.
|
tok::TokenKind TokenID:8; // Front-end token ID or tok::identifier.
|
||||||
|
@ -42,7 +42,7 @@ public:
|
||||||
/// terminated.
|
/// terminated.
|
||||||
///
|
///
|
||||||
const char *getName() const {
|
const char *getName() const {
|
||||||
// String data is stored immediately after the IdentifierTokenInfo object.
|
// String data is stored immediately after the IdentifierInfo object.
|
||||||
return (const char*)(this+1);
|
return (const char*)(this+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,11 +90,11 @@ private:
|
||||||
class IdentifierVisitor {
|
class IdentifierVisitor {
|
||||||
public:
|
public:
|
||||||
virtual ~IdentifierVisitor();
|
virtual ~IdentifierVisitor();
|
||||||
virtual void VisitIdentifier(IdentifierTokenInfo &ITI) const = 0;
|
virtual void VisitIdentifier(IdentifierInfo &II) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// IdentifierTable - This table implements an efficient mapping from strings to
|
/// IdentifierTable - This table implements an efficient mapping from strings to
|
||||||
/// IdentifierTokenInfo nodes. It has no other purpose, but this is an
|
/// IdentifierInfo nodes. It has no other purpose, but this is an
|
||||||
/// extremely performance-critical piece of the code, as each occurrance of
|
/// extremely performance-critical piece of the code, as each occurrance of
|
||||||
/// every identifier goes through here when lexed.
|
/// every identifier goes through here when lexed.
|
||||||
class IdentifierTable {
|
class IdentifierTable {
|
||||||
|
@ -107,8 +107,8 @@ public:
|
||||||
|
|
||||||
/// get - Return the identifier token info for the specified named identifier.
|
/// get - Return the identifier token info for the specified named identifier.
|
||||||
///
|
///
|
||||||
IdentifierTokenInfo &get(const char *NameStart, const char *NameEnd);
|
IdentifierInfo &get(const char *NameStart, const char *NameEnd);
|
||||||
IdentifierTokenInfo &get(const std::string &Name);
|
IdentifierInfo &get(const std::string &Name);
|
||||||
|
|
||||||
/// VisitIdentifiers - This method walks through all of the identifiers,
|
/// VisitIdentifiers - This method walks through all of the identifiers,
|
||||||
/// invoking IV->VisitIdentifier for each of them.
|
/// invoking IV->VisitIdentifier for each of them.
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
class IdentifierTokenInfo;
|
class IdentifierInfo;
|
||||||
|
|
||||||
/// LexerToken - This structure provides full information about a lexed token.
|
/// LexerToken - This structure provides full information about a lexed token.
|
||||||
/// it is not intended to be space efficient, it is intended to return as much
|
/// it is not intended to be space efficient, it is intended to return as much
|
||||||
|
@ -33,7 +33,7 @@ class LexerToken {
|
||||||
|
|
||||||
/// IdentifierInfo - If this was an identifier, this points to the uniqued
|
/// IdentifierInfo - If this was an identifier, this points to the uniqued
|
||||||
/// information about this identifier.
|
/// information about this identifier.
|
||||||
IdentifierTokenInfo *IdentifierInfo;
|
IdentifierInfo *IdentInfo;
|
||||||
|
|
||||||
/// Kind - The actual flavor of token this is.
|
/// Kind - The actual flavor of token this is.
|
||||||
///
|
///
|
||||||
|
@ -67,13 +67,13 @@ public:
|
||||||
///
|
///
|
||||||
void StartToken() {
|
void StartToken() {
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
IdentifierInfo = 0;
|
IdentInfo = 0;
|
||||||
Loc = SourceLocation();
|
Loc = SourceLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifierTokenInfo *getIdentifierInfo() const { return IdentifierInfo; }
|
IdentifierInfo *getIdentifierInfo() const { return IdentInfo; }
|
||||||
void SetIdentifierInfo(IdentifierTokenInfo *II) {
|
void SetIdentifierInfo(IdentifierInfo *II) {
|
||||||
IdentifierInfo = II;
|
IdentInfo = II;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SetFlag - Set the specified flag.
|
/// SetFlag - Set the specified flag.
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class IdentifierTokenInfo;
|
class IdentifierInfo;
|
||||||
|
|
||||||
/// MultipleIncludeOpt - This class implements the simple state machine that the
|
/// MultipleIncludeOpt - This class implements the simple state machine that the
|
||||||
/// Lexer class uses to detect files subject to the 'multiple-include'
|
/// Lexer class uses to detect files subject to the 'multiple-include'
|
||||||
|
@ -33,7 +33,7 @@ class MultipleIncludeOpt {
|
||||||
|
|
||||||
/// TheMacro - The controlling macro for a file, if valid.
|
/// TheMacro - The controlling macro for a file, if valid.
|
||||||
///
|
///
|
||||||
const IdentifierTokenInfo *TheMacro;
|
const IdentifierInfo *TheMacro;
|
||||||
public:
|
public:
|
||||||
MultipleIncludeOpt() : ReadAnyTokens(false), TheMacro(0) {}
|
MultipleIncludeOpt() : ReadAnyTokens(false), TheMacro(0) {}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
/// EnterTopLevelIFNDEF - When entering a top-level #ifndef directive (or the
|
/// EnterTopLevelIFNDEF - When entering a top-level #ifndef directive (or the
|
||||||
/// "#if !defined" equivalent) without any preceding tokens, this method is
|
/// "#if !defined" equivalent) without any preceding tokens, this method is
|
||||||
/// called.
|
/// called.
|
||||||
void EnterTopLevelIFNDEF(const IdentifierTokenInfo *M) {
|
void EnterTopLevelIFNDEF(const IdentifierInfo *M) {
|
||||||
// Note, we don't care about the input value of 'ReadAnyTokens'. The caller
|
// Note, we don't care about the input value of 'ReadAnyTokens'. The caller
|
||||||
// ensures that this is only called if there are no tokens read before the
|
// ensures that this is only called if there are no tokens read before the
|
||||||
// #ifndef.
|
// #ifndef.
|
||||||
|
@ -94,7 +94,7 @@ public:
|
||||||
|
|
||||||
/// GetControllingMacroAtEndOfFile - Once the entire file has been lexed, if
|
/// GetControllingMacroAtEndOfFile - Once the entire file has been lexed, if
|
||||||
/// there is a controlling macro, return it.
|
/// there is a controlling macro, return it.
|
||||||
const IdentifierTokenInfo *GetControllingMacroAtEndOfFile() const {
|
const IdentifierInfo *GetControllingMacroAtEndOfFile() const {
|
||||||
// If we haven't read any tokens after the #endif, return the controlling
|
// If we haven't read any tokens after the #endif, return the controlling
|
||||||
// macro if it's valid (if it isn't, it will be null).
|
// macro if it's valid (if it isn't, it will be null).
|
||||||
if (!ReadAnyTokens)
|
if (!ReadAnyTokens)
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace llvm {
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class Preprocessor;
|
class Preprocessor;
|
||||||
class LexerToken;
|
class LexerToken;
|
||||||
class IdentifierTokenInfo;
|
class IdentifierInfo;
|
||||||
class PragmaNamespace;
|
class PragmaNamespace;
|
||||||
|
|
||||||
/// PragmaHandler - Instances of this interface defined to handle the various
|
/// PragmaHandler - Instances of this interface defined to handle the various
|
||||||
|
@ -34,12 +34,12 @@ namespace clang {
|
||||||
/// we treat "#pragma STDC" and "#pragma GCC" as namespaces that contain other
|
/// we treat "#pragma STDC" and "#pragma GCC" as namespaces that contain other
|
||||||
/// pragmas.
|
/// pragmas.
|
||||||
class PragmaHandler {
|
class PragmaHandler {
|
||||||
const IdentifierTokenInfo *Name;
|
const IdentifierInfo *Name;
|
||||||
public:
|
public:
|
||||||
PragmaHandler(const IdentifierTokenInfo *name) : Name(name) {}
|
PragmaHandler(const IdentifierInfo *name) : Name(name) {}
|
||||||
virtual ~PragmaHandler();
|
virtual ~PragmaHandler();
|
||||||
|
|
||||||
const IdentifierTokenInfo *getName() const { return Name; }
|
const IdentifierInfo *getName() const { return Name; }
|
||||||
virtual void HandlePragma(Preprocessor &PP, LexerToken &FirstToken) = 0;
|
virtual void HandlePragma(Preprocessor &PP, LexerToken &FirstToken) = 0;
|
||||||
|
|
||||||
/// getIfNamespace - If this is a namespace, return it. This is equivalent to
|
/// getIfNamespace - If this is a namespace, return it. This is equivalent to
|
||||||
|
@ -56,14 +56,14 @@ class PragmaNamespace : public PragmaHandler {
|
||||||
///
|
///
|
||||||
std::vector<PragmaHandler*> Handlers;
|
std::vector<PragmaHandler*> Handlers;
|
||||||
public:
|
public:
|
||||||
PragmaNamespace(const IdentifierTokenInfo *Name) : PragmaHandler(Name) {}
|
PragmaNamespace(const IdentifierInfo *Name) : PragmaHandler(Name) {}
|
||||||
virtual ~PragmaNamespace();
|
virtual ~PragmaNamespace();
|
||||||
|
|
||||||
/// FindHandler - Check to see if there is already a handler for the
|
/// FindHandler - Check to see if there is already a handler for the
|
||||||
/// specified name. If not, return the handler for the null identifier if it
|
/// specified name. If not, return the handler for the null identifier if it
|
||||||
/// exists, otherwise return null. If IgnoreNull is true (the default) then
|
/// exists, otherwise return null. If IgnoreNull is true (the default) then
|
||||||
/// the null handler isn't returned on failure to match.
|
/// the null handler isn't returned on failure to match.
|
||||||
PragmaHandler *FindHandler(const IdentifierTokenInfo *Name,
|
PragmaHandler *FindHandler(const IdentifierInfo *Name,
|
||||||
bool IgnoreNull = true) const;
|
bool IgnoreNull = true) const;
|
||||||
|
|
||||||
/// AddPragma - Add a pragma to this namespace.
|
/// AddPragma - Add a pragma to this namespace.
|
||||||
|
|
|
@ -93,12 +93,12 @@ class Preprocessor {
|
||||||
bool NoCurDirSearch;
|
bool NoCurDirSearch;
|
||||||
|
|
||||||
/// Identifiers for builtin macros.
|
/// Identifiers for builtin macros.
|
||||||
IdentifierTokenInfo *Ident__LINE__, *Ident__FILE__; // __LINE__, __FILE__
|
IdentifierInfo *Ident__LINE__, *Ident__FILE__; // __LINE__, __FILE__
|
||||||
IdentifierTokenInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__
|
IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__
|
||||||
IdentifierTokenInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__
|
IdentifierInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__
|
||||||
IdentifierTokenInfo *Ident__BASE_FILE__; // __BASE_FILE__
|
IdentifierInfo *Ident__BASE_FILE__; // __BASE_FILE__
|
||||||
IdentifierTokenInfo *Ident__TIMESTAMP__; // __TIMESTAMP__
|
IdentifierInfo *Ident__TIMESTAMP__; // __TIMESTAMP__
|
||||||
IdentifierTokenInfo *Ident_Pragma; // _Pragma
|
IdentifierInfo *Ident_Pragma; // _Pragma
|
||||||
|
|
||||||
SourceLocation DATELoc, TIMELoc;
|
SourceLocation DATELoc, TIMELoc;
|
||||||
public:
|
public:
|
||||||
|
@ -131,9 +131,9 @@ private:
|
||||||
bool DisableMacroExpansion; // True if macro expansion is disabled.
|
bool DisableMacroExpansion; // True if macro expansion is disabled.
|
||||||
bool SkippingContents; // True if in a #if 0 block.
|
bool SkippingContents; // True if in a #if 0 block.
|
||||||
|
|
||||||
/// IdentifierInfo - This is mapping/lookup information for all identifiers in
|
/// Identifiers - This is mapping/lookup information for all identifiers in
|
||||||
/// the program, including program keywords.
|
/// the program, including program keywords.
|
||||||
IdentifierTable IdentifierInfo;
|
IdentifierTable Identifiers;
|
||||||
|
|
||||||
/// PragmaHandlers - This tracks all of the pragmas that the client registered
|
/// PragmaHandlers - This tracks all of the pragmas that the client registered
|
||||||
/// with this preprocessor.
|
/// with this preprocessor.
|
||||||
|
@ -184,7 +184,7 @@ private:
|
||||||
/// ControllingMacro - If this file has a #ifndef XXX (or equivalent) guard
|
/// ControllingMacro - If this file has a #ifndef XXX (or equivalent) guard
|
||||||
/// that protects the entire contents of the file, this is the identifier
|
/// that protects the entire contents of the file, this is the identifier
|
||||||
/// for the macro that controls whether or not it has any effect.
|
/// for the macro that controls whether or not it has any effect.
|
||||||
const IdentifierTokenInfo *ControllingMacro;
|
const IdentifierInfo *ControllingMacro;
|
||||||
|
|
||||||
PerFileInfo() : isImport(false), DirInfo(DirectoryLookup::NormalHeaderDir),
|
PerFileInfo() : isImport(false), DirInfo(DirectoryLookup::NormalHeaderDir),
|
||||||
NumIncludes(0), ControllingMacro(0) {}
|
NumIncludes(0), ControllingMacro(0) {}
|
||||||
|
@ -211,7 +211,7 @@ public:
|
||||||
FileManager &getFileManager() const { return FileMgr; }
|
FileManager &getFileManager() const { return FileMgr; }
|
||||||
SourceManager &getSourceManager() const { return SourceMgr; }
|
SourceManager &getSourceManager() const { return SourceMgr; }
|
||||||
|
|
||||||
IdentifierTable &getIdentifierTable() { return IdentifierInfo; }
|
IdentifierTable &getIdentifierTable() { return Identifiers; }
|
||||||
|
|
||||||
/// isSkipping - Return true if we're lexing a '#if 0' block. This causes
|
/// isSkipping - Return true if we're lexing a '#if 0' block. This causes
|
||||||
/// lexer errors/warnings to get ignored.
|
/// lexer errors/warnings to get ignored.
|
||||||
|
@ -262,13 +262,13 @@ public:
|
||||||
/// pointers is preferred unless the identifier is already available as a
|
/// pointers is preferred unless the identifier is already available as a
|
||||||
/// string (this avoids allocation and copying of memory to construct an
|
/// string (this avoids allocation and copying of memory to construct an
|
||||||
/// std::string).
|
/// std::string).
|
||||||
IdentifierTokenInfo *getIdentifierInfo(const char *NameStart,
|
IdentifierInfo *getIdentifierInfo(const char *NameStart,
|
||||||
const char *NameEnd) {
|
const char *NameEnd) {
|
||||||
// If we are in a "#if 0" block, don't bother lookup up identifiers.
|
// If we are in a "#if 0" block, don't bother lookup up identifiers.
|
||||||
if (SkippingContents) return 0;
|
if (SkippingContents) return 0;
|
||||||
return &IdentifierInfo.get(NameStart, NameEnd);
|
return &Identifiers.get(NameStart, NameEnd);
|
||||||
}
|
}
|
||||||
IdentifierTokenInfo *getIdentifierInfo(const char *NameStr) {
|
IdentifierInfo *getIdentifierInfo(const char *NameStr) {
|
||||||
return getIdentifierInfo(NameStr, NameStr+strlen(NameStr));
|
return getIdentifierInfo(NameStr, NameStr+strlen(NameStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ public:
|
||||||
if (Flags+Features.NoExtensions >= 2) return;
|
if (Flags+Features.NoExtensions >= 2) return;
|
||||||
|
|
||||||
const char *Str = &Keyword[0];
|
const char *Str = &Keyword[0];
|
||||||
IdentifierTokenInfo &Info = *getIdentifierInfo(Str, Str+Keyword.size());
|
IdentifierInfo &Info = *getIdentifierInfo(Str, Str+Keyword.size());
|
||||||
Info.setTokenID(TokenCode);
|
Info.setTokenID(TokenCode);
|
||||||
Info.setIsExtensionToken(Flags == 1);
|
Info.setIsExtensionToken(Flags == 1);
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ private:
|
||||||
/// EvaluateDirectiveExpression - Evaluate an integer constant expression that
|
/// EvaluateDirectiveExpression - Evaluate an integer constant expression that
|
||||||
/// may occur after a #if or #elif directive and return it as a bool. If the
|
/// may occur after a #if or #elif directive and return it as a bool. If the
|
||||||
/// expression is equivalent to "!defined(X)" return X in IfNDefMacro.
|
/// expression is equivalent to "!defined(X)" return X in IfNDefMacro.
|
||||||
bool EvaluateDirectiveExpression(IdentifierTokenInfo *&IfNDefMacro);
|
bool EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro);
|
||||||
/// EvaluateValue/EvaluateDirectiveSubExpr - Used to implement
|
/// EvaluateValue/EvaluateDirectiveSubExpr - Used to implement
|
||||||
/// EvaluateDirectiveExpression, see PPExpressions.cpp.
|
/// EvaluateDirectiveExpression, see PPExpressions.cpp.
|
||||||
bool EvaluateValue(int &Result, LexerToken &PeekTok);
|
bool EvaluateValue(int &Result, LexerToken &PeekTok);
|
||||||
|
@ -445,7 +445,7 @@ private:
|
||||||
/// RegisterBuiltinMacros - Register builtin macros, such as __LINE__ with the
|
/// RegisterBuiltinMacros - Register builtin macros, such as __LINE__ with the
|
||||||
/// identifier table.
|
/// identifier table.
|
||||||
void RegisterBuiltinMacros();
|
void RegisterBuiltinMacros();
|
||||||
IdentifierTokenInfo *RegisterBuiltinMacro(const char *Name);
|
IdentifierInfo *RegisterBuiltinMacro(const char *Name);
|
||||||
|
|
||||||
/// HandleMacroExpandedIdentifier - If an identifier token is read that is to
|
/// HandleMacroExpandedIdentifier - If an identifier token is read that is to
|
||||||
/// be expanded as a macro, handle it and return the next token as 'Tok'.
|
/// be expanded as a macro, handle it and return the next token as 'Tok'.
|
||||||
|
|
Loading…
Reference in New Issue