Rename create(MacroArg)InstantiationLoc to create(MacroArg)ExpansionLoc.

llvm-svn: 136054
This commit is contained in:
Chandler Carruth 2011-07-26 03:03:05 +00:00
parent aa63153ff7
commit 115b077f30
7 changed files with 75 additions and 75 deletions

View File

@ -583,23 +583,23 @@ public:
SrcMgr::C_User, LoadedID, LoadedOffset);
}
/// createMacroArgInstantiationLoc - Return a new SourceLocation that encodes
/// the fact that a token from SpellingLoc should actually be referenced from
/// InstantiationLoc, and that it represents the instantiation of a macro
/// createMacroArgExpansionLoc - Return a new SourceLocation that encodes the
/// fact that a token from SpellingLoc should actually be referenced from
/// ExpansionLoc, and that it represents the instantiation of a macro
/// argument into the function-like macro body.
SourceLocation createMacroArgInstantiationLoc(SourceLocation Loc,
SourceLocation InstantiationLoc,
unsigned TokLength);
SourceLocation createMacroArgExpansionLoc(SourceLocation Loc,
SourceLocation ExpansionLoc,
unsigned TokLength);
/// createInstantiationLoc - Return a new SourceLocation that encodes the fact
/// createExpansionLoc - Return a new SourceLocation that encodes the fact
/// that a token from SpellingLoc should actually be referenced from
/// InstantiationLoc.
SourceLocation createInstantiationLoc(SourceLocation Loc,
SourceLocation InstantiationLocStart,
SourceLocation InstantiationLocEnd,
unsigned TokLength,
int LoadedID = 0,
unsigned LoadedOffset = 0);
/// ExpansionLoc.
SourceLocation createExpansionLoc(SourceLocation Loc,
SourceLocation ExpansionLocStart,
SourceLocation ExpansionLocEnd,
unsigned TokLength,
int LoadedID = 0,
unsigned LoadedOffset = 0);
/// \brief Retrieve the memory buffer associated with the given file.
///
@ -1080,13 +1080,13 @@ private:
return getLoadedSLocEntry(static_cast<unsigned>(-ID - 2));
}
/// createInstantiationLoc - Implements the common elements of storing an
/// createExpansionLoc - Implements the common elements of storing an
/// instantiation info struct into the SLocEntry table and producing a source
/// location that refers to it.
SourceLocation createInstantiationLocImpl(const SrcMgr::InstantiationInfo &II,
unsigned TokLength,
int LoadedID = 0,
unsigned LoadedOffset = 0);
SourceLocation createExpansionLocImpl(const SrcMgr::InstantiationInfo &II,
unsigned TokLength,
int LoadedID = 0,
unsigned LoadedOffset = 0);
/// isOffsetInFileID - Return true if the specified FileID contains the
/// specified SourceLocation offset. This is a very hot method.

View File

@ -406,7 +406,7 @@ void SourceManager::clearIDTables() {
// The highest possible offset is 2^31-1, so CurrentLoadedOffset starts at
// 2^31.
CurrentLoadedOffset = 1U << 31U;
createInstantiationLoc(SourceLocation(),SourceLocation(),SourceLocation(), 1);
createExpansionLoc(SourceLocation(),SourceLocation(),SourceLocation(), 1);
}
/// getOrCreateContentCache - Create or return a cached ContentCache for the
@ -518,30 +518,32 @@ FileID SourceManager::createFileID(const ContentCache *File,
}
SourceLocation
SourceManager::createMacroArgInstantiationLoc(SourceLocation SpellingLoc,
SourceLocation ILoc,
unsigned TokLength) {
SourceManager::createMacroArgExpansionLoc(SourceLocation SpellingLoc,
SourceLocation ExpansionLoc,
unsigned TokLength) {
InstantiationInfo II =
InstantiationInfo::createForMacroArg(SpellingLoc, ILoc);
return createInstantiationLocImpl(II, TokLength);
}
SourceLocation SourceManager::createInstantiationLoc(SourceLocation SpellingLoc,
SourceLocation ILocStart,
SourceLocation ILocEnd,
unsigned TokLength,
int LoadedID,
unsigned LoadedOffset) {
InstantiationInfo II =
InstantiationInfo::create(SpellingLoc, ILocStart, ILocEnd);
return createInstantiationLocImpl(II, TokLength, LoadedID, LoadedOffset);
InstantiationInfo::createForMacroArg(SpellingLoc, ExpansionLoc);
return createExpansionLocImpl(II, TokLength);
}
SourceLocation
SourceManager::createInstantiationLocImpl(const InstantiationInfo &II,
unsigned TokLength,
int LoadedID,
unsigned LoadedOffset) {
SourceManager::createExpansionLoc(SourceLocation SpellingLoc,
SourceLocation ExpansionLocStart,
SourceLocation ExpansionLocEnd,
unsigned TokLength,
int LoadedID,
unsigned LoadedOffset) {
InstantiationInfo II =
InstantiationInfo::create(SpellingLoc, ExpansionLocStart,
ExpansionLocEnd);
return createExpansionLocImpl(II, TokLength, LoadedID, LoadedOffset);
}
SourceLocation
SourceManager::createExpansionLocImpl(const InstantiationInfo &II,
unsigned TokLength,
int LoadedID,
unsigned LoadedOffset) {
if (LoadedID < 0) {
assert(LoadedID != -1 && "Loading sentinel FileID");
unsigned Index = unsigned(-LoadedID) - 2;

View File

@ -187,9 +187,9 @@ Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc,
// Set the SourceLocation with the remapping information. This ensures that
// GetMappedTokenLoc will remap the tokens as they are lexed.
L->FileLoc = SM.createInstantiationLoc(SM.getLocForStartOfFile(SpellingFID),
ExpansionLocStart,
ExpansionLocEnd, TokLen);
L->FileLoc = SM.createExpansionLoc(SM.getLocForStartOfFile(SpellingFID),
ExpansionLocStart,
ExpansionLocEnd, TokLen);
// Ensure that the lexer thinks it is inside a directive, so that end \n will
// return an EOD token.
@ -914,7 +914,7 @@ static SourceLocation GetMappedTokenLoc(Preprocessor &PP,
std::pair<SourceLocation,SourceLocation> II =
SM.getImmediateExpansionRange(FileLoc);
return SM.createInstantiationLoc(SpellingLoc, II.first, II.second, TokLen);
return SM.createExpansionLoc(SpellingLoc, II.first, II.second, TokLen);
}
/// getSourceLocation - Return a source location identifier for the specified

View File

@ -284,8 +284,8 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
// Update the tokens location to include both its expansion and physical
// locations.
SourceLocation Loc =
SourceMgr.createInstantiationLoc(Identifier.getLocation(), ExpandLoc,
ExpansionEnd,Identifier.getLength());
SourceMgr.createExpansionLoc(Identifier.getLocation(), ExpandLoc,
ExpansionEnd,Identifier.getLength());
Identifier.setLocation(Loc);
// If this is a disabled macro or #define X X, we must mark the result as
@ -875,18 +875,18 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
ComputeDATE_TIME(DATELoc, TIMELoc, *this);
Tok.setKind(tok::string_literal);
Tok.setLength(strlen("\"Mmm dd yyyy\""));
Tok.setLocation(SourceMgr.createInstantiationLoc(DATELoc, Tok.getLocation(),
Tok.getLocation(),
Tok.getLength()));
Tok.setLocation(SourceMgr.createExpansionLoc(DATELoc, Tok.getLocation(),
Tok.getLocation(),
Tok.getLength()));
return;
} else if (II == Ident__TIME__) {
if (!TIMELoc.isValid())
ComputeDATE_TIME(DATELoc, TIMELoc, *this);
Tok.setKind(tok::string_literal);
Tok.setLength(strlen("\"hh:mm:ss\""));
Tok.setLocation(SourceMgr.createInstantiationLoc(TIMELoc, Tok.getLocation(),
Tok.getLocation(),
Tok.getLength()));
Tok.setLocation(SourceMgr.createExpansionLoc(TIMELoc, Tok.getLocation(),
Tok.getLocation(),
Tok.getLength()));
return;
} else if (II == Ident__INCLUDE_LEVEL__) {
// Compute the presumed include depth of this token. This can be affected

View File

@ -335,8 +335,7 @@ void Preprocessor::CreateString(const char *Buf, unsigned Len, Token &Tok,
SourceLocation Loc = ScratchBuf->getToken(Buf, Len, DestPtr);
if (ExpansionLoc.isValid())
Loc = SourceMgr.createInstantiationLoc(Loc, ExpansionLoc,
ExpansionLoc, Len);
Loc = SourceMgr.createExpansionLoc(Loc, ExpansionLoc, ExpansionLoc, Len);
Tok.setLocation(Loc);
// If this is a raw identifier or a literal token, set the pointer data.

View File

@ -57,10 +57,10 @@ void TokenLexer::Init(Token &Tok, SourceLocation ELEnd, MacroArgs *Actuals) {
// creating separate source location entries for each token.
SourceLocation macroStart = SM.getExpansionLoc(Tokens[0].getLocation());
MacroDefStartInfo = SM.getDecomposedLoc(macroStart);
MacroExpansionStart = SM.createInstantiationLoc(macroStart,
ExpandLocStart,
ExpandLocEnd,
Macro->getDefinitionLength(SM));
MacroExpansionStart = SM.createExpansionLoc(macroStart,
ExpandLocStart,
ExpandLocEnd,
Macro->getDefinitionLength(SM));
}
// If this is a function-like macro, expand the arguments and change
@ -231,9 +231,9 @@ void TokenLexer::ExpandFunctionArguments() {
"Expected arg identifier to come from definition");
for (unsigned i = FirstResult, e = ResultToks.size(); i != e; ++i) {
Token &Tok = ResultToks[i];
Tok.setLocation(SM.createMacroArgInstantiationLoc(Tok.getLocation(),
curInst,
Tok.getLength()));
Tok.setLocation(SM.createMacroArgExpansionLoc(Tok.getLocation(),
curInst,
Tok.getLength()));
}
}
@ -289,9 +289,9 @@ void TokenLexer::ExpandFunctionArguments() {
for (unsigned i = ResultToks.size() - NumToks, e = ResultToks.size();
i != e; ++i) {
Token &Tok = ResultToks[i];
Tok.setLocation(SM.createMacroArgInstantiationLoc(Tok.getLocation(),
curInst,
Tok.getLength()));
Tok.setLocation(SM.createMacroArgExpansionLoc(Tok.getLocation(),
curInst,
Tok.getLength()));
}
}
@ -421,10 +421,10 @@ void TokenLexer::Lex(Token &Tok) {
MacroStartSLocOffset)) {
SourceLocation instLoc;
if (Tok.is(tok::comment)) {
instLoc = SM.createInstantiationLoc(Tok.getLocation(),
ExpandLocStart,
ExpandLocEnd,
Tok.getLength());
instLoc = SM.createExpansionLoc(Tok.getLocation(),
ExpandLocStart,
ExpandLocEnd,
Tok.getLength());
} else {
instLoc = getMacroExpansionLocation(Tok.getLocation());
assert(instLoc.isValid() &&
@ -574,8 +574,7 @@ bool TokenLexer::PasteTokens(Token &Tok) {
// information so that the user knows where it came from.
SourceManager &SM = PP.getSourceManager();
SourceLocation Loc =
SM.createInstantiationLoc(PasteOpLoc, ExpandLocStart,
ExpandLocEnd, 2);
SM.createExpansionLoc(PasteOpLoc, ExpandLocStart, ExpandLocEnd, 2);
// If we're in microsoft extensions mode, downgrade this from a hard
// error to a warning that defaults to an error. This allows
// disabling it.
@ -616,10 +615,10 @@ bool TokenLexer::PasteTokens(Token &Tok) {
assert(pasteLocInst.isValid() &&
"Expected '##' to come from definition");
Tok.setLocation(SM.createInstantiationLoc(Tok.getLocation(),
pasteLocInst,
pasteLocInst,
Tok.getLength()));
Tok.setLocation(SM.createExpansionLoc(Tok.getLocation(),
pasteLocInst,
pasteLocInst,
Tok.getLength()));
}
// Now that we got the result token, it will be subject to expansion. Since

View File

@ -1359,7 +1359,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) {
case SM_SLOC_EXPANSION_ENTRY: {
SourceLocation SpellingLoc = ReadSourceLocation(*F, Record[1]);
SourceMgr.createInstantiationLoc(SpellingLoc,
SourceMgr.createExpansionLoc(SpellingLoc,
ReadSourceLocation(*F, Record[2]),
ReadSourceLocation(*F, Record[3]),
Record[4],