diff options
Diffstat (limited to 'clang/lib/Rewrite')
-rw-r--r-- | clang/lib/Rewrite/HTMLRewrite.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Rewrite/RewriteObjC.cpp | 66 |
2 files changed, 34 insertions, 34 deletions
diff --git a/clang/lib/Rewrite/HTMLRewrite.cpp b/clang/lib/Rewrite/HTMLRewrite.cpp index ad2491c8fbd..3b781580bdf 100644 --- a/clang/lib/Rewrite/HTMLRewrite.cpp +++ b/clang/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/clang/lib/Rewrite/RewriteObjC.cpp b/clang/lib/Rewrite/RewriteObjC.cpp index 1b7fb2dfc42..fa287fd5349 100644 --- a/clang/lib/Rewrite/RewriteObjC.cpp +++ b/clang/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<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, "}"); } |