rename getFullFilePos -> getFileOffset.

llvm-svn: 63097
This commit is contained in:
Chris Lattner 2009-01-27 06:27:13 +00:00
parent dd62885f40
commit c360bf2e48
4 changed files with 15 additions and 16 deletions

View File

@ -159,7 +159,7 @@ void PTHWriter::EmitToken(const Token& T) {
else else
Emit32(ResolveID(T.getIdentifierInfo())); Emit32(ResolveID(T.getIdentifierInfo()));
Emit32(PP.getSourceManager().getFullFilePos(T.getLocation())); Emit32(PP.getSourceManager().getFileOffset(T.getLocation()));
} }
namespace { namespace {

View File

@ -130,13 +130,13 @@ void clang::RewriteMacrosInInput(Preprocessor &PP,const std::string &InFileName,
const IdentifierInfo *II = RawTokens[CurRawTok].getIdentifierInfo(); const IdentifierInfo *II = RawTokens[CurRawTok].getIdentifierInfo();
if (!strcmp(II->getName(), "warning")) { if (!strcmp(II->getName(), "warning")) {
// Comment out #warning. // Comment out #warning.
RB.InsertTextAfter(SM.getFullFilePos(RawTok.getLocation()), "//", 2); RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//", 2);
} else if (!strcmp(II->getName(), "pragma") && } else if (!strcmp(II->getName(), "pragma") &&
RawTokens[CurRawTok+1].is(tok::identifier) && RawTokens[CurRawTok+1].is(tok::identifier) &&
!strcmp(RawTokens[CurRawTok+1].getIdentifierInfo()->getName(), !strcmp(RawTokens[CurRawTok+1].getIdentifierInfo()->getName(),
"mark")){ "mark")){
// Comment out #pragma mark. // Comment out #pragma mark.
RB.InsertTextAfter(SM.getFullFilePos(RawTok.getLocation()), "//", 2); RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//", 2);
} }
} }
@ -150,8 +150,8 @@ void clang::RewriteMacrosInInput(Preprocessor &PP,const std::string &InFileName,
// Okay, both tokens are from the same file. Get their offsets from the // Okay, both tokens are from the same file. Get their offsets from the
// start of the file. // start of the file.
unsigned PPOffs = SM.getFullFilePos(PPLoc); unsigned PPOffs = SM.getFileOffset(PPLoc);
unsigned RawOffs = SM.getFullFilePos(RawTok.getLocation()); unsigned RawOffs = SM.getFileOffset(RawTok.getLocation());
// If the offsets are the same and the token kind is the same, ignore them. // If the offsets are the same and the token kind is the same, ignore them.
if (PPOffs == RawOffs && isSameToken(RawTok, PPTok)) { if (PPOffs == RawOffs && isSameToken(RawTok, PPTok)) {
@ -173,7 +173,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP,const std::string &InFileName,
EndPos = RawOffs+RawTok.getLength(); EndPos = RawOffs+RawTok.getLength();
RawTok = GetNextRawTok(RawTokens, CurRawTok, true); RawTok = GetNextRawTok(RawTokens, CurRawTok, true);
RawOffs = SM.getFullFilePos(RawTok.getLocation()); RawOffs = SM.getFileOffset(RawTok.getLocation());
if (RawTok.is(tok::comment)) { if (RawTok.is(tok::comment)) {
// Skip past the comment. // Skip past the comment.
@ -197,7 +197,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP,const std::string &InFileName,
Expansion += ' ' + PP.getSpelling(PPTok); Expansion += ' ' + PP.getSpelling(PPTok);
PP.Lex(PPTok); PP.Lex(PPTok);
PPLoc = SM.getInstantiationLoc(PPTok.getLocation()); PPLoc = SM.getInstantiationLoc(PPTok.getLocation());
PPOffs = SM.getFullFilePos(PPLoc); PPOffs = SM.getFileOffset(PPLoc);
} }
Expansion += ' '; Expansion += ' ';
RB.InsertTextBefore(InsertPos, &Expansion[0], Expansion.size()); RB.InsertTextBefore(InsertPos, &Expansion[0], Expansion.size());

View File

@ -468,11 +468,10 @@ public:
return getDecomposedSpellingLocSlowCase(E, Offset); return getDecomposedSpellingLocSlowCase(E, Offset);
} }
/// getFullFilePos - This (efficient) method returns the offset from the start /// getFileOffset - This method returns the offset from the start
/// of the file that the specified spelling SourceLocation represents. This /// of the file that the specified SourceLocation represents. This is not very
/// returns the location of the actual character data, not the instantiation /// meaningful for a macro ID.
/// position. unsigned getFileOffset(SourceLocation SpellingLoc) const {
unsigned getFullFilePos(SourceLocation SpellingLoc) const {
return getDecomposedLoc(SpellingLoc).second; return getDecomposedLoc(SpellingLoc).second;
} }

View File

@ -36,8 +36,8 @@ void html::HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E,
FileID FID = SM.getFileID(B); FileID FID = SM.getFileID(B);
assert(SM.getFileID(E) == FID && "B/E not in the same file!"); assert(SM.getFileID(E) == FID && "B/E not in the same file!");
unsigned BOffset = SM.getFullFilePos(B); unsigned BOffset = SM.getFileOffset(B);
unsigned EOffset = SM.getFullFilePos(E); unsigned EOffset = SM.getFileOffset(E);
// Include the whole end token in the range. // Include the whole end token in the range.
EOffset += Lexer::MeasureTokenLength(E, R.getSourceMgr()); EOffset += Lexer::MeasureTokenLength(E, R.getSourceMgr());
@ -359,7 +359,7 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, Preprocessor &PP) {
while (Tok.isNot(tok::eof)) { while (Tok.isNot(tok::eof)) {
// Since we are lexing unexpanded tokens, all tokens are from the main // Since we are lexing unexpanded tokens, all tokens are from the main
// FileID. // FileID.
unsigned TokOffs = SourceMgr.getFullFilePos(Tok.getLocation()); unsigned TokOffs = SourceMgr.getFileOffset(Tok.getLocation());
unsigned TokLen = Tok.getLength(); unsigned TokLen = Tok.getLength();
switch (Tok.getKind()) { switch (Tok.getKind()) {
default: break; default: break;
@ -397,7 +397,7 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, Preprocessor &PP) {
unsigned TokEnd = TokOffs+TokLen; unsigned TokEnd = TokOffs+TokLen;
L.LexFromRawLexer(Tok); L.LexFromRawLexer(Tok);
while (!Tok.isAtStartOfLine() && Tok.isNot(tok::eof)) { while (!Tok.isAtStartOfLine() && Tok.isNot(tok::eof)) {
TokEnd = SourceMgr.getFullFilePos(Tok.getLocation())+Tok.getLength(); TokEnd = SourceMgr.getFileOffset(Tok.getLocation())+Tok.getLength();
L.LexFromRawLexer(Tok); L.LexFromRawLexer(Tok);
} }