зеркало из https://github.com/microsoft/clang.git
Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.
It already works (and is useful with) macro locs as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140057 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
5a4374812c
Коммит
a64ccefdf0
|
@ -125,11 +125,10 @@ private:
|
|||
}
|
||||
public:
|
||||
|
||||
/// getFileLocWithOffset - Return a source location with the specified offset
|
||||
/// from this file SourceLocation.
|
||||
SourceLocation getFileLocWithOffset(int Offset) const {
|
||||
assert(((getOffset()+Offset) & MacroIDBit) == 0 &&
|
||||
"offset overflow or macro loc");
|
||||
/// \brief Return a source location with the specified offset from this
|
||||
/// SourceLocation.
|
||||
SourceLocation getLocWithOffset(int Offset) const {
|
||||
assert(((getOffset()+Offset) & MacroIDBit) == 0 && "offset overflow");
|
||||
SourceLocation L;
|
||||
L.ID = ID+Offset;
|
||||
return L;
|
||||
|
|
|
@ -1147,7 +1147,7 @@ public:
|
|||
assert(Module.SLocRemap.find(Loc.getOffset()) != Module.SLocRemap.end() &&
|
||||
"Cannot find offset to remap.");
|
||||
int Remap = Module.SLocRemap.find(Loc.getOffset())->second;
|
||||
return Loc.getFileLocWithOffset(Remap);
|
||||
return Loc.getLocWithOffset(Remap);
|
||||
}
|
||||
|
||||
/// \brief Read a source location.
|
||||
|
|
|
@ -47,7 +47,7 @@ static bool isEmptyARCMTMacroStatement(NullStmt *S,
|
|||
SourceManager::LocBeforeThanCompare(SM));
|
||||
--I;
|
||||
SourceLocation
|
||||
AfterMacroLoc = I->getFileLocWithOffset(getARCMTMacroName().size());
|
||||
AfterMacroLoc = I->getLocWithOffset(getARCMTMacroName().size());
|
||||
assert(AfterMacroLoc.isFileID());
|
||||
|
||||
if (AfterMacroLoc == SemiLoc)
|
||||
|
|
|
@ -479,7 +479,7 @@ void TransformActionsImpl::commitReplaceText(SourceLocation loc,
|
|||
SourceManager &SM = Ctx.getSourceManager();
|
||||
loc = SM.getExpansionLoc(loc);
|
||||
// canReplaceText already checked if loc points at text.
|
||||
SourceLocation afterText = loc.getFileLocWithOffset(text.size());
|
||||
SourceLocation afterText = loc.getLocWithOffset(text.size());
|
||||
|
||||
addRemoval(CharSourceRange::getCharRange(loc, afterText));
|
||||
commitInsert(loc, replacementText);
|
||||
|
|
|
@ -94,7 +94,7 @@ SourceLocation trans::findLocationAfterSemi(SourceLocation loc,
|
|||
SourceLocation SemiLoc = findSemiAfterLocation(loc, Ctx);
|
||||
if (SemiLoc.isInvalid())
|
||||
return SourceLocation();
|
||||
return SemiLoc.getFileLocWithOffset(1);
|
||||
return SemiLoc.getLocWithOffset(1);
|
||||
}
|
||||
|
||||
/// \brief \arg Loc is the end of a statement range. This returns the location
|
||||
|
|
|
@ -4299,7 +4299,7 @@ SourceLocation ASTImporter::Import(SourceLocation FromLoc) {
|
|||
std::pair<FileID, unsigned> Decomposed = FromSM.getDecomposedLoc(FromLoc);
|
||||
SourceManager &ToSM = ToContext.getSourceManager();
|
||||
return ToSM.getLocForStartOfFile(Import(Decomposed.first))
|
||||
.getFileLocWithOffset(Decomposed.second);
|
||||
.getLocWithOffset(Decomposed.second);
|
||||
}
|
||||
|
||||
SourceRange ASTImporter::Import(SourceRange FromRange) {
|
||||
|
|
|
@ -802,7 +802,7 @@ SourceLocation SourceManager::getSpellingLocSlowCase(SourceLocation Loc) const {
|
|||
do {
|
||||
std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
|
||||
Loc = getSLocEntry(LocInfo.first).getExpansion().getSpellingLoc();
|
||||
Loc = Loc.getFileLocWithOffset(LocInfo.second);
|
||||
Loc = Loc.getLocWithOffset(LocInfo.second);
|
||||
} while (!Loc.isFileID());
|
||||
return Loc;
|
||||
}
|
||||
|
@ -834,7 +834,7 @@ SourceManager::getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
|
|||
SourceLocation Loc;
|
||||
do {
|
||||
Loc = E->getExpansion().getSpellingLoc();
|
||||
Loc = Loc.getFileLocWithOffset(Offset);
|
||||
Loc = Loc.getLocWithOffset(Offset);
|
||||
|
||||
FID = getFileID(Loc);
|
||||
E = &getSLocEntry(FID);
|
||||
|
@ -852,7 +852,7 @@ SourceLocation SourceManager::getImmediateSpellingLoc(SourceLocation Loc) const{
|
|||
if (Loc.isFileID()) return Loc;
|
||||
std::pair<FileID, unsigned> LocInfo = getDecomposedLoc(Loc);
|
||||
Loc = getSLocEntry(LocInfo.first).getExpansion().getSpellingLoc();
|
||||
return Loc.getFileLocWithOffset(LocInfo.second);
|
||||
return Loc.getLocWithOffset(LocInfo.second);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc) const {
|
|||
// Handle virtual #include manipulation.
|
||||
if (Entry->IncludeOffset) {
|
||||
IncludeLoc = getLocForStartOfFile(LocInfo.first);
|
||||
IncludeLoc = IncludeLoc.getFileLocWithOffset(Entry->IncludeOffset);
|
||||
IncludeLoc = IncludeLoc.getLocWithOffset(Entry->IncludeOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1457,7 +1457,7 @@ SourceLocation SourceManager::translateFileLineCol(const FileEntry *SourceFile,
|
|||
unsigned Size = Content->getBuffer(Diag, *this)->getBufferSize();
|
||||
if (Size > 0)
|
||||
--Size;
|
||||
return getLocForStartOfFile(FirstFID).getFileLocWithOffset(Size);
|
||||
return getLocForStartOfFile(FirstFID).getLocWithOffset(Size);
|
||||
}
|
||||
|
||||
unsigned FilePos = Content->SourceLineCache[Line - 1];
|
||||
|
@ -1469,9 +1469,9 @@ SourceLocation SourceManager::translateFileLineCol(const FileEntry *SourceFile,
|
|||
while (i < BufLength-1 && i < Col-1 && Buf[i] != '\n' && Buf[i] != '\r')
|
||||
++i;
|
||||
if (i < Col-1)
|
||||
return getLocForStartOfFile(FirstFID).getFileLocWithOffset(FilePos + i);
|
||||
return getLocForStartOfFile(FirstFID).getLocWithOffset(FilePos + i);
|
||||
|
||||
return getLocForStartOfFile(FirstFID).getFileLocWithOffset(FilePos + Col - 1);
|
||||
return getLocForStartOfFile(FirstFID).getLocWithOffset(FilePos + Col - 1);
|
||||
}
|
||||
|
||||
/// \brief Compute a map of macro argument chunks to their expanded source
|
||||
|
@ -1584,7 +1584,7 @@ SourceLocation SourceManager::getMacroArgExpandedLocation(SourceLocation Loc) {
|
|||
unsigned MacroArgBeginOffs = I->first;
|
||||
SourceLocation MacroArgExpandedLoc = I->second;
|
||||
if (MacroArgExpandedLoc.isValid())
|
||||
return MacroArgExpandedLoc.getFileLocWithOffset(Offset - MacroArgBeginOffs);
|
||||
return MacroArgExpandedLoc.getLocWithOffset(Offset - MacroArgBeginOffs);
|
||||
|
||||
return Loc;
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic &D,
|
|||
// Translate the offset into the file.
|
||||
unsigned Offset = D.getLoc().getPointer() - LBuf->getBufferStart();
|
||||
SourceLocation NewLoc =
|
||||
CSM.getLocForStartOfFile(FID).getFileLocWithOffset(Offset);
|
||||
CSM.getLocForStartOfFile(FID).getLocWithOffset(Offset);
|
||||
return FullSourceLoc(NewLoc, CSM);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ static void ParseDirective(const char *CommentStart, unsigned CommentLen,
|
|||
|
||||
// next token: {{
|
||||
if (!PH.Next("{{")) {
|
||||
PP.Diag(Pos.getFileLocWithOffset(PH.C-PH.Begin),
|
||||
PP.Diag(Pos.getLocWithOffset(PH.C-PH.Begin),
|
||||
diag::err_verify_missing_start) << KindStr;
|
||||
continue;
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ static void ParseDirective(const char *CommentStart, unsigned CommentLen,
|
|||
|
||||
// search for token: }}
|
||||
if (!PH.Search("}}")) {
|
||||
PP.Diag(Pos.getFileLocWithOffset(PH.C-PH.Begin),
|
||||
PP.Diag(Pos.getLocWithOffset(PH.C-PH.Begin),
|
||||
diag::err_verify_missing_end) << KindStr;
|
||||
continue;
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ static void ParseDirective(const char *CommentStart, unsigned CommentLen,
|
|||
if (D->isValid(Error))
|
||||
DL->push_back(D);
|
||||
else {
|
||||
PP.Diag(Pos.getFileLocWithOffset(ContentBegin-PH.Begin),
|
||||
PP.Diag(Pos.getLocWithOffset(ContentBegin-PH.Begin),
|
||||
diag::err_verify_invalid_content)
|
||||
<< KindStr << Error;
|
||||
}
|
||||
|
|
|
@ -449,7 +449,7 @@ static SourceLocation getBeginningOfFileToken(SourceLocation Loc,
|
|||
}
|
||||
|
||||
// Create a lexer starting at the beginning of this token.
|
||||
SourceLocation LexerStartLoc = Loc.getFileLocWithOffset(-LocInfo.second);
|
||||
SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
|
||||
Lexer TheLexer(LexerStartLoc, LangOpts, BufStart, LexStart, Buffer.end());
|
||||
TheLexer.SetCommentRetentionState(true);
|
||||
|
||||
|
@ -490,7 +490,7 @@ SourceLocation Lexer::GetBeginningOfToken(SourceLocation Loc,
|
|||
std::pair<FileID, unsigned> BeginFileLocInfo= SM.getDecomposedLoc(BeginFileLoc);
|
||||
assert(FileLocInfo.first == BeginFileLocInfo.first &&
|
||||
FileLocInfo.second >= BeginFileLocInfo.second);
|
||||
return Loc.getFileLocWithOffset(SM.getDecomposedLoc(BeginFileLoc).second -
|
||||
return Loc.getLocWithOffset(SM.getDecomposedLoc(BeginFileLoc).second -
|
||||
SM.getDecomposedLoc(FileLoc).second);
|
||||
}
|
||||
|
||||
|
@ -673,7 +673,7 @@ SourceLocation Lexer::AdvanceToTokenCharacter(SourceLocation TokStart,
|
|||
// chars, this method is extremely fast.
|
||||
while (Lexer::isObviouslySimpleCharacter(*TokPtr)) {
|
||||
if (CharNo == 0)
|
||||
return TokStart.getFileLocWithOffset(PhysOffset);
|
||||
return TokStart.getLocWithOffset(PhysOffset);
|
||||
++TokPtr, --CharNo, ++PhysOffset;
|
||||
}
|
||||
|
||||
|
@ -693,7 +693,7 @@ SourceLocation Lexer::AdvanceToTokenCharacter(SourceLocation TokStart,
|
|||
if (!Lexer::isObviouslySimpleCharacter(*TokPtr))
|
||||
PhysOffset += Lexer::SkipEscapedNewLines(TokPtr)-TokPtr;
|
||||
|
||||
return TokStart.getFileLocWithOffset(PhysOffset);
|
||||
return TokStart.getLocWithOffset(PhysOffset);
|
||||
}
|
||||
|
||||
/// \brief Computes the source location just past the end of the
|
||||
|
@ -731,7 +731,7 @@ SourceLocation Lexer::getLocForEndOfToken(SourceLocation Loc, unsigned Offset,
|
|||
else
|
||||
return Loc;
|
||||
|
||||
return Loc.getFileLocWithOffset(Len);
|
||||
return Loc.getLocWithOffset(Len);
|
||||
}
|
||||
|
||||
/// \brief Returns true if the given MacroID location points at the first
|
||||
|
@ -768,7 +768,7 @@ bool Lexer::isAtEndOfMacroExpansion(SourceLocation loc,
|
|||
return false;
|
||||
|
||||
FileID FID = SM.getFileID(loc);
|
||||
SourceLocation afterLoc = loc.getFileLocWithOffset(tokLen+1);
|
||||
SourceLocation afterLoc = loc.getLocWithOffset(tokLen+1);
|
||||
if (SM.isInFileID(afterLoc, FID))
|
||||
return false; // Still in the same FileID, does not point to the last token.
|
||||
|
||||
|
@ -954,7 +954,7 @@ static SourceLocation GetMappedTokenLoc(Preprocessor &PP,
|
|||
// Create a new SLoc which is expanded from Expansion(FileLoc) but whose
|
||||
// characters come from spelling(FileLoc)+Offset.
|
||||
SourceLocation SpellingLoc = SM.getSpellingLoc(FileLoc);
|
||||
SpellingLoc = SpellingLoc.getFileLocWithOffset(CharNo);
|
||||
SpellingLoc = SpellingLoc.getLocWithOffset(CharNo);
|
||||
|
||||
// Figure out the expansion loc range, which is the range covered by the
|
||||
// original _Pragma(...) sequence.
|
||||
|
@ -975,7 +975,7 @@ SourceLocation Lexer::getSourceLocation(const char *Loc,
|
|||
// the file id from FileLoc with the offset specified.
|
||||
unsigned CharNo = Loc-BufferStart;
|
||||
if (FileLoc.isFileID())
|
||||
return FileLoc.getFileLocWithOffset(CharNo);
|
||||
return FileLoc.getLocWithOffset(CharNo);
|
||||
|
||||
// Otherwise, this is the _Pragma lexer case, which pretends that all of the
|
||||
// tokens are lexed from where the _Pragma was defined.
|
||||
|
@ -1126,7 +1126,7 @@ SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc,
|
|||
NumWhitespaceChars++;
|
||||
}
|
||||
|
||||
return TokenLoc.getFileLocWithOffset(Tok.getLength() + NumWhitespaceChars);
|
||||
return TokenLoc.getLocWithOffset(Tok.getLength() + NumWhitespaceChars);
|
||||
}
|
||||
|
||||
/// getCharAndSizeSlow - Peek a single 'character' from the specified buffer,
|
||||
|
@ -2250,7 +2250,7 @@ bool Lexer::HandleEndOfConflictMarker(const char *CurPtr) {
|
|||
|
||||
bool Lexer::isCodeCompletionPoint(const char *CurPtr) const {
|
||||
if (PP && PP->isCodeCompletionEnabled()) {
|
||||
SourceLocation Loc = FileLoc.getFileLocWithOffset(CurPtr-BufferStart);
|
||||
SourceLocation Loc = FileLoc.getLocWithOffset(CurPtr-BufferStart);
|
||||
return Loc == PP->getCodeCompletionLoc();
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ void Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir,
|
|||
SourceMgr.getFileEntryForID(FID) == CodeCompletionFile) {
|
||||
CodeCompletionFileLoc = SourceMgr.getLocForStartOfFile(FID);
|
||||
CodeCompletionLoc =
|
||||
CodeCompletionFileLoc.getFileLocWithOffset(CodeCompletionOffset);
|
||||
CodeCompletionFileLoc.getLocWithOffset(CodeCompletionOffset);
|
||||
}
|
||||
|
||||
EnterSourceFileWithLexer(new Lexer(FID, InputFile, *this), CurDir);
|
||||
|
|
|
@ -73,7 +73,7 @@ LexNextToken:
|
|||
Tok.setKind(TKind);
|
||||
Tok.setFlag(TFlags);
|
||||
assert(!LexingRawMode);
|
||||
Tok.setLocation(FileStartLoc.getFileLocWithOffset(FileOffset));
|
||||
Tok.setLocation(FileStartLoc.getLocWithOffset(FileOffset));
|
||||
Tok.setLength(Len);
|
||||
|
||||
// Handle identifiers.
|
||||
|
@ -297,7 +297,7 @@ SourceLocation PTHLexer::getSourceLocation() {
|
|||
// NOTE: This is a virtual function; hence it is defined out-of-line.
|
||||
const unsigned char *OffsetPtr = CurPtr + (DISK_TOKEN_SIZE - 4);
|
||||
uint32_t Offset = ReadLE32(OffsetPtr);
|
||||
return FileStartLoc.getFileLocWithOffset(Offset);
|
||||
return FileStartLoc.getLocWithOffset(Offset);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -53,7 +53,7 @@ SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len,
|
|||
// diagnostic points to one.
|
||||
CurBuffer[BytesUsed-1] = '\0';
|
||||
|
||||
return BufferStartLoc.getFileLocWithOffset(BytesUsed-Len-1);
|
||||
return BufferStartLoc.getLocWithOffset(BytesUsed-Len-1);
|
||||
}
|
||||
|
||||
void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) {
|
||||
|
|
|
@ -143,7 +143,7 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok,
|
|||
// source. If they were, it must be okay to stick them together: if there
|
||||
// were an issue, the tokens would have been lexed differently.
|
||||
if (PrevTok.getLocation().isFileID() && Tok.getLocation().isFileID() &&
|
||||
PrevTok.getLocation().getFileLocWithOffset(PrevTok.getLength()) ==
|
||||
PrevTok.getLocation().getLocWithOffset(PrevTok.getLength()) ==
|
||||
Tok.getLocation())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ TokenLexer::getExpansionLocForMacroDefLoc(SourceLocation loc) const {
|
|||
|
||||
unsigned relativeOffset = 0;
|
||||
SM.isInSLocAddrSpace(loc, MacroDefStart, MacroDefLength, &relativeOffset);
|
||||
return MacroExpansionStart.getFileLocWithOffset(relativeOffset);
|
||||
return MacroExpansionStart.getLocWithOffset(relativeOffset);
|
||||
}
|
||||
|
||||
/// \brief Finds the tokens that are consecutive (from the same FileID)
|
||||
|
@ -713,7 +713,7 @@ static void updateConsecutiveMacroArgTokens(SourceManager &SM,
|
|||
Token &Tok = *begin_tokens;
|
||||
int RelOffs = 0;
|
||||
SM.isInSameSLocAddrSpace(FirstLoc, Tok.getLocation(), &RelOffs);
|
||||
Tok.setLocation(Expansion.getFileLocWithOffset(RelOffs));
|
||||
Tok.setLocation(Expansion.getLocWithOffset(RelOffs));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -315,12 +315,12 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
|
|||
FILoc = SM.getExpansionLoc(FILoc);
|
||||
bool IsInvalid = false;
|
||||
const char *SourcePtr =
|
||||
SM.getCharacterData(FILoc.getFileLocWithOffset(-1), &IsInvalid);
|
||||
SM.getCharacterData(FILoc.getLocWithOffset(-1), &IsInvalid);
|
||||
if (!IsInvalid && *SourcePtr == ' ') {
|
||||
SourcePtr =
|
||||
SM.getCharacterData(FILoc.getFileLocWithOffset(-2), &IsInvalid);
|
||||
SM.getCharacterData(FILoc.getLocWithOffset(-2), &IsInvalid);
|
||||
if (!IsInvalid && *SourcePtr == ' ') {
|
||||
FILoc = FILoc.getFileLocWithOffset(-1);
|
||||
FILoc = FILoc.getLocWithOffset(-1);
|
||||
FIText = ":";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ static int SelectDigraphErrorMessage(tok::TokenKind Kind) {
|
|||
static bool AreTokensAdjacent(Preprocessor &PP, Token &First, Token &Second) {
|
||||
SourceManager &SM = PP.getSourceManager();
|
||||
SourceLocation FirstLoc = SM.getSpellingLoc(First.getLocation());
|
||||
SourceLocation FirstEnd = FirstLoc.getFileLocWithOffset(First.getLength());
|
||||
SourceLocation FirstEnd = FirstLoc.getLocWithOffset(First.getLength());
|
||||
return FirstEnd == SM.getSpellingLoc(Second.getLocation());
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ static void FixDigraph(Parser &P, Preprocessor &PP, Token &DigraphToken,
|
|||
|
||||
// Update token information to reflect their change in token type.
|
||||
ColonToken.setKind(tok::coloncolon);
|
||||
ColonToken.setLocation(ColonToken.getLocation().getFileLocWithOffset(-1));
|
||||
ColonToken.setLocation(ColonToken.getLocation().getLocWithOffset(-1));
|
||||
ColonToken.setLength(2);
|
||||
DigraphToken.setKind(tok::less);
|
||||
DigraphToken.setLength(1);
|
||||
|
|
|
@ -277,7 +277,7 @@ void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID,
|
|||
const char* FileEnd = Buf->getBufferEnd();
|
||||
|
||||
SourceLocation StartLoc = R.getSourceMgr().getLocForStartOfFile(FID);
|
||||
SourceLocation EndLoc = StartLoc.getFileLocWithOffset(FileEnd-FileStart);
|
||||
SourceLocation EndLoc = StartLoc.getLocWithOffset(FileEnd-FileStart);
|
||||
|
||||
std::string s;
|
||||
llvm::raw_string_ostream os(s);
|
||||
|
|
|
@ -779,7 +779,7 @@ void RewriteObjC::RewriteInclude() {
|
|||
if (!strncmp(BufPtr, "import", ImportLen)) {
|
||||
// replace import with include
|
||||
SourceLocation ImportLoc =
|
||||
LocStart.getFileLocWithOffset(BufPtr-MainBufStart);
|
||||
LocStart.getLocWithOffset(BufPtr-MainBufStart);
|
||||
ReplaceText(ImportLoc, ImportLen, "include");
|
||||
BufPtr += ImportLen;
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
|||
const char *semiBuf = strchr(startBuf, ';');
|
||||
assert((*semiBuf == ';') && "@synthesize: can't find ';'");
|
||||
SourceLocation onePastSemiLoc =
|
||||
startLoc.getFileLocWithOffset(semiBuf-startBuf+1);
|
||||
startLoc.getLocWithOffset(semiBuf-startBuf+1);
|
||||
|
||||
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
|
||||
return; // FIXME: is this correct?
|
||||
|
@ -1051,12 +1051,12 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
|
|||
const char *endBuf = SM->getCharacterData(LocEnd);
|
||||
for (const char *p = startBuf; p < endBuf; p++) {
|
||||
if (*p == '@' && !strncmp(p+1, "optional", strlen("optional"))) {
|
||||
SourceLocation OptionalLoc = LocStart.getFileLocWithOffset(p-startBuf);
|
||||
SourceLocation OptionalLoc = LocStart.getLocWithOffset(p-startBuf);
|
||||
ReplaceText(OptionalLoc, strlen("@optional"), "/* @optional */");
|
||||
|
||||
}
|
||||
else if (*p == '@' && !strncmp(p+1, "required", strlen("required"))) {
|
||||
SourceLocation OptionalLoc = LocStart.getFileLocWithOffset(p-startBuf);
|
||||
SourceLocation OptionalLoc = LocStart.getLocWithOffset(p-startBuf);
|
||||
ReplaceText(OptionalLoc, strlen("@required"), "/* @required */");
|
||||
|
||||
}
|
||||
|
@ -1717,7 +1717,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
|
|||
// Replace ')' in for '(' type elem in collection ')' with ';'
|
||||
SourceLocation rightParenLoc = S->getRParenLoc();
|
||||
const char *rparenBuf = SM->getCharacterData(rightParenLoc);
|
||||
SourceLocation lparenLoc = startLoc.getFileLocWithOffset(rparenBuf-startBuf);
|
||||
SourceLocation lparenLoc = startLoc.getLocWithOffset(rparenBuf-startBuf);
|
||||
buf = ";\n\t";
|
||||
|
||||
// unsigned long limit = [l_collection countByEnumeratingWithState:&enumState
|
||||
|
@ -1794,7 +1794,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
|
|||
// Insert all these *after* the statement body.
|
||||
// FIXME: If this should support Obj-C++, support CXXTryStmt
|
||||
if (isa<CompoundStmt>(S->getBody())) {
|
||||
SourceLocation endBodyLoc = OrigEnd.getFileLocWithOffset(1);
|
||||
SourceLocation endBodyLoc = OrigEnd.getLocWithOffset(1);
|
||||
InsertText(endBodyLoc, buf);
|
||||
} else {
|
||||
/* Need to treat single statements specially. For example:
|
||||
|
@ -1807,7 +1807,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
|
|||
const char *stmtBuf = SM->getCharacterData(OrigEnd);
|
||||
const char *semiBuf = strchr(stmtBuf, ';');
|
||||
assert(semiBuf && "Can't find ';'");
|
||||
SourceLocation endBodyLoc = OrigEnd.getFileLocWithOffset(semiBuf-stmtBuf+1);
|
||||
SourceLocation endBodyLoc = OrigEnd.getLocWithOffset(semiBuf-stmtBuf+1);
|
||||
InsertText(endBodyLoc, buf);
|
||||
}
|
||||
Stmts.pop_back();
|
||||
|
@ -1839,7 +1839,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
|
|||
SourceLocation endLoc = S->getSynchBody()->getLocStart();
|
||||
const char *endBuf = SM->getCharacterData(endLoc);
|
||||
while (*endBuf != ')') endBuf--;
|
||||
SourceLocation rparenLoc = startLoc.getFileLocWithOffset(endBuf-startBuf);
|
||||
SourceLocation rparenLoc = startLoc.getLocWithOffset(endBuf-startBuf);
|
||||
buf = ");\n";
|
||||
// declare a new scope with two variables, _stack and _rethrow.
|
||||
buf += "/* @try scope begin */ \n{ struct _objc_exception_data {\n";
|
||||
|
@ -1931,7 +1931,7 @@ void RewriteObjC::RewriteTryReturnStmts(Stmt *S) {
|
|||
|
||||
const char *semiBuf = strchr(startBuf, ';');
|
||||
assert((*semiBuf == ';') && "RewriteTryReturnStmts: can't find ';'");
|
||||
SourceLocation onePastSemiLoc = startLoc.getFileLocWithOffset(semiBuf-startBuf+1);
|
||||
SourceLocation onePastSemiLoc = startLoc.getLocWithOffset(semiBuf-startBuf+1);
|
||||
|
||||
std::string buf;
|
||||
buf = "{ objc_exception_try_exit(&_stack); return";
|
||||
|
@ -1954,7 +1954,7 @@ void RewriteObjC::RewriteSyncReturnStmts(Stmt *S, std::string syncExitBuf) {
|
|||
|
||||
const char *semiBuf = strchr(startBuf, ';');
|
||||
assert((*semiBuf == ';') && "RewriteSyncReturnStmts: can't find ';'");
|
||||
SourceLocation onePastSemiLoc = startLoc.getFileLocWithOffset(semiBuf-startBuf+1);
|
||||
SourceLocation onePastSemiLoc = startLoc.getLocWithOffset(semiBuf-startBuf+1);
|
||||
|
||||
std::string buf;
|
||||
buf = "{ objc_exception_try_exit(&_stack);";
|
||||
|
@ -1992,7 +1992,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
|
|||
|
||||
SourceLocation lastCurlyLoc = startLoc;
|
||||
if (S->getNumCatchStmts()) {
|
||||
startLoc = startLoc.getFileLocWithOffset(1);
|
||||
startLoc = startLoc.getLocWithOffset(1);
|
||||
buf = " /* @catch begin */ else {\n";
|
||||
buf += " id _caught = objc_exception_extract(&_stack);\n";
|
||||
buf += " objc_exception_try_enter (&_stack);\n";
|
||||
|
@ -2073,7 +2073,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
|
|||
"bogus @catch body location");
|
||||
|
||||
// Insert the last (implicit) else clause *before* the right curly brace.
|
||||
bodyLoc = bodyLoc.getFileLocWithOffset(-1);
|
||||
bodyLoc = bodyLoc.getLocWithOffset(-1);
|
||||
buf = "} /* last catch end */\n";
|
||||
buf += "else {\n";
|
||||
buf += " _rethrow = _caught;\n";
|
||||
|
@ -2101,9 +2101,9 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
|
|||
assert(*SM->getCharacterData(endLoc) == '}' &&
|
||||
"bogus @finally body location");
|
||||
|
||||
startLoc = startLoc.getFileLocWithOffset(1);
|
||||
startLoc = startLoc.getLocWithOffset(1);
|
||||
InsertText(startLoc, " if (!_rethrow) objc_exception_try_exit(&_stack);\n");
|
||||
endLoc = endLoc.getFileLocWithOffset(-1);
|
||||
endLoc = endLoc.getLocWithOffset(-1);
|
||||
InsertText(endLoc, " if (_rethrow) objc_exception_throw(_rethrow);\n");
|
||||
|
||||
// Set lastCurlyLoc
|
||||
|
@ -2127,7 +2127,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
|
|||
RewriteTryReturnStmts(S->getTryBody());
|
||||
}
|
||||
// Now emit the final closing curly brace...
|
||||
lastCurlyLoc = lastCurlyLoc.getFileLocWithOffset(1);
|
||||
lastCurlyLoc = lastCurlyLoc.getLocWithOffset(1);
|
||||
InsertText(lastCurlyLoc, " } /* @try scope end */\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -2156,7 +2156,7 @@ Stmt *RewriteObjC::RewriteObjCThrowStmt(ObjCAtThrowStmt *S) {
|
|||
|
||||
const char *semiBuf = strchr(startBuf, ';');
|
||||
assert((*semiBuf == ';') && "@throw: can't find ';'");
|
||||
SourceLocation semiLoc = startLoc.getFileLocWithOffset(semiBuf-startBuf);
|
||||
SourceLocation semiLoc = startLoc.getLocWithOffset(semiBuf-startBuf);
|
||||
ReplaceText(semiLoc, 1, ");");
|
||||
return 0;
|
||||
}
|
||||
|
@ -2287,8 +2287,8 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Expr *E) {
|
|||
const char *startRef = 0, *endRef = 0;
|
||||
if (scanForProtocolRefs(startBuf, endBuf, startRef, endRef)) {
|
||||
// Get the locations of the startRef, endRef.
|
||||
SourceLocation LessLoc = Loc.getFileLocWithOffset(startRef-startBuf);
|
||||
SourceLocation GreaterLoc = Loc.getFileLocWithOffset(endRef-startBuf+1);
|
||||
SourceLocation LessLoc = Loc.getLocWithOffset(startRef-startBuf);
|
||||
SourceLocation GreaterLoc = Loc.getLocWithOffset(endRef-startBuf+1);
|
||||
// Comment out the protocol references.
|
||||
InsertText(LessLoc, "/*");
|
||||
InsertText(GreaterLoc, "*/");
|
||||
|
@ -2332,8 +2332,8 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
|
|||
const char *startRef = 0, *endRef = 0;
|
||||
if (scanForProtocolRefs(startBuf, endBuf, startRef, endRef)) {
|
||||
// Get the locations of the startRef, endRef.
|
||||
SourceLocation LessLoc = Loc.getFileLocWithOffset(startRef-endBuf);
|
||||
SourceLocation GreaterLoc = Loc.getFileLocWithOffset(endRef-endBuf+1);
|
||||
SourceLocation LessLoc = Loc.getLocWithOffset(startRef-endBuf);
|
||||
SourceLocation GreaterLoc = Loc.getLocWithOffset(endRef-endBuf+1);
|
||||
// Comment out the protocol references.
|
||||
InsertText(LessLoc, "/*");
|
||||
InsertText(GreaterLoc, "*/");
|
||||
|
@ -2355,9 +2355,9 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
|
|||
if (scanForProtocolRefs(startBuf, endBuf, startRef, endRef)) {
|
||||
// Get the locations of the startRef, endRef.
|
||||
SourceLocation LessLoc =
|
||||
Loc.getFileLocWithOffset(startRef-startFuncBuf);
|
||||
Loc.getLocWithOffset(startRef-startFuncBuf);
|
||||
SourceLocation GreaterLoc =
|
||||
Loc.getFileLocWithOffset(endRef-startFuncBuf+1);
|
||||
Loc.getLocWithOffset(endRef-startFuncBuf+1);
|
||||
// Comment out the protocol references.
|
||||
InsertText(LessLoc, "/*");
|
||||
InsertText(GreaterLoc, "*/");
|
||||
|
@ -3384,7 +3384,7 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
|
|||
|
||||
// insert the super class structure definition.
|
||||
SourceLocation OnePastCurly =
|
||||
LocStart.getFileLocWithOffset(cursor-startBuf+1);
|
||||
LocStart.getLocWithOffset(cursor-startBuf+1);
|
||||
InsertText(OnePastCurly, Result);
|
||||
}
|
||||
cursor++; // past '{'
|
||||
|
@ -3392,7 +3392,7 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
|
|||
// Now comment out any visibility specifiers.
|
||||
while (cursor < endBuf) {
|
||||
if (*cursor == '@') {
|
||||
SourceLocation atLoc = LocStart.getFileLocWithOffset(cursor-startBuf);
|
||||
SourceLocation atLoc = LocStart.getLocWithOffset(cursor-startBuf);
|
||||
// Skip whitespace.
|
||||
for (++cursor; cursor[0] == ' ' || cursor[0] == '\t'; ++cursor)
|
||||
/*scan*/;
|
||||
|
@ -3409,20 +3409,20 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
|
|||
// of user code, then scan the ivar list and use needToScanForQualifiers
|
||||
// for type checking.
|
||||
else if (*cursor == '<') {
|
||||
SourceLocation atLoc = LocStart.getFileLocWithOffset(cursor-startBuf);
|
||||
SourceLocation atLoc = LocStart.getLocWithOffset(cursor-startBuf);
|
||||
InsertText(atLoc, "/* ");
|
||||
cursor = strchr(cursor, '>');
|
||||
cursor++;
|
||||
atLoc = LocStart.getFileLocWithOffset(cursor-startBuf);
|
||||
atLoc = LocStart.getLocWithOffset(cursor-startBuf);
|
||||
InsertText(atLoc, " */");
|
||||
} else if (*cursor == '^') { // rewrite block specifier.
|
||||
SourceLocation caretLoc = LocStart.getFileLocWithOffset(cursor-startBuf);
|
||||
SourceLocation caretLoc = LocStart.getLocWithOffset(cursor-startBuf);
|
||||
ReplaceText(caretLoc, 1, "*");
|
||||
}
|
||||
cursor++;
|
||||
}
|
||||
// Don't forget to add a ';'!!
|
||||
InsertText(LocEnd.getFileLocWithOffset(1), ";");
|
||||
InsertText(LocEnd.getLocWithOffset(1), ";");
|
||||
} else { // we don't have any instance variables - insert super struct.
|
||||
endBuf += Lexer::MeasureTokenLength(LocEnd, *SM, LangOpts);
|
||||
Result += " {\n struct ";
|
||||
|
@ -4926,7 +4926,7 @@ void RewriteObjC::RewriteCastExpr(CStyleCastExpr *CE) {
|
|||
switch (*argPtr) {
|
||||
case '^':
|
||||
// Replace the '^' with '*'.
|
||||
LocStart = LocStart.getFileLocWithOffset(argPtr-startBuf);
|
||||
LocStart = LocStart.getLocWithOffset(argPtr-startBuf);
|
||||
ReplaceText(LocStart, 1, "*");
|
||||
break;
|
||||
}
|
||||
|
@ -4946,7 +4946,7 @@ void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
|
|||
|
||||
parenCount++;
|
||||
// advance the location to startArgList.
|
||||
DeclLoc = DeclLoc.getFileLocWithOffset(startArgList-startBuf);
|
||||
DeclLoc = DeclLoc.getLocWithOffset(startArgList-startBuf);
|
||||
assert((DeclLoc.isValid()) && "Invalid DeclLoc");
|
||||
|
||||
const char *argPtr = startArgList;
|
||||
|
@ -4955,7 +4955,7 @@ void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
|
|||
switch (*argPtr) {
|
||||
case '^':
|
||||
// Replace the '^' with '*'.
|
||||
DeclLoc = DeclLoc.getFileLocWithOffset(argPtr-startArgList);
|
||||
DeclLoc = DeclLoc.getLocWithOffset(argPtr-startArgList);
|
||||
ReplaceText(DeclLoc, 1, "*");
|
||||
break;
|
||||
case '(':
|
||||
|
@ -5055,7 +5055,7 @@ void RewriteObjC::RewriteBlockPointerDecl(NamedDecl *ND) {
|
|||
// scan backward (from the decl location) for the end of the previous decl.
|
||||
while (*startBuf != '^' && *startBuf != ';' && startBuf != MainFileStart)
|
||||
startBuf--;
|
||||
SourceLocation Start = DeclLoc.getFileLocWithOffset(startBuf-endBuf);
|
||||
SourceLocation Start = DeclLoc.getLocWithOffset(startBuf-endBuf);
|
||||
std::string buf;
|
||||
unsigned OrigLength=0;
|
||||
// *startBuf != '^' if we are dealing with a pointer to function that
|
||||
|
@ -5326,7 +5326,7 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
|
|||
const char *semiBuf = strchr(startInitializerBuf, ';');
|
||||
assert((*semiBuf == ';') && "RewriteByRefVar: can't find ';'");
|
||||
SourceLocation semiLoc =
|
||||
startLoc.getFileLocWithOffset(semiBuf-startInitializerBuf);
|
||||
startLoc.getLocWithOffset(semiBuf-startInitializerBuf);
|
||||
|
||||
InsertText(semiLoc, "}");
|
||||
}
|
||||
|
|
|
@ -890,7 +890,7 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
|
|||
const char *SpecName = getSpecifierName(SC);
|
||||
|
||||
SourceLocation SCLoc = getStorageClassSpecLoc();
|
||||
SourceLocation SCEndLoc = SCLoc.getFileLocWithOffset(strlen(SpecName));
|
||||
SourceLocation SCEndLoc = SCLoc.getLocWithOffset(strlen(SpecName));
|
||||
|
||||
Diag(D, SCLoc, diag::err_friend_storage_spec)
|
||||
<< SpecName
|
||||
|
|
|
@ -1302,7 +1302,7 @@ getSpecifierRange(const char *startSpecifier, unsigned specifierLen) {
|
|||
SourceLocation End = getLocationOfByte(startSpecifier + specifierLen - 1);
|
||||
|
||||
// Advance the end SourceLocation by one due to half-open ranges.
|
||||
End = End.getFileLocWithOffset(1);
|
||||
End = End.getLocWithOffset(1);
|
||||
|
||||
return CharSourceRange::getCharRange(Start, End);
|
||||
}
|
||||
|
|
|
@ -7163,10 +7163,10 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
|
|||
UO->getOpcode() == UO_Minus) &&
|
||||
Loc.isFileID() && UO->getOperatorLoc().isFileID() &&
|
||||
// Only if the two operators are exactly adjacent.
|
||||
Loc.getFileLocWithOffset(1) == UO->getOperatorLoc() &&
|
||||
Loc.getLocWithOffset(1) == UO->getOperatorLoc() &&
|
||||
// And there is a space or other character before the subexpr of the
|
||||
// unary +/-. We don't want to warn on "x=-1".
|
||||
Loc.getFileLocWithOffset(2) != UO->getSubExpr()->getLocStart() &&
|
||||
Loc.getLocWithOffset(2) != UO->getSubExpr()->getLocStart() &&
|
||||
UO->getSubExpr()->getLocStart().isFileID()) {
|
||||
Diag(Loc, diag::warn_not_compound_assign)
|
||||
<< (UO->getOpcode() == UO_Plus ? "+" : "-")
|
||||
|
|
|
@ -1392,7 +1392,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
|
|||
ExprResult NewBase =
|
||||
ActOnCallExpr(0, BaseExpr.take(), ParenInsertionLoc,
|
||||
MultiExprArg(*this, 0, 0),
|
||||
ParenInsertionLoc.getFileLocWithOffset(1));
|
||||
ParenInsertionLoc.getLocWithOffset(1));
|
||||
if (NewBase.isInvalid())
|
||||
return ExprError();
|
||||
BaseExpr = NewBase;
|
||||
|
|
|
@ -323,7 +323,7 @@ bool PCHValidator::ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers,
|
|||
assert(MacroLoc.second!=StringRef::npos && "Unable to find macro!");
|
||||
SourceLocation PCHMissingLoc =
|
||||
SourceMgr.getLocForStartOfFile(MacroLoc.first)
|
||||
.getFileLocWithOffset(MacroLoc.second);
|
||||
.getLocWithOffset(MacroLoc.second);
|
||||
Reader.Diag(PCHMissingLoc, diag::note_pch_macro_defined_as) << MacroName;
|
||||
|
||||
ConflictingDefines = true;
|
||||
|
@ -346,7 +346,7 @@ bool PCHValidator::ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers,
|
|||
assert(MacroLoc.second!=StringRef::npos && "Unable to find macro!");
|
||||
SourceLocation PCHMissingLoc =
|
||||
SourceMgr.getLocForStartOfFile(MacroLoc.first)
|
||||
.getFileLocWithOffset(MacroLoc.second);
|
||||
.getLocWithOffset(MacroLoc.second);
|
||||
Reader.Diag(PCHMissingLoc, diag::note_using_macro_def_from_pch);
|
||||
}
|
||||
|
||||
|
|
|
@ -474,7 +474,7 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
|
|||
// Insert the new html.
|
||||
unsigned DisplayPos = LineEnd - FileStart;
|
||||
SourceLocation Loc =
|
||||
SM.getLocForStartOfFile(LPosInfo.first).getFileLocWithOffset(DisplayPos);
|
||||
SM.getLocForStartOfFile(LPosInfo.first).getLocWithOffset(DisplayPos);
|
||||
|
||||
R.InsertTextBefore(Loc, os.str());
|
||||
|
||||
|
@ -575,7 +575,7 @@ void HTMLDiagnostics::HighlightRange(Rewriter& R, FileID BugFileID,
|
|||
// selected range.
|
||||
|
||||
SourceLocation E =
|
||||
InstantiationEnd.getFileLocWithOffset(EndColNo - OldEndColNo);
|
||||
InstantiationEnd.getLocWithOffset(EndColNo - OldEndColNo);
|
||||
|
||||
html::HighlightRange(R, InstantiationStart, E, HighlightStart, HighlightEnd);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
|
|||
EndLoc = SM.getExpansionRange(EndLoc).second;
|
||||
if (R.isTokenRange() && !EndLoc.isInvalid() && EndLoc.isFileID()) {
|
||||
unsigned Length = Lexer::MeasureTokenLength(EndLoc, SM, LangOpts);
|
||||
EndLoc = EndLoc.getFileLocWithOffset(Length);
|
||||
EndLoc = EndLoc.getLocWithOffset(Length);
|
||||
}
|
||||
|
||||
CXSourceRange Result = { { (void *)&SM, (void *)&LangOpts },
|
||||
|
@ -2780,7 +2780,7 @@ CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu,
|
|||
1, 1);
|
||||
if (Start.isInvalid()) return clang_getNullLocation();
|
||||
|
||||
SourceLocation SLoc = Start.getFileLocWithOffset(offset);
|
||||
SourceLocation SLoc = Start.getLocWithOffset(offset);
|
||||
|
||||
if (SLoc.isInvalid()) return clang_getNullLocation();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче