]> granicus.if.org Git - clang/commitdiff
Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 19 Sep 2011 20:40:19 +0000 (20:40 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 19 Sep 2011 20:40:19 +0000 (20:40 +0000)
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

26 files changed:
include/clang/Basic/SourceLocation.h
include/clang/Serialization/ASTReader.h
lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
lib/ARCMigrate/TransformActions.cpp
lib/ARCMigrate/Transforms.cpp
lib/AST/ASTImporter.cpp
lib/Basic/SourceManager.cpp
lib/CodeGen/CodeGenAction.cpp
lib/Frontend/VerifyDiagnosticsClient.cpp
lib/Lex/Lexer.cpp
lib/Lex/PPLexerChange.cpp
lib/Lex/PTHLexer.cpp
lib/Lex/ScratchBuffer.cpp
lib/Lex/TokenConcatenation.cpp
lib/Lex/TokenLexer.cpp
lib/Parse/ParseExpr.cpp
lib/Parse/ParseExprCXX.cpp
lib/Rewrite/HTMLRewrite.cpp
lib/Rewrite/RewriteObjC.cpp
lib/Sema/DeclSpec.cpp
lib/Sema/SemaChecking.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprMember.cpp
lib/Serialization/ASTReader.cpp
lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
tools/libclang/CIndex.cpp

index 51734ef748d2b636278f4ad29be6c05cf47f7187..154148c16b03c70cca86ed709efdd8fbdb2e10e6 100644 (file)
@@ -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;
index 1a4603d53ac5a190ebb0e0f8390fef1c25152b6f..cc5c1d76e0e066f3405cbc20ed39e5b2e6311973 100644 (file)
@@ -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.
index 0b3f4c3a65660bb8d17f548b18d424400d221a84..3ad05e683c7885ecd8b75f0d7e5638fe1b9320a0 100644 (file)
@@ -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)
index 65623a1b313abfa8c716cd6669de8800d4dd8dfe..1321686ca662228bce79b66637acf8c04d532887 100644 (file)
@@ -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);  
index 01af5f695787f079d97c1ce4fa853e8f3dd30a1d..4244fafe07d494d277876955916a618050cc387e 100644 (file)
@@ -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
index 7174dbe8675f5981aa71975d7abebfde10d4ef9b..cee63b951dc8ccd66c8c0e9babc3e6f2194fd8bf 100644 (file)
@@ -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) {
index 0e0ed2aa69597c908de07cafeb8c0f965e884499..5fe1b190985f95eda28f17c47d34534397e612c0 100644 (file)
@@ -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;
 }
index fc1bd5ee2fb3e5cf46374db641f084bf2eaf9d49..55f3cbe270398b65f4f7808e06e7e4d9d6e4c82b 100644 (file)
@@ -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);
 }
 
index f53e0dac2345ace1758af3feb3843054c9e1481b..69eb887843cb67fd5d70036427b131d0e66312e1 100644 (file)
@@ -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;
     }
index 2135cd4fb8f7e5fc2255942de3fe28d3ea646b19..563248877e4834add284a5eafe3f03122a663b6a 100644 (file)
@@ -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();
   }
 
index d52220798e066d8f4b3c363d4377fac40e8792fa..921218208c9f7881e1aa59c23e5771fd61e97598 100644 (file)
@@ -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);
index 02af1ec27eda8dc25cae745282d6672cdf542a16..3fd4b55bbdf10c714f06689adc80620c31a2976d 100644 (file)
@@ -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);
 }
 
 //===----------------------------------------------------------------------===//
index 0e98c1751985522a5ee478f4ff4b8729972990a6..3d363fa4b472675df1142311df0ab95c1e9f1809 100644 (file)
@@ -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) {
index 2940b52d68e200a2aca7735fc0fe25150b083582..dc6d686d6cc1097b7b2529a43291e34009829b3e 100644 (file)
@@ -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;
 
index 7ea28bf20c9148714ade666a6f7ece1e2b3a3995..9618711d6cb87c0dd575a28c3c0f7e768a618200 100644 (file)
@@ -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));
   }
 }
 
index 9c0ab6171c1d4e38851cec289dc79b7651a58ae5..f1c6d1256d4c17e067e28a6094cdbc2ecd404713 100644 (file)
@@ -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 = ":";
             }
           }
index 88abce9c5e2fe45e744c2f18800a084ad30f9b35..89953fd3d8cfd1feb38a807d33c5c3a6d5c847a2 100644 (file)
@@ -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);
index ad2491c8fbd36c82557040e868099521c2b21d33..3b781580bdfde5d6136c5d4ba4566bce0308314f 100644 (file)
@@ -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);
index 1b7fb2dfc42214fd0d9bfc259b2b94acf017d39c..fa287fd53496d8e6caacba0241edcab93feb9363 100644 (file)
@@ -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, "}");
   }
index 7278922967c53e64788d7a4723488c67df983975..fad1199613ed7471fc981e09bfed35f3e9c100d8 100644 (file)
@@ -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
index aecc659485dfdca244a703a3e099f15f8ee6b32b..cda4d92d2f5adda313e3ddb1df6340abf1d7e0e5 100644 (file)
@@ -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);
 }
index 9fb0ac211f207cb1d2ae86a4fafc5b59cb808459..8bbfa7270f6c5d9f4fabd7a8dc5e937b0e7df79d 100644 (file)
@@ -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 ? "+" : "-")
index 09148904665224b036bdc42065088ae7ecd21df5..1344e247cfd07a690f75ea863bbd0b1c1bc3e59a 100644 (file)
@@ -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;
index 30e3c8cb920482e427bd4510425aa470b6cf8702..0c23431b940df389014584e5304c7b10c9e06a72 100644 (file)
@@ -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);
   }
 
index 2b377d0078ee31df5f57bab3c9d914174c8dcd1e..e644c30d112327a1a994c7acb0782df7fe4f5353 100644 (file)
@@ -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);
 }
index 25434164f49ca0694c1c3619a476f7a43d3f3f46..3654a58a5d4f21a2d51044306261cfb9baa89e3c 100644 (file)
@@ -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();