From a64ccefdf0ea4e03ec88805d71b0af74950c7472 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 19 Sep 2011 20:40:19 +0000 Subject: [PATCH] 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 --- include/clang/Basic/SourceLocation.h | 9 ++- include/clang/Serialization/ASTReader.h | 2 +- .../TransEmptyStatementsAndDealloc.cpp | 2 +- lib/ARCMigrate/TransformActions.cpp | 2 +- lib/ARCMigrate/Transforms.cpp | 2 +- lib/AST/ASTImporter.cpp | 2 +- lib/Basic/SourceManager.cpp | 16 ++--- lib/CodeGen/CodeGenAction.cpp | 2 +- lib/Frontend/VerifyDiagnosticsClient.cpp | 6 +- lib/Lex/Lexer.cpp | 20 +++--- lib/Lex/PPLexerChange.cpp | 2 +- lib/Lex/PTHLexer.cpp | 4 +- lib/Lex/ScratchBuffer.cpp | 2 +- lib/Lex/TokenConcatenation.cpp | 2 +- lib/Lex/TokenLexer.cpp | 4 +- lib/Parse/ParseExpr.cpp | 6 +- lib/Parse/ParseExprCXX.cpp | 4 +- lib/Rewrite/HTMLRewrite.cpp | 2 +- lib/Rewrite/RewriteObjC.cpp | 66 +++++++++---------- lib/Sema/DeclSpec.cpp | 2 +- lib/Sema/SemaChecking.cpp | 2 +- lib/Sema/SemaExpr.cpp | 4 +- lib/Sema/SemaExprMember.cpp | 2 +- lib/Serialization/ASTReader.cpp | 4 +- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp | 4 +- tools/libclang/CIndex.cpp | 4 +- 26 files changed, 88 insertions(+), 89 deletions(-) diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index 51734ef748..154148c16b 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -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; diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 1a4603d53a..cc5c1d76e0 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -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. diff --git a/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp b/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp index 0b3f4c3a65..3ad05e683c 100644 --- a/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp +++ b/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp @@ -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) diff --git a/lib/ARCMigrate/TransformActions.cpp b/lib/ARCMigrate/TransformActions.cpp index 65623a1b31..1321686ca6 100644 --- a/lib/ARCMigrate/TransformActions.cpp +++ b/lib/ARCMigrate/TransformActions.cpp @@ -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); diff --git a/lib/ARCMigrate/Transforms.cpp b/lib/ARCMigrate/Transforms.cpp index 01af5f6957..4244fafe07 100644 --- a/lib/ARCMigrate/Transforms.cpp +++ b/lib/ARCMigrate/Transforms.cpp @@ -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 diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 7174dbe867..cee63b951d 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -4299,7 +4299,7 @@ SourceLocation ASTImporter::Import(SourceLocation FromLoc) { std::pair 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) { diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 0e0ed2aa69..5fe1b19098 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -802,7 +802,7 @@ SourceLocation SourceManager::getSpellingLocSlowCase(SourceLocation Loc) const { do { std::pair 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 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; } diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index fc1bd5ee2f..55f3cbe270 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/lib/CodeGen/CodeGenAction.cpp @@ -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); } diff --git a/lib/Frontend/VerifyDiagnosticsClient.cpp b/lib/Frontend/VerifyDiagnosticsClient.cpp index f53e0dac23..69eb887843 100644 --- a/lib/Frontend/VerifyDiagnosticsClient.cpp +++ b/lib/Frontend/VerifyDiagnosticsClient.cpp @@ -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; } diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 2135cd4fb8..563248877e 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -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 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(); } diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index d52220798e..921218208c 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/lib/Lex/PPLexerChange.cpp @@ -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); diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index 02af1ec27e..3fd4b55bbd 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -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); } //===----------------------------------------------------------------------===// diff --git a/lib/Lex/ScratchBuffer.cpp b/lib/Lex/ScratchBuffer.cpp index 0e98c17519..3d363fa4b4 100644 --- a/lib/Lex/ScratchBuffer.cpp +++ b/lib/Lex/ScratchBuffer.cpp @@ -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) { diff --git a/lib/Lex/TokenConcatenation.cpp b/lib/Lex/TokenConcatenation.cpp index 2940b52d68..dc6d686d6c 100644 --- a/lib/Lex/TokenConcatenation.cpp +++ b/lib/Lex/TokenConcatenation.cpp @@ -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; diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 7ea28bf20c..9618711d6c 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -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)); } } diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 9c0ab6171c..f1c6d1256d 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -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 = ":"; } } diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 88abce9c5e..89953fd3d8 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -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); diff --git a/lib/Rewrite/HTMLRewrite.cpp b/lib/Rewrite/HTMLRewrite.cpp index ad2491c8fb..3b781580bd 100644 --- a/lib/Rewrite/HTMLRewrite.cpp +++ b/lib/Rewrite/HTMLRewrite.cpp @@ -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); diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 1b7fb2dfc4..fa287fd534 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -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(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, "}"); } diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 7278922967..fad1199613 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -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 diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index aecc659485..cda4d92d2f 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -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); } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 9fb0ac211f..8bbfa7270f 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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 ? "+" : "-") diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp index 0914890466..1344e247cf 100644 --- a/lib/Sema/SemaExprMember.cpp +++ b/lib/Sema/SemaExprMember.cpp @@ -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; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 30e3c8cb92..0c23431b94 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -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); } diff --git a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index 2b377d0078..e644c30d11 100644 --- a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -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); } diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 25434164f4..3654a58a5d 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -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(); -- 2.40.0