35 changes: 18 additions & 17 deletions clang/include/clang/AST/Stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ class CaseStmt : public SwitchCase {
while (const auto *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
CS = CS2;

return CS->getSubStmt()->getLocEnd();
return CS->getSubStmt()->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand Down Expand Up @@ -853,7 +853,7 @@ class DefaultStmt : public SwitchCase {
SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubStmt->getLocEnd();
return SubStmt->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand All @@ -866,8 +866,8 @@ class DefaultStmt : public SwitchCase {

inline SourceLocation SwitchCase::getEndLoc() const {
if (const auto *CS = dyn_cast<CaseStmt>(this))
return CS->getLocEnd();
return cast<DefaultStmt>(this)->getLocEnd();
return CS->getEndLoc();
return cast<DefaultStmt>(this)->getEndLoc();
}

/// LabelStmt - Represents a label, which has a substatement. For example:
Expand Down Expand Up @@ -901,7 +901,7 @@ class LabelStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return IdentLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubStmt->getLocEnd();
return SubStmt->getEndLoc();
}

child_range children() { return child_range(&SubStmt, &SubStmt+1); }
Expand Down Expand Up @@ -960,7 +960,7 @@ class AttributedStmt final
SourceLocation getBeginLoc() const LLVM_READONLY { return AttrLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubStmt->getLocEnd();
return SubStmt->getEndLoc();
}

child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
Expand Down Expand Up @@ -1034,9 +1034,9 @@ class IfStmt : public Stmt {
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
if (SubExprs[ELSE])
return SubExprs[ELSE]->getLocEnd();
return SubExprs[ELSE]->getEndLoc();
else
return SubExprs[THEN]->getLocEnd();
return SubExprs[THEN]->getEndLoc();
}

// Iterators over subexpressions. The iterators will include iterating
Expand Down Expand Up @@ -1130,7 +1130,8 @@ class SwitchStmt : public Stmt {

SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubExprs[BODY] ? SubExprs[BODY]->getLocEnd() : SubExprs[COND]->getLocEnd();
return SubExprs[BODY] ? SubExprs[BODY]->getEndLoc()
: SubExprs[COND]->getEndLoc();
}

// Iterators
Expand Down Expand Up @@ -1188,7 +1189,7 @@ class WhileStmt : public Stmt {

SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
return SubExprs[BODY]->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand Down Expand Up @@ -1312,7 +1313,7 @@ class ForStmt : public Stmt {

SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
return SubExprs[BODY]->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand Down Expand Up @@ -1396,7 +1397,7 @@ class IndirectGotoStmt : public Stmt {
SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
SourceLocation getBeginLoc() const LLVM_READONLY { return GotoLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY { return Target->getLocEnd(); }
SourceLocation getEndLoc() const LLVM_READONLY { return Target->getEndLoc(); }

static bool classof(const Stmt *T) {
return T->getStmtClass() == IndirectGotoStmtClass;
Expand Down Expand Up @@ -1508,7 +1509,7 @@ class ReturnStmt : public Stmt {

SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return RetExpr ? RetExpr->getLocEnd() : RetLoc;
return RetExpr ? RetExpr->getEndLoc() : RetLoc;
}

static bool classof(const Stmt *T) {
Expand Down Expand Up @@ -1982,7 +1983,7 @@ class SEHExceptStmt : public Stmt {
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }

SourceLocation getExceptLoc() const { return Loc; }
SourceLocation getEndLoc() const { return getBlock()->getLocEnd(); }
SourceLocation getEndLoc() const { return getBlock()->getEndLoc(); }

Expr *getFilterExpr() const {
return reinterpret_cast<Expr*>(Children[FILTER_EXPR]);
Expand Down Expand Up @@ -2021,7 +2022,7 @@ class SEHFinallyStmt : public Stmt {
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }

SourceLocation getFinallyLoc() const { return Loc; }
SourceLocation getEndLoc() const { return Block->getLocEnd(); }
SourceLocation getEndLoc() const { return Block->getEndLoc(); }

CompoundStmt *getBlock() const { return cast<CompoundStmt>(Block); }

Expand Down Expand Up @@ -2061,7 +2062,7 @@ class SEHTryStmt : public Stmt {
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }

SourceLocation getTryLoc() const { return TryLoc; }
SourceLocation getEndLoc() const { return Children[HANDLER]->getLocEnd(); }
SourceLocation getEndLoc() const { return Children[HANDLER]->getEndLoc(); }

bool getIsCXXTry() const { return IsCXXTry; }

Expand Down Expand Up @@ -2321,7 +2322,7 @@ class CapturedStmt : public Stmt {

SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return getCapturedStmt()->getLocEnd();
return getCapturedStmt()->getEndLoc();
}

SourceRange getSourceRange() const LLVM_READONLY {
Expand Down
12 changes: 6 additions & 6 deletions clang/include/clang/AST/StmtCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CXXCatchStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return CatchLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return HandlerBlock->getLocEnd();
return HandlerBlock->getEndLoc();
}

SourceLocation getCatchLoc() const { return CatchLoc; }
Expand Down Expand Up @@ -94,7 +94,7 @@ class CXXTryStmt final : public Stmt,

SourceLocation getTryLoc() const { return TryLoc; }
SourceLocation getEndLoc() const {
return getStmts()[NumHandlers]->getLocEnd();
return getStmts()[NumHandlers]->getEndLoc();
}

CompoundStmt *getTryBlock() {
Expand Down Expand Up @@ -201,7 +201,7 @@ class CXXForRangeStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return ForLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
return SubExprs[BODY]->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand Down Expand Up @@ -289,7 +289,7 @@ class MSDependentExistsStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return KeywordLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubStmt->getLocEnd();
return SubStmt->getEndLoc();
}

child_range children() {
Expand Down Expand Up @@ -415,7 +415,7 @@ class CoroutineBodyStmt final
}
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return getBody() ? getBody()->getLocEnd() : getPromiseDecl()->getLocEnd();
return getBody() ? getBody()->getEndLoc() : getPromiseDecl()->getEndLoc();
}

child_range children() {
Expand Down Expand Up @@ -479,7 +479,7 @@ class CoreturnStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return CoreturnLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return getOperand() ? getOperand()->getLocEnd() : getBeginLoc();
return getOperand() ? getOperand()->getEndLoc() : getBeginLoc();
}

child_range children() {
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/StmtDataCollectors.td
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Stmt {
// This ensures that non-macro-generated code isn't identical to
// macro-generated code.
addData(data_collection::getMacroStack(S->getBeginLoc(), Context));
addData(data_collection::getMacroStack(S->getLocEnd(), Context));
addData(data_collection::getMacroStack(S->getEndLoc(), Context));
}];
}

Expand Down
12 changes: 6 additions & 6 deletions clang/include/clang/AST/StmtObjC.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ObjCForCollectionStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return ForLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
return SubExprs[BODY]->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand Down Expand Up @@ -109,7 +109,7 @@ class ObjCAtCatchStmt : public Stmt {
SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
SourceLocation getBeginLoc() const LLVM_READONLY { return AtCatchLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY { return Body->getLocEnd(); }
SourceLocation getEndLoc() const LLVM_READONLY { return Body->getEndLoc(); }

bool hasEllipsis() const { return getCatchParamDecl() == nullptr; }

Expand Down Expand Up @@ -141,7 +141,7 @@ class ObjCAtFinallyStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return AtFinallyLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return AtFinallyStmt->getLocEnd();
return AtFinallyStmt->getEndLoc();
}

SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; }
Expand Down Expand Up @@ -307,7 +307,7 @@ class ObjCAtSynchronizedStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return AtSynchronizedLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return getSynchBody()->getLocEnd();
return getSynchBody()->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand Down Expand Up @@ -343,7 +343,7 @@ class ObjCAtThrowStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return AtThrowLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return Throw ? Throw->getLocEnd() : AtThrowLoc;
return Throw ? Throw->getEndLoc() : AtThrowLoc;
}

static bool classof(const Stmt *T) {
Expand Down Expand Up @@ -373,7 +373,7 @@ class ObjCAutoreleasePoolStmt : public Stmt {
SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return SubStmt->getLocEnd();
return SubStmt->getEndLoc();
}

SourceLocation getAtLoc() const { return AtLoc; }
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Sema/Initialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,8 @@ class InitializationKind {
if (!DirectInit)
return CreateCopy(Loc, Init->getBeginLoc());
if (isa<InitListExpr>(Init))
return CreateDirectList(Loc, Init->getBeginLoc(), Init->getLocEnd());
return CreateDirect(Loc, Init->getBeginLoc(), Init->getLocEnd());
return CreateDirectList(Loc, Init->getBeginLoc(), Init->getEndLoc());
return CreateDirect(Loc, Init->getBeginLoc(), Init->getEndLoc());
}

/// Determine the initialization kind.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ class CXXDestructorCall : public CXXInstanceCall {
ProgramStateRef St, const LocationContext *LCtx)
: CXXInstanceCall(DD, St, LCtx) {
Data = DtorDataTy(Target, IsBaseDestructor).getOpaqueValue();
Location = Trigger->getLocEnd();
Location = Trigger->getEndLoc();
}

CXXDestructorCall(const CXXDestructorCall &Other) = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class RecursiveSymbolVisitor
for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) {
const OffsetOfNode &Component = S->getComponent(I);
if (Component.getKind() == OffsetOfNode::Field) {
if (!visit(Component.getField(), Component.getLocEnd()))
if (!visit(Component.getField(), Component.getEndLoc()))
return false;
}
// FIXME: Try to resolve dependent field references.
Expand Down
33 changes: 17 additions & 16 deletions clang/lib/ARCMigrate/ObjCMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ namespace {
if (IsGetter) {
// Find space location range between receiver expression and getter method.
SourceLocation BegLoc =
ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getLocEnd();
ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc();
BegLoc = PP.getLocForEndOfToken(BegLoc);
SourceLocation EndLoc = Msg->getSelectorLoc(0);
SourceRange SpaceRange(BegLoc, EndLoc);
Expand Down Expand Up @@ -291,7 +291,7 @@ namespace {
if (!RHS)
return false;
SourceLocation BegLoc =
ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getLocEnd();
ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc();
BegLoc = PP.getLocForEndOfToken(BegLoc);
SourceLocation EndLoc = RHS->getBeginLoc();
EndLoc = EndLoc.getLocWithOffset(-1);
Expand Down Expand Up @@ -722,7 +722,7 @@ static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
ClassString += ')';
SourceRange R(EnumDcl->getBeginLoc(), EnumDcl->getBeginLoc());
commit.replace(R, ClassString);
SourceLocation EndOfEnumDclLoc = EnumDcl->getLocEnd();
SourceLocation EndOfEnumDclLoc = EnumDcl->getEndLoc();
EndOfEnumDclLoc = trans::findSemiAfterLocation(EndOfEnumDclLoc,
NS.getASTContext(), /*IsDecl*/true);
if (EndOfEnumDclLoc.isValid()) {
Expand All @@ -732,7 +732,7 @@ static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
else
return false;

SourceLocation EndTypedefDclLoc = TypedefDcl->getLocEnd();
SourceLocation EndTypedefDclLoc = TypedefDcl->getEndLoc();
EndTypedefDclLoc = trans::findSemiAfterLocation(EndTypedefDclLoc,
NS.getASTContext(), /*IsDecl*/true);
if (EndTypedefDclLoc.isValid()) {
Expand All @@ -742,8 +742,9 @@ static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
else
return false;

EndOfEnumDclLoc = trans::findLocationAfterSemi(EnumDcl->getLocEnd(), NS.getASTContext(),
/*IsDecl*/true);
EndOfEnumDclLoc =
trans::findLocationAfterSemi(EnumDcl->getEndLoc(), NS.getASTContext(),
/*IsDecl*/ true);
if (EndOfEnumDclLoc.isValid()) {
SourceLocation BeginOfEnumDclLoc = EnumDcl->getBeginLoc();
// FIXME. This assumes that enum decl; is immediately preceded by eoln.
Expand Down Expand Up @@ -779,9 +780,9 @@ static void rewriteToNSMacroDecl(ASTContext &Ctx,
CharSourceRange::getCharRange(EnumDcl->getBeginLoc(), EndLoc);
commit.replace(R, ClassString);
// This is to remove spaces between '}' and typedef name.
SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
SourceLocation StartTypedefLoc = EnumDcl->getEndLoc();
StartTypedefLoc = StartTypedefLoc.getLocWithOffset(+1);
SourceLocation EndTypedefLoc = TypedefDcl->getLocEnd();
SourceLocation EndTypedefLoc = TypedefDcl->getEndLoc();

commit.remove(SourceRange(StartTypedefLoc, EndTypedefLoc));
}
Expand Down Expand Up @@ -812,7 +813,7 @@ static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx,
}
if (AllHexdecimalEnumerator && EnumVal) {
bool FoundHexdecimalEnumerator = false;
SourceLocation EndLoc = Enumerator->getLocEnd();
SourceLocation EndLoc = Enumerator->getEndLoc();
Token Tok;
if (!PP.getRawToken(EndLoc, Tok, /*IgnoreWhiteSpace=*/true))
if (Tok.isLiteral() && Tok.getLength() > 2) {
Expand Down Expand Up @@ -1258,7 +1259,7 @@ void ObjCMigrateASTConsumer::migrateNsReturnsInnerPointer(ASTContext &Ctx,
return;

edit::Commit commit(*Editor);
commit.insertBefore(OM->getLocEnd(), " NS_RETURNS_INNER_POINTER");
commit.insertBefore(OM->getEndLoc(), " NS_RETURNS_INNER_POINTER");
Editor->commit(commit);
}

Expand All @@ -1270,7 +1271,7 @@ void ObjCMigrateASTConsumer::migratePropertyNsReturnsInnerPointer(ASTContext &Ct
!NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER"))
return;
edit::Commit commit(*Editor);
commit.insertBefore(P->getLocEnd(), " NS_RETURNS_INNER_POINTER ");
commit.insertBefore(P->getEndLoc(), " NS_RETURNS_INNER_POINTER ");
Editor->commit(commit);
}

Expand Down Expand Up @@ -1398,7 +1399,7 @@ void ObjCMigrateASTConsumer::AnnotateImplicitBridging(ASTContext &Ctx) {
edit::Commit commit(*Editor);
commit.insertBefore(FirstFD->getBeginLoc(), PragmaString);
PragmaString = "\n\nCF_IMPLICIT_BRIDGING_DISABLED\n";
SourceLocation EndLoc = LastFD->getLocEnd();
SourceLocation EndLoc = LastFD->getEndLoc();
// get location just past end of function location.
EndLoc = PP.getLocForEndOfToken(EndLoc);
if (isa<FunctionDecl>(LastFD)) {
Expand Down Expand Up @@ -1473,7 +1474,7 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,

if (AnnotationString) {
edit::Commit commit(*Editor);
commit.insertAfterToken(FuncDecl->getLocEnd(), AnnotationString);
commit.insertAfterToken(FuncDecl->getEndLoc(), AnnotationString);
Editor->commit(commit);
}
}
Expand Down Expand Up @@ -1599,7 +1600,7 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,

if (AnnotationString) {
edit::Commit commit(*Editor);
commit.insertBefore(MethodDecl->getLocEnd(), AnnotationString);
commit.insertBefore(MethodDecl->getEndLoc(), AnnotationString);
Editor->commit(commit);
}
}
Expand Down Expand Up @@ -1637,7 +1638,7 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
MethodDecl->getMethodFamily() != OMF_release &&
NSAPIObj->isMacroDefined("NS_CONSUMES_SELF")) {
edit::Commit commit(*Editor);
commit.insertBefore(MethodDecl->getLocEnd(), " NS_CONSUMES_SELF");
commit.insertBefore(MethodDecl->getEndLoc(), " NS_CONSUMES_SELF");
Editor->commit(commit);
}

Expand Down Expand Up @@ -1714,7 +1715,7 @@ void ObjCMigrateASTConsumer::inferDesignatedInitializers(
continue;
if (hasSuperInitCall(MD)) {
edit::Commit commit(*Editor);
commit.insert(IFaceM->getLocEnd(), " NS_DESIGNATED_INITIALIZER");
commit.insert(IFaceM->getEndLoc(), " NS_DESIGNATED_INITIALIZER");
Editor->commit(commit);
}
}
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/ARCMigrate/TransAutoreleasePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ class AutoreleasePoolRewriter
Pass.TA.removeStmt(*scope.End);
Stmt::child_iterator retI = scope.End;
++retI;
SourceLocation afterSemi = findLocationAfterSemi((*retI)->getLocEnd(),
Pass.Ctx);
SourceLocation afterSemi =
findLocationAfterSemi((*retI)->getEndLoc(), Pass.Ctx);
assert(afterSemi.isValid() &&
"Didn't we check before setting IsFollowedBySimpleReturnStmt "
"to true?");
Pass.TA.insertAfterToken(afterSemi, "\n}");
Pass.TA.increaseIndentation(
SourceRange(scope.getIndentedRange().getBegin(),
(*retI)->getLocEnd()),
(*retI)->getEndLoc()),
scope.CompoundParent->getBeginLoc());
} else {
Pass.TA.replaceStmt(*scope.Begin, "@autoreleasepool {");
Expand Down Expand Up @@ -241,7 +241,7 @@ class AutoreleasePoolRewriter
Stmt::child_iterator rangeE = Begin;
for (Stmt::child_iterator I = rangeS; I != End; ++I)
++rangeE;
return SourceRange((*rangeS)->getBeginLoc(), (*rangeE)->getLocEnd());
return SourceRange((*rangeS)->getBeginLoc(), (*rangeE)->getEndLoc());
}
};

Expand Down Expand Up @@ -307,7 +307,7 @@ class AutoreleasePoolRewriter
if (ReturnStmt *retS = dyn_cast<ReturnStmt>(*SI))
if ((retS->getRetValue() == nullptr ||
isa<DeclRefExpr>(retS->getRetValue()->IgnoreParenCasts())) &&
findLocationAfterSemi(retS->getLocEnd(), Pass.Ctx).isValid()) {
findLocationAfterSemi(retS->getEndLoc(), Pass.Ctx).isValid()) {
scope.IsFollowedBySimpleReturnStmt = true;
++SI; // the return will be included in scope, don't check it.
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/ARCMigrate/TransProtectedScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CaseCollector : public RecursiveASTVisitor<CaseCollector> {
Curr = Curr->getNextSwitchCase();
}

SourceLocation NextLoc = S->getLocEnd();
SourceLocation NextLoc = S->getEndLoc();
Curr = S->getSwitchCaseList();
// We iterate over case statements in reverse source-order.
while (Curr) {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class UnbridgedCastRewriter : public RecursiveASTVisitor<UnbridgedCastRewriter>{
} else {
newCast += '(';
TA.insert(insertLoc, newCast.str());
TA.insertAfterToken(E->getLocEnd(), ")");
TA.insertAfterToken(E->getEndLoc(), ")");
}
}
} else {
Expand All @@ -267,7 +267,7 @@ class UnbridgedCastRewriter : public RecursiveASTVisitor<UnbridgedCastRewriter>{
} else {
BridgeCall += '(';
TA.insert(InsertLoc, BridgeCall);
TA.insertAfterToken(WrapE->getLocEnd(), ")");
TA.insertAfterToken(WrapE->getEndLoc(), ")");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ void ASTDumper::VisitOMPExecutableDirective(
<< ClauseName.drop_front() << "Clause";
}
dumpPointer(C);
dumpSourceRange(SourceRange(C->getBeginLoc(), C->getLocEnd()));
dumpSourceRange(SourceRange(C->getBeginLoc(), C->getEndLoc()));
if (C->isImplicit())
OS << " <implicit>";
for (auto *S : C->children())
Expand Down
34 changes: 15 additions & 19 deletions clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2755,7 +2755,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
ToFunction->setVirtualAsWritten(D->isVirtualAsWritten());
ToFunction->setTrivial(D->isTrivial());
ToFunction->setPure(D->isPure());
ToFunction->setRangeEnd(Importer.Import(D->getLocEnd()));
ToFunction->setRangeEnd(Importer.Import(D->getEndLoc()));

// Set the parameters.
for (auto *Param : Parameters) {
Expand Down Expand Up @@ -3409,7 +3409,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
ObjCMethodDecl *ToMethod;
if (GetImportedOrCreateDecl(
ToMethod, D, Importer.getToContext(), Loc,
Importer.Import(D->getLocEnd()), Name.getObjCSelector(), ResultTy,
Importer.Import(D->getEndLoc()), Name.getObjCSelector(), ResultTy,
ReturnTInfo, DC, D->isInstanceMethod(), D->isVariadic(),
D->isPropertyAccessor(), D->isImplicit(), D->isDefined(),
D->getImplementationControl(), D->hasRelatedResultType()))
Expand Down Expand Up @@ -5862,7 +5862,7 @@ Expr *ASTNodeImporter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {

return new (Importer.getToContext()) ArrayTypeTraitExpr(
Importer.Import(E->getBeginLoc()), E->getTrait(), ToQueried,
E->getValue(), Dim, Importer.Import(E->getLocEnd()), T);
E->getValue(), Dim, Importer.Import(E->getEndLoc()), T);
}

Expr *ASTNodeImporter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
Expand All @@ -5876,7 +5876,7 @@ Expr *ASTNodeImporter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {

return new (Importer.getToContext()) ExpressionTraitExpr(
Importer.Import(E->getBeginLoc()), E->getTrait(), ToQueried,
E->getValue(), Importer.Import(E->getLocEnd()), T);
E->getValue(), Importer.Import(E->getEndLoc()), T);
}

Expr *ASTNodeImporter::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
Expand Down Expand Up @@ -6062,7 +6062,7 @@ Expr *ASTNodeImporter::VisitOffsetOfExpr(OffsetOfExpr *OE) {
case OffsetOfNode::Array:
Nodes.push_back(OffsetOfNode(Importer.Import(Node.getBeginLoc()),
Node.getArrayExprIndex(),
Importer.Import(Node.getLocEnd())));
Importer.Import(Node.getEndLoc())));
break;

case OffsetOfNode::Base: {
Expand All @@ -6077,15 +6077,15 @@ Expr *ASTNodeImporter::VisitOffsetOfExpr(OffsetOfExpr *OE) {
if (!FD)
return nullptr;
Nodes.push_back(OffsetOfNode(Importer.Import(Node.getBeginLoc()), FD,
Importer.Import(Node.getLocEnd())));
Importer.Import(Node.getEndLoc())));
break;
}
case OffsetOfNode::Identifier: {
IdentifierInfo *ToII = Importer.Import(Node.getFieldName());
if (!ToII)
return nullptr;
Nodes.push_back(OffsetOfNode(Importer.Import(Node.getBeginLoc()), ToII,
Importer.Import(Node.getLocEnd())));
Importer.Import(Node.getEndLoc())));
break;
}
}
Expand Down Expand Up @@ -6126,7 +6126,7 @@ Expr *ASTNodeImporter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {

return new (Importer.getToContext())
CXXNoexceptExpr(T, Operand, CanThrow, Importer.Import(E->getBeginLoc()),
Importer.Import(E->getLocEnd()));
Importer.Import(E->getEndLoc()));
}

Expr *ASTNodeImporter::VisitCXXThrowExpr(CXXThrowExpr *E) {
Expand Down Expand Up @@ -6729,16 +6729,12 @@ Expr *ASTNodeImporter::VisitLambdaExpr(LambdaExpr *LE) {
if (ImportContainerChecked(LE->capture_inits(), InitCaptures))
return nullptr;

return LambdaExpr::Create(Importer.getToContext(), ToClass,
Importer.Import(LE->getIntroducerRange()),
LE->getCaptureDefault(),
Importer.Import(LE->getCaptureDefaultLoc()),
Captures,
LE->hasExplicitParameters(),
LE->hasExplicitResultType(),
InitCaptures,
Importer.Import(LE->getLocEnd()),
LE->containsUnexpandedParameterPack());
return LambdaExpr::Create(
Importer.getToContext(), ToClass,
Importer.Import(LE->getIntroducerRange()), LE->getCaptureDefault(),
Importer.Import(LE->getCaptureDefaultLoc()), Captures,
LE->hasExplicitParameters(), LE->hasExplicitResultType(), InitCaptures,
Importer.Import(LE->getEndLoc()), LE->containsUnexpandedParameterPack());
}

Expr *ASTNodeImporter::VisitInitListExpr(InitListExpr *ILE) {
Expand Down Expand Up @@ -6917,7 +6913,7 @@ Expr *ASTNodeImporter::VisitTypeTraitExpr(TypeTraitExpr *E) {

return TypeTraitExpr::Create(
Importer.getToContext(), ToType, Importer.Import(E->getBeginLoc()),
E->getTrait(), ToArgs, Importer.Import(E->getLocEnd()), ToValue);
E->getTrait(), ToArgs, Importer.Import(E->getEndLoc()), ToValue);
}

Expr *ASTNodeImporter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/AST/CommentSema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,9 @@ void Sema::checkDeprecatedCommand(const BlockCommandComment *Command) {

SmallString<64> TextToInsert(" ");
TextToInsert += AttributeSpelling;
Diag(FD->getLocEnd(),
diag::note_add_deprecation_attr)
<< FixItHint::CreateInsertion(FD->getLocEnd().getLocWithOffset(1),
TextToInsert);
Diag(FD->getEndLoc(), diag::note_add_deprecation_attr)
<< FixItHint::CreateInsertion(FD->getEndLoc().getLocWithOffset(1),
TextToInsert);
}
}

Expand Down
10 changes: 5 additions & 5 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ VarDecl::TLSKind VarDecl::getTLSKind() const {

SourceRange VarDecl::getSourceRange() const {
if (const Expr *Init = getInit()) {
SourceLocation InitEnd = Init->getLocEnd();
SourceLocation InitEnd = Init->getEndLoc();
// If Init is implicit, ignore its source range and fallback on
// DeclaratorDecl::getSourceRange() to handle postfix elements.
if (InitEnd.isValid() && InitEnd != getLocation())
Expand Down Expand Up @@ -2704,7 +2704,7 @@ Stmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const {
void FunctionDecl::setBody(Stmt *B) {
Body = B;
if (B)
EndRangeLoc = B->getLocEnd();
EndRangeLoc = B->getEndLoc();
}

void FunctionDecl::setPure(bool P) {
Expand Down Expand Up @@ -3781,7 +3781,7 @@ SourceRange FieldDecl::getSourceRange() const {
if (!FinalExpr)
FinalExpr = getBitWidth();
if (FinalExpr)
return SourceRange(getInnerLocStart(), FinalExpr->getLocEnd());
return SourceRange(getInnerLocStart(), FinalExpr->getEndLoc());
return DeclaratorDecl::getSourceRange();
}

Expand Down Expand Up @@ -4258,7 +4258,7 @@ bool BlockDecl::capturesVariable(const VarDecl *variable) const {
}

SourceRange BlockDecl::getSourceRange() const {
return SourceRange(getLocation(), Body? Body->getLocEnd() : getLocation());
return SourceRange(getLocation(), Body ? Body->getEndLoc() : getLocation());
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -4474,7 +4474,7 @@ IndirectFieldDecl *IndirectFieldDecl::CreateDeserialized(ASTContext &C,
SourceRange EnumConstantDecl::getSourceRange() const {
SourceLocation End = getLocation();
if (Init)
End = Init->getLocEnd();
End = Init->getEndLoc();
return SourceRange(getLocation(), End);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/DeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {

SourceLocation ObjCMethodDecl::getEndLoc() const {
if (Stmt *Body = getBody())
return Body->getLocEnd();
return Body->getEndLoc();
return DeclEndLoc;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/DeclOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,5 @@ OMPCapturedExprDecl *OMPCapturedExprDecl::CreateDeserialized(ASTContext &C,

SourceRange OMPCapturedExprDecl::getSourceRange() const {
assert(hasInit());
return SourceRange(getInit()->getBeginLoc(), getInit()->getLocEnd());
return SourceRange(getInit()->getBeginLoc(), getInit()->getEndLoc());
}
22 changes: 11 additions & 11 deletions clang/lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ bool Expr::isKnownToHaveBooleanValue() const {
// Amusing macro metaprogramming hack: check whether a class provides
// a more specific implementation of getExprLoc().
//
// See also Stmt.cpp:{getBeginLoc(),getLocEnd()}.
// See also Stmt.cpp:{getBeginLoc(),getEndLoc()}.
namespace {
/// This implementation is used when a class provides a custom
/// implementation of getExprLoc.
Expand Down Expand Up @@ -455,7 +455,7 @@ SourceLocation DeclRefExpr::getBeginLoc() const {
SourceLocation DeclRefExpr::getEndLoc() const {
if (hasExplicitTemplateArgs())
return getRAngleLoc();
return getNameInfo().getLocEnd();
return getNameInfo().getEndLoc();
}

PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FNTy, IdentType IT,
Expand Down Expand Up @@ -1369,11 +1369,11 @@ SourceLocation CallExpr::getBeginLoc() const {
}
SourceLocation CallExpr::getEndLoc() const {
if (isa<CXXOperatorCallExpr>(this))
return cast<CXXOperatorCallExpr>(this)->getLocEnd();
return cast<CXXOperatorCallExpr>(this)->getEndLoc();

SourceLocation end = getRParenLoc();
if (end.isInvalid() && getNumArgs() > 0 && getArg(getNumArgs() - 1))
end = getArg(getNumArgs() - 1)->getLocEnd();
end = getArg(getNumArgs() - 1)->getEndLoc();
return end;
}

Expand Down Expand Up @@ -1548,7 +1548,7 @@ SourceLocation MemberExpr::getEndLoc() const {
if (hasExplicitTemplateArgs())
EndLoc = getRAngleLoc();
else if (EndLoc.isInvalid())
EndLoc = getBase()->getLocEnd();
EndLoc = getBase()->getEndLoc();
return EndLoc;
}

Expand Down Expand Up @@ -2059,15 +2059,15 @@ SourceLocation InitListExpr::getBeginLoc() const {

SourceLocation InitListExpr::getEndLoc() const {
if (InitListExpr *SyntacticForm = getSyntacticForm())
return SyntacticForm->getLocEnd();
return SyntacticForm->getEndLoc();
SourceLocation End = RBraceLoc;
if (End.isInvalid()) {
// Find the first non-null initializer from the end.
for (InitExprsTy::const_reverse_iterator I = InitExprs.rbegin(),
E = InitExprs.rend();
I != E; ++I) {
if (Stmt *S = *I) {
End = S->getLocEnd();
End = S->getEndLoc();
break;
}
}
Expand Down Expand Up @@ -2279,7 +2279,7 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,

if (unsigned NumArgs = CE->getNumArgs())
R2 = SourceRange(CE->getArg(0)->getBeginLoc(),
CE->getArg(NumArgs - 1)->getLocEnd());
CE->getArg(NumArgs - 1)->getEndLoc());
return true;
}
}
Expand Down Expand Up @@ -3867,7 +3867,7 @@ SourceRange DesignatedInitExpr::getDesignatorsSourceRange() const {
if (size() == 1)
return DIE->getDesignator(0)->getSourceRange();
return SourceRange(DIE->getDesignator(0)->getBeginLoc(),
DIE->getDesignator(size() - 1)->getLocEnd());
DIE->getDesignator(size() - 1)->getEndLoc());
}

SourceLocation DesignatedInitExpr::getBeginLoc() const {
Expand All @@ -3886,7 +3886,7 @@ SourceLocation DesignatedInitExpr::getBeginLoc() const {
}

SourceLocation DesignatedInitExpr::getEndLoc() const {
return getInit()->getLocEnd();
return getInit()->getEndLoc();
}

Expr *DesignatedInitExpr::getArrayIndex(const Designator& D) const {
Expand Down Expand Up @@ -3949,7 +3949,7 @@ SourceLocation DesignatedInitUpdateExpr::getBeginLoc() const {
}

SourceLocation DesignatedInitUpdateExpr::getEndLoc() const {
return getBase()->getLocEnd();
return getBase()->getEndLoc();
}

ParenListExpr::ParenListExpr(const ASTContext& C, SourceLocation lparenloc,
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/AST/ExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ SourceLocation CXXConstructExpr::getBeginLoc() const {

SourceLocation CXXConstructExpr::getEndLoc() const {
if (isa<CXXTemporaryObjectExpr>(this))
return cast<CXXTemporaryObjectExpr>(this)->getLocEnd();
return cast<CXXTemporaryObjectExpr>(this)->getEndLoc();

if (ParenOrBraceRange.isValid())
return ParenOrBraceRange.getEnd();
Expand All @@ -467,7 +467,7 @@ SourceLocation CXXConstructExpr::getEndLoc() const {
for (unsigned I = getNumArgs(); I > 0; --I) {
const Expr *Arg = getArg(I-1);
if (!Arg->isDefaultArgument()) {
SourceLocation NewEnd = Arg->getLocEnd();
SourceLocation NewEnd = Arg->getEndLoc();
if (NewEnd.isValid()) {
End = NewEnd;
break;
Expand All @@ -483,7 +483,7 @@ SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
if (getNumArgs() == 1)
// Prefix operator
return SourceRange(getOperatorLoc(), getArg(0)->getLocEnd());
return SourceRange(getOperatorLoc(), getArg(0)->getEndLoc());
else
// Postfix operator
return SourceRange(getArg(0)->getBeginLoc(), getOperatorLoc());
Expand All @@ -494,9 +494,9 @@ SourceRange CXXOperatorCallExpr::getSourceRangeImpl() const {
} else if (Kind == OO_Subscript) {
return SourceRange(getArg(0)->getBeginLoc(), getRParenLoc());
} else if (getNumArgs() == 1) {
return SourceRange(getOperatorLoc(), getArg(0)->getLocEnd());
return SourceRange(getOperatorLoc(), getArg(0)->getEndLoc());
} else if (getNumArgs() == 2) {
return SourceRange(getArg(0)->getBeginLoc(), getArg(1)->getLocEnd());
return SourceRange(getArg(0)->getBeginLoc(), getArg(1)->getEndLoc());
} else {
return getOperatorLoc();
}
Expand Down Expand Up @@ -712,7 +712,7 @@ SourceLocation CXXFunctionalCastExpr::getBeginLoc() const {
}

SourceLocation CXXFunctionalCastExpr::getEndLoc() const {
return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getLocEnd();
return RParenLoc.isValid() ? RParenLoc : getSubExpr()->getEndLoc();
}

UserDefinedLiteral::LiteralOperatorKind
Expand Down Expand Up @@ -799,7 +799,7 @@ SourceLocation CXXTemporaryObjectExpr::getBeginLoc() const {
SourceLocation CXXTemporaryObjectExpr::getEndLoc() const {
SourceLocation Loc = getParenOrBraceRange().getEnd();
if (Loc.isInvalid() && getNumArgs())
Loc = getArg(getNumArgs()-1)->getLocEnd();
Loc = getArg(getNumArgs() - 1)->getEndLoc();
return Loc;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4453,7 +4453,7 @@ static bool HandleFunctionCall(SourceLocation CallLoc,
if (ESR == ESR_Succeeded) {
if (Callee->getReturnType()->isVoidType())
return true;
Info.FFDiag(Callee->getLocEnd(), diag::note_constexpr_no_return);
Info.FFDiag(Callee->getEndLoc(), diag::note_constexpr_no_return);
}
return ESR == ESR_Returned;
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/RawCommentList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ void RawCommentList::addComment(const RawComment &RC,
(C1.isTrailingComment() && !C2.isTrailingComment() &&
isOrdinaryKind(C2.getKind()) &&
commentsStartOnSameColumn(SourceMgr, C1, C2))) &&
onlyWhitespaceBetween(SourceMgr, C1.getLocEnd(), C2.getBeginLoc(),
onlyWhitespaceBetween(SourceMgr, C1.getEndLoc(), C2.getBeginLoc(),
/*MaxNewlinesAllowed=*/1)) {
SourceRange MergedRange(C1.getBeginLoc(), C2.getLocEnd());
SourceRange MergedRange(C1.getBeginLoc(), C2.getEndLoc());
*Comments.back() = RawComment(SourceMgr, MergedRange, CommentOpts, true);
} else {
Comments.push_back(new (Allocator) RawComment(RC));
Expand Down
20 changes: 9 additions & 11 deletions clang/lib/AST/Stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,18 @@ namespace {
static bad implements_getBeginLoc(getBeginLoc_t Stmt::*) { return bad(); }

typedef SourceLocation getLocEnd_t() const;
template <class T> good implements_getLocEnd(getLocEnd_t T::*) {
template <class T> good implements_getEndLoc(getLocEnd_t T::*) {
return good();
}
LLVM_ATTRIBUTE_UNUSED
static bad implements_getLocEnd(getLocEnd_t Stmt::*) {
return bad();
}
static bad implements_getEndLoc(getLocEnd_t Stmt::*) { return bad(); }

#define ASSERT_IMPLEMENTS_children(type) \
(void) is_good(implements_children(&type::children))
#define ASSERT_IMPLEMENTS_getBeginLoc(type) \
(void)is_good(implements_getBeginLoc(&type::getBeginLoc))
#define ASSERT_IMPLEMENTS_getLocEnd(type) \
(void) is_good(implements_getLocEnd(&type::getLocEnd))
#define ASSERT_IMPLEMENTS_getEndLoc(type) \
(void)is_good(implements_getEndLoc(&type::getEndLoc))

} // namespace

Expand All @@ -218,7 +216,7 @@ static inline void check_implementations() {
#define STMT(type, base) \
ASSERT_IMPLEMENTS_children(type); \
ASSERT_IMPLEMENTS_getBeginLoc(type); \
ASSERT_IMPLEMENTS_getLocEnd(type);
ASSERT_IMPLEMENTS_getEndLoc(type);
#include "clang/AST/StmtNodes.inc"
}

Expand Down Expand Up @@ -256,7 +254,7 @@ namespace {
SourceRange getSourceRangeImpl(const Stmt *stmt,
SourceRange (Stmt::*v)() const) {
return SourceRange(static_cast<const S *>(stmt)->getBeginLoc(),
static_cast<const S *>(stmt)->getLocEnd());
static_cast<const S *>(stmt)->getEndLoc());
}

} // namespace
Expand Down Expand Up @@ -290,9 +288,9 @@ SourceLocation Stmt::getEndLoc() const {
switch (getStmtClass()) {
case Stmt::NoStmtClass: llvm_unreachable("statement without class");
#define ABSTRACT_STMT(type)
#define STMT(type, base) \
case Stmt::type##Class: \
return static_cast<const type*>(this)->getLocEnd();
#define STMT(type, base) \
case Stmt::type##Class: \
return static_cast<const type *>(this)->getEndLoc();
#include "clang/AST/StmtNodes.inc"
}
llvm_unreachable("unknown statement kind");
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/AST/StmtObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(const ASTContext &Context,

SourceLocation ObjCAtTryStmt::getEndLoc() const {
if (HasFinally)
return getFinallyStmt()->getLocEnd();
return getFinallyStmt()->getEndLoc();
if (NumCatchStmts)
return getCatchStmt(NumCatchStmts - 1)->getLocEnd();
return getTryBody()->getLocEnd();
return getCatchStmt(NumCatchStmts - 1)->getEndLoc();
return getTryBody()->getEndLoc();
}
2 changes: 1 addition & 1 deletion clang/lib/Analysis/CloneDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ SourceLocation StmtSequence::getBeginLoc() const {
return front()->getBeginLoc();
}

SourceLocation StmtSequence::getEndLoc() const { return back()->getLocEnd(); }
SourceLocation StmtSequence::getEndLoc() const { return back()->getEndLoc(); }

SourceRange StmtSequence::getSourceRange() const {
return SourceRange(getBeginLoc(), getEndLoc());
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/Consumed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ void ConsumedAnalyzer::run(AnalysisDeclContext &AC) {

case CFGElement::AutomaticObjectDtor: {
const CFGAutomaticObjDtor &DTor = B.castAs<CFGAutomaticObjDtor>();
SourceLocation Loc = DTor.getTriggerStmt()->getLocEnd();
SourceLocation Loc = DTor.getTriggerStmt()->getEndLoc();
const VarDecl *Var = DTor.getVarDecl();

Visitor.checkCallability(PropagationInfo(Var),
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/ThreadSafety.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,7 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
// Create a dummy expression,
auto *VD = const_cast<VarDecl *>(AD.getVarDecl());
DeclRefExpr DRE(VD, false, VD->getType().getNonReferenceType(),
VK_LValue, AD.getTriggerStmt()->getLocEnd());
VK_LValue, AD.getTriggerStmt()->getEndLoc());
LocksetBuilder.handleCall(&DRE, DD);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGBlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD,

CurGD = GD;

CurEHLocation = blockInfo.getBlockExpr()->getLocEnd();
CurEHLocation = blockInfo.getBlockExpr()->getEndLoc();

BlockInfo = &blockInfo;

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ void CodeGenFunction::EmitConstructorBody(FunctionArgList &Args) {
// delegation optimization.
if (CtorType == Ctor_Complete && IsConstructorDelegationValid(Ctor) &&
CGM.getTarget().getCXXABI().hasConstructorVariants()) {
EmitDelegateCXXConstructorCall(Ctor, Ctor_Base, Args, Ctor->getLocEnd());
EmitDelegateCXXConstructorCall(Ctor, Ctor_Base, Args, Ctor->getEndLoc());
return;
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ CodeGenFunction::GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
FilterExpr->getType()->isSignedIntegerType());
Builder.CreateStore(R, ReturnValue);

FinishFunction(FilterExpr->getLocEnd());
FinishFunction(FilterExpr->getEndLoc());

return CurFn;
}
Expand All @@ -1907,7 +1907,7 @@ CodeGenFunction::GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
// Emit the original filter expression, convert to i32, and return.
EmitStmt(FinallyBlock);

FinishFunction(FinallyBlock->getLocEnd());
FinishFunction(FinallyBlock->getEndLoc());

return CurFn;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
args.append(OMD->param_begin(), OMD->param_end());

CurGD = OMD;
CurEHLocation = OMD->getLocEnd();
CurEHLocation = OMD->getEndLoc();

StartFunction(OMD, OMD->getReturnType(), Fn, FI, args,
OMD->getLocation(), StartLoc);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8864,7 +8864,7 @@ void CGOpenMPRuntime::emitDoacrossInit(CodeGenFunction &CGF,
llvm::Value *RTLFn = createRuntimeFunction(OMPRTL__kmpc_doacross_init);
CGF.EmitRuntimeCall(RTLFn, Args);
llvm::Value *FiniArgs[DoacrossCleanupTy::DoacrossFinArgs] = {
emitUpdateLocation(CGF, D.getLocEnd()), getThreadID(CGF, D.getLocEnd())};
emitUpdateLocation(CGF, D.getEndLoc()), getThreadID(CGF, D.getEndLoc())};
llvm::Value *FiniRTLFn = createRuntimeFunction(OMPRTL__kmpc_doacross_fini);
CGF.EHStack.pushCleanup<DoacrossCleanupTy>(NormalAndEHCleanup, FiniRTLFn,
llvm::makeArrayRef(FiniArgs));
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/CodeGen/CGStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ void CodeGenFunction::EmitOMPReductionClauseFinal(
// Emit nowait reduction if nowait clause is present or directive is a
// parallel directive (it always has implicit barrier).
CGM.getOpenMPRuntime().emitReduction(
*this, D.getLocEnd(), Privates, LHSExprs, RHSExprs, ReductionOps,
*this, D.getEndLoc(), Privates, LHSExprs, RHSExprs, ReductionOps,
{WithNowait, SimpleReduction, ReductionKind});
}
}
Expand Down Expand Up @@ -1851,7 +1851,7 @@ void CodeGenFunction::EmitOMPOuterLoop(
// Tell the runtime we are done.
auto &&CodeGen = [DynamicOrOrdered, &S](CodeGenFunction &CGF) {
if (!DynamicOrOrdered)
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(),
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getEndLoc(),
S.getDirectiveKind());
};
OMPCancelStack.emitExit(*this, S.getDirectiveKind(), CodeGen);
Expand Down Expand Up @@ -2332,7 +2332,7 @@ bool CodeGenFunction::EmitOMPWorksharingLoop(
EmitBlock(LoopExit.getBlock());
// Tell the runtime we are done.
auto &&CodeGen = [&S](CodeGenFunction &CGF) {
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(),
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getEndLoc(),
S.getDirectiveKind());
};
OMPCancelStack.emitExit(*this, S.getDirectiveKind(), CodeGen);
Expand Down Expand Up @@ -2564,7 +2564,7 @@ void CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
[](CodeGenFunction &) {});
// Tell the runtime we are done.
auto &&CodeGen = [&S](CodeGenFunction &CGF) {
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(),
CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getEndLoc(),
S.getDirectiveKind());
};
CGF.OMPCancelStack.emitExit(CGF, S.getDirectiveKind(), CodeGen);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CoverageMappingGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class CoverageMappingBuilder {

/// Get the end of \c S ignoring macro arguments and builtin macros.
SourceLocation getEnd(const Stmt *S) {
SourceLocation Loc = S->getLocEnd();
SourceLocation Loc = S->getEndLoc();
while (SM.isMacroArgExpansion(Loc) || isInBuiltin(Loc))
Loc = SM.getImmediateExpansionRange(Loc).getBegin();
return getPreciseTokenLocEnd(Loc);
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Edit/RewriteObjCFoundationAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ static bool rewriteToArrayLiteral(const ObjCMessageExpr *Msg,
return true;
}
SourceRange ArgRange(Msg->getArg(0)->getBeginLoc(),
Msg->getArg(Msg->getNumArgs() - 2)->getLocEnd());
Msg->getArg(Msg->getNumArgs() - 2)->getEndLoc());
commit.replaceWithInner(MsgRange, ArgRange);
commit.insertWrap("@[", ArgRange, "]");
return true;
Expand Down Expand Up @@ -551,7 +551,7 @@ static bool rewriteToDictionaryLiteral(const ObjCMessageExpr *Msg,
// The sentinel and first value are cut off, the value will move after the
// key.
SourceRange ArgRange(Msg->getArg(1)->getBeginLoc(),
Msg->getArg(SentinelIdx - 1)->getLocEnd());
Msg->getArg(SentinelIdx - 1)->getEndLoc());
commit.insertWrap("@{", ArgRange, "}");
commit.replaceWithInner(MsgRange, ArgRange);
return true;
Expand Down Expand Up @@ -591,7 +591,7 @@ static bool rewriteToDictionaryLiteral(const ObjCMessageExpr *Msg,
}
// Range of arguments up until and including the last key.
// The first value is cut off, the value will move after the key.
SourceRange ArgRange(Keys.front()->getBeginLoc(), Keys.back()->getLocEnd());
SourceRange ArgRange(Keys.front()->getBeginLoc(), Keys.back()->getEndLoc());
commit.insertWrap("@{", ArgRange, "}");
commit.replaceWithInner(MsgRange, ArgRange);
return true;
Expand Down
30 changes: 15 additions & 15 deletions clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ void RewriteModernObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
assert((*semiBuf == ';') && "@synthesize: can't find ';'");
startGetterSetterLoc = startLoc.getLocWithOffset(semiBuf-startBuf+1);
} else
startGetterSetterLoc = IMD ? IMD->getLocEnd() : CID->getLocEnd();
startGetterSetterLoc = IMD ? IMD->getEndLoc() : CID->getEndLoc();

if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
return; // FIXME: is this correct?
Expand Down Expand Up @@ -1109,7 +1109,7 @@ void RewriteModernObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
if (Method->isImplicit())
return;
SourceLocation LocStart = Method->getBeginLoc();
SourceLocation LocEnd = Method->getLocEnd();
SourceLocation LocEnd = Method->getEndLoc();

if (SM->getExpansionLineNumber(LocEnd) >
SM->getExpansionLineNumber(LocStart)) {
Expand Down Expand Up @@ -1371,7 +1371,7 @@ void RewriteModernObjC::RewriteImplementationDecl(Decl *OID) {
for (auto *I : IMD ? IMD->property_impls() : CID->property_impls())
RewritePropertyImplDecl(I, IMD, CID);

InsertText(IMD ? IMD->getLocEnd() : CID->getLocEnd(), "// ");
InsertText(IMD ? IMD->getEndLoc() : CID->getEndLoc(), "// ");
}

void RewriteModernObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
Expand Down Expand Up @@ -1879,7 +1879,7 @@ Stmt *RewriteModernObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S)
buf += "\n\tid sync_exit;";
buf += "\n\t} _sync_exit(_sync_obj);\n";

// We can't use S->getSynchExpr()->getLocEnd() to find the end location, since
// We can't use S->getSynchExpr()->getEndLoc() to find the end location, since
// the sync expression is typically a message expression that's already
// been rewritten! (which implies the SourceLocation's are invalid).
SourceLocation RParenExprLoc = S->getSynchBody()->getBeginLoc();
Expand All @@ -1892,7 +1892,7 @@ Stmt *RewriteModernObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S)
assert (*LBraceLocBuf == '{');
ReplaceText(RParenExprLoc, (LBraceLocBuf - SM->getCharacterData(RParenExprLoc) + 1), buf);

SourceLocation startRBraceLoc = S->getSynchBody()->getLocEnd();
SourceLocation startRBraceLoc = S->getSynchBody()->getEndLoc();
assert((*SM->getCharacterData(startRBraceLoc) == '}') &&
"bogus @synchronized block");

Expand Down Expand Up @@ -2020,7 +2020,7 @@ Stmt *RewriteModernObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
Write_RethrowObject(buf);
ReplaceText(startFinalBodyLoc, 1, buf);

SourceLocation endFinalBodyLoc = body->getLocEnd();
SourceLocation endFinalBodyLoc = body->getEndLoc();
ReplaceText(endFinalBodyLoc, 1, "}\n}");
// Now check for any return/continue/go statements within the @try.
WarnAboutReturnGotoStmts(S->getTryBody());
Expand Down Expand Up @@ -2051,7 +2051,7 @@ Stmt *RewriteModernObjC::RewriteObjCThrowStmt(ObjCAtThrowStmt *S) {
assert((*wBuf == 'w') && "@throw: can't find 'w'");
ReplaceText(startLoc, wBuf-startBuf+1, buf);

SourceLocation endLoc = S->getLocEnd();
SourceLocation endLoc = S->getEndLoc();
const char *endBuf = SM->getCharacterData(endLoc);
const char *semiBuf = strchr(endBuf, ';');
assert((*semiBuf == ';') && "@throw: can't find ';'");
Expand Down Expand Up @@ -2170,7 +2170,7 @@ void RewriteModernObjC::RewriteObjCQualifiedInterfaceTypes(Expr *E) {
EndLoc = ECE->getRParenLoc();
} else {
Loc = E->getBeginLoc();
EndLoc = E->getLocEnd();
EndLoc = E->getEndLoc();
}
// This will defend against trying to rewrite synthesized expressions.
if (Loc.isInvalid() || EndLoc.isInvalid())
Expand Down Expand Up @@ -2301,7 +2301,7 @@ void RewriteModernObjC::RewriteTypeOfDecl(VarDecl *ND) {
ReplaceText(DeclLoc, endBuf-startBuf-1, TypeAsString);
}
else {
SourceLocation X = ND->getLocEnd();
SourceLocation X = ND->getEndLoc();
X = SM->getExpansionLoc(X);
const char *endBuf = SM->getCharacterData(X);
ReplaceText(DeclLoc, endBuf-startBuf-1, TypeAsString);
Expand Down Expand Up @@ -2625,7 +2625,7 @@ Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) {

FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
SourceLocation StartLoc = Exp->getBeginLoc();
SourceLocation EndLoc = Exp->getLocEnd();
SourceLocation EndLoc = Exp->getEndLoc();

// Synthesize a call to objc_msgSend().
SmallVector<Expr*, 4> MsgExprs;
Expand Down Expand Up @@ -2709,7 +2709,7 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) {

FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
SourceLocation StartLoc = Exp->getBeginLoc();
SourceLocation EndLoc = Exp->getLocEnd();
SourceLocation EndLoc = Exp->getEndLoc();

// Build the expression: __NSContainer_literal(int, ...).arr
QualType IntQT = Context->IntTy;
Expand Down Expand Up @@ -2832,7 +2832,7 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral

FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
SourceLocation StartLoc = Exp->getBeginLoc();
SourceLocation EndLoc = Exp->getLocEnd();
SourceLocation EndLoc = Exp->getEndLoc();

// Build the expression: __NSContainer_literal(int, ...).arr
QualType IntQT = Context->IntTy;
Expand Down Expand Up @@ -3563,7 +3563,7 @@ Stmt *RewriteModernObjC::SynthMessageExpr(ObjCMessageExpr *Exp,

Stmt *RewriteModernObjC::RewriteMessageExpr(ObjCMessageExpr *Exp) {
Stmt *ReplacingStmt =
SynthMessageExpr(Exp, Exp->getBeginLoc(), Exp->getLocEnd());
SynthMessageExpr(Exp, Exp->getBeginLoc(), Exp->getEndLoc());

// Now do the actual rewrite.
ReplaceStmt(Exp, ReplacingStmt);
Expand Down Expand Up @@ -5035,7 +5035,7 @@ void RewriteModernObjC::RewriteByRefVar(VarDecl *ND, bool firstDecl,
// Use variable's location which is good for this case.
DeclLoc = ND->getLocation();
const char *startBuf = SM->getCharacterData(DeclLoc);
SourceLocation X = ND->getLocEnd();
SourceLocation X = ND->getEndLoc();
X = SM->getExpansionLoc(X);
const char *endBuf = SM->getCharacterData(X);
std::string Name(ND->getNameAsString());
Expand Down Expand Up @@ -5537,7 +5537,7 @@ Stmt *RewriteModernObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
#if 0
// Before we rewrite it, put the original message expression in a comment.
SourceLocation startLoc = MessExpr->getBeginLoc();
SourceLocation endLoc = MessExpr->getLocEnd();
SourceLocation endLoc = MessExpr->getEndLoc();

const char *startBuf = SM->getCharacterData(startLoc);
const char *endBuf = SM->getCharacterData(endLoc);
Expand Down
30 changes: 15 additions & 15 deletions clang/lib/Frontend/Rewrite/RewriteObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
if (Method->isImplicit())
return;
SourceLocation LocStart = Method->getBeginLoc();
SourceLocation LocEnd = Method->getLocEnd();
SourceLocation LocEnd = Method->getEndLoc();

if (SM->getExpansionLineNumber(LocEnd) >
SM->getExpansionLineNumber(LocStart)) {
Expand Down Expand Up @@ -1191,7 +1191,7 @@ void RewriteObjC::RewriteImplementationDecl(Decl *OID) {
for (auto *I : IMD ? IMD->property_impls() : CID->property_impls())
RewritePropertyImplDecl(I, IMD, CID);

InsertText(IMD ? IMD->getLocEnd() : CID->getLocEnd(), "// ");
InsertText(IMD ? IMD->getEndLoc() : CID->getEndLoc(), "// ");
}

void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
Expand Down Expand Up @@ -1651,7 +1651,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
const char *lparenBuf = startBuf;
while (*lparenBuf != '(') lparenBuf++;
ReplaceText(startLoc, lparenBuf-startBuf+1, buf);
// We can't use S->getSynchExpr()->getLocEnd() to find the end location, since
// We can't use S->getSynchExpr()->getEndLoc() to find the end location, since
// the sync expression is typically a message expression that's already
// been rewritten! (which implies the SourceLocation's are invalid).
SourceLocation endLoc = S->getSynchBody()->getBeginLoc();
Expand All @@ -1667,7 +1667,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
buf += "objc_exception_try_enter(&_stack);\n";
buf += "if (!_setjmp(_stack.buf)) /* @try block continue */\n";
ReplaceText(rparenLoc, 1, buf);
startLoc = S->getSynchBody()->getLocEnd();
startLoc = S->getSynchBody()->getEndLoc();
startBuf = SM->getCharacterData(startLoc);

assert((*startBuf == '}') && "bogus @synchronized block");
Expand Down Expand Up @@ -1798,7 +1798,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {

ReplaceText(startLoc, 4, buf);

startLoc = S->getTryBody()->getLocEnd();
startLoc = S->getTryBody()->getEndLoc();
startBuf = SM->getCharacterData(startLoc);

assert((*startBuf == '}') && "bogus @try block");
Expand Down Expand Up @@ -1881,7 +1881,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
}
// Complete the catch list...
if (lastCatchBody) {
SourceLocation bodyLoc = lastCatchBody->getLocEnd();
SourceLocation bodyLoc = lastCatchBody->getEndLoc();
assert(*SM->getCharacterData(bodyLoc) == '}' &&
"bogus @catch body location");

Expand All @@ -1897,7 +1897,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
InsertText(bodyLoc, buf);

// Set lastCurlyLoc
lastCurlyLoc = lastCatchBody->getLocEnd();
lastCurlyLoc = lastCatchBody->getEndLoc();
}
if (ObjCAtFinallyStmt *finalStmt = S->getFinallyStmt()) {
startLoc = finalStmt->getBeginLoc();
Expand All @@ -1908,7 +1908,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {

Stmt *body = finalStmt->getFinallyBody();
SourceLocation startLoc = body->getBeginLoc();
SourceLocation endLoc = body->getLocEnd();
SourceLocation endLoc = body->getEndLoc();
assert(*SM->getCharacterData(startLoc) == '{' &&
"bogus @finally body location");
assert(*SM->getCharacterData(endLoc) == '}' &&
Expand All @@ -1920,7 +1920,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
InsertText(endLoc, " if (_rethrow) objc_exception_throw(_rethrow);\n");

// Set lastCurlyLoc
lastCurlyLoc = body->getLocEnd();
lastCurlyLoc = body->getEndLoc();

// Now check for any return/continue/go statements within the @try.
WarnAboutReturnGotoStmts(S->getTryBody());
Expand Down Expand Up @@ -2083,7 +2083,7 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Expr *E) {
EndLoc = ECE->getRParenLoc();
} else {
Loc = E->getBeginLoc();
EndLoc = E->getLocEnd();
EndLoc = E->getEndLoc();
}
// This will defend against trying to rewrite synthesized expressions.
if (Loc.isInvalid() || EndLoc.isInvalid())
Expand Down Expand Up @@ -2210,7 +2210,7 @@ void RewriteObjC::RewriteTypeOfDecl(VarDecl *ND) {
ReplaceText(DeclLoc, endBuf-startBuf-1, TypeAsString);
}
else {
SourceLocation X = ND->getLocEnd();
SourceLocation X = ND->getEndLoc();
X = SM->getExpansionLoc(X);
const char *endBuf = SM->getCharacterData(X);
ReplaceText(DeclLoc, endBuf-startBuf-1, TypeAsString);
Expand Down Expand Up @@ -3009,7 +3009,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,

Stmt *RewriteObjC::RewriteMessageExpr(ObjCMessageExpr *Exp) {
Stmt *ReplacingStmt =
SynthMessageExpr(Exp, Exp->getBeginLoc(), Exp->getLocEnd());
SynthMessageExpr(Exp, Exp->getBeginLoc(), Exp->getEndLoc());

// Now do the actual rewrite.
ReplaceStmt(Exp, ReplacingStmt);
Expand Down Expand Up @@ -4179,7 +4179,7 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
// Use variable's location which is good for this case.
DeclLoc = ND->getLocation();
const char *startBuf = SM->getCharacterData(DeclLoc);
SourceLocation X = ND->getLocEnd();
SourceLocation X = ND->getEndLoc();
X = SM->getExpansionLoc(X);
const char *endBuf = SM->getCharacterData(X);
std::string Name(ND->getNameAsString());
Expand Down Expand Up @@ -4633,7 +4633,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
#if 0
// Before we rewrite it, put the original message expression in a comment.
SourceLocation startLoc = MessExpr->getBeginLoc();
SourceLocation endLoc = MessExpr->getLocEnd();
SourceLocation endLoc = MessExpr->getEndLoc();

const char *startBuf = SM->getCharacterData(startLoc);
const char *endBuf = SM->getCharacterData(endLoc);
Expand Down Expand Up @@ -5874,7 +5874,7 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
IV->getBase());
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(
IV->getBase()->getBeginLoc(), IV->getBase()->getLocEnd(), castExpr);
IV->getBase()->getBeginLoc(), IV->getBase()->getEndLoc(), castExpr);
// Cannot delete IV->getBase(), since PE points to it.
// Replace the old base with the cast. This is important when doing
// embedded rewrites. For example, [newInv->_container addObject:0].
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Index/IndexBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) {
const OffsetOfNode &Component = S->getComponent(I);
if (Component.getKind() == OffsetOfNode::Field)
IndexCtx.handleReference(Component.getField(), Component.getLocEnd(),
IndexCtx.handleReference(Component.getField(), Component.getEndLoc(),
Parent, ParentDC, SymbolRoleSet(), {});
// FIXME: Try to resolve dependent field references.
}
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2841,7 +2841,7 @@ Parser::DiagnoseMissingSemiAfterTagDefinition(DeclSpec &DS, AccessSpecifier AS,
return false;

const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
Diag(PP.getLocForEndOfToken(DS.getRepAsDecl()->getLocEnd()),
Diag(PP.getLocForEndOfToken(DS.getRepAsDecl()->getEndLoc()),
diag::err_expected_after)
<< DeclSpec::getSpecifierName(DS.getTypeSpecType(), PPol) << tok::semi;

Expand Down Expand Up @@ -5363,7 +5363,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
// Sema will have to catch (syntactically invalid) pointers into global
// scope. It has to catch pointers into namespace scope anyway.
D.AddTypeInfo(DeclaratorChunk::getMemberPointer(
SS, DS.getTypeQualifiers(), DS.getLocEnd()),
SS, DS.getTypeQualifiers(), DS.getEndLoc()),
std::move(DS.getAttributes()),
/* Don't replace range end. */ SourceLocation());
return;
Expand Down Expand Up @@ -6693,7 +6693,7 @@ void Parser::ParseMisplacedBracketDeclarator(Declarator &D) {

if (NeedParens) {
// Create a DeclaratorChunk for the inserted parens.
SourceLocation EndLoc = PP.getLocForEndOfToken(D.getLocEnd());
SourceLocation EndLoc = PP.getLocForEndOfToken(D.getEndLoc());
D.AddTypeInfo(DeclaratorChunk::getParen(SuggestParenLoc, EndLoc),
SourceLocation());
}
Expand All @@ -6709,11 +6709,11 @@ void Parser::ParseMisplacedBracketDeclarator(Declarator &D) {
if (!D.getIdentifier() && !NeedParens)
return;

SourceLocation EndBracketLoc = TempDeclarator.getLocEnd();
SourceLocation EndBracketLoc = TempDeclarator.getEndLoc();

// Generate the move bracket error message.
SourceRange BracketRange(StartBracketLoc, EndBracketLoc);
SourceLocation EndLoc = PP.getLocForEndOfToken(D.getLocEnd());
SourceLocation EndLoc = PP.getLocForEndOfToken(D.getEndLoc());

if (NeedParens) {
Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
Expand Down
17 changes: 8 additions & 9 deletions clang/lib/Parse/ParseExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
Expr *InitList = Init.get();
return Actions.ActOnCXXTypeConstructExpr(
TypeRep, InitList->getBeginLoc(), MultiExprArg(&InitList, 1),
InitList->getLocEnd(), /*ListInitialization=*/true);
InitList->getEndLoc(), /*ListInitialization=*/true);
} else {
BalancedDelimiterTracker T(*this, tok::l_paren);
T.consumeOpen();
Expand All @@ -1685,10 +1685,10 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {

if (Tok.isNot(tok::r_paren)) {
if (ParseExpressionList(Exprs, CommaLocs, [&] {
Actions.CodeCompleteConstructor(getCurScope(),
TypeRep.get()->getCanonicalTypeInternal(),
DS.getLocEnd(), Exprs);
})) {
Actions.CodeCompleteConstructor(
getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
DS.getEndLoc(), Exprs);
})) {
SkipUntil(tok::r_paren, StopAtSemi);
return ExprError();
}
Expand Down Expand Up @@ -2819,10 +2819,9 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) {
if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] {
ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(),
DeclaratorInfo).get();
Actions.CodeCompleteConstructor(getCurScope(),
TypeRep.get()->getCanonicalTypeInternal(),
DeclaratorInfo.getLocEnd(),
ConstructorArgs);
Actions.CodeCompleteConstructor(
getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
DeclaratorInfo.getEndLoc(), ConstructorArgs);
})) {
SkipUntil(tok::semi, StopAtSemi | StopBeforeMatch);
return ExprError();
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/Sema/AnalysisBasedWarnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
// Short circuit for compilation speed.
if (CD.checkDiagnostics(Diags, ReturnsVoid, HasNoReturn))
return;
SourceLocation LBrace = Body->getBeginLoc(), RBrace = Body->getLocEnd();
SourceLocation LBrace = Body->getBeginLoc(), RBrace = Body->getEndLoc();
auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) {
if (IsCoroutine)
S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType();
Expand Down Expand Up @@ -748,10 +748,10 @@ static bool SuggestInitializationFixit(Sema &S, const VarDecl *VD) {
return false;

// Don't suggest a fixit inside macros.
if (VD->getLocEnd().isMacroID())
if (VD->getEndLoc().isMacroID())
return false;

SourceLocation Loc = S.getLocForEndOfToken(VD->getLocEnd());
SourceLocation Loc = S.getLocForEndOfToken(VD->getEndLoc());

// Suggest possible initialization (if any).
std::string Init = S.getFixItZeroInitializerForType(VariableTy, Loc);
Expand All @@ -773,9 +773,9 @@ static void CreateIfFixit(Sema &S, const Stmt *If, const Stmt *Then,
Fixit1 = FixItHint::CreateRemoval(
CharSourceRange::getCharRange(If->getBeginLoc(), Then->getBeginLoc()));
if (Else) {
SourceLocation ElseKwLoc = S.getLocForEndOfToken(Then->getLocEnd());
Fixit2 = FixItHint::CreateRemoval(
SourceRange(ElseKwLoc, Else->getLocEnd()));
SourceLocation ElseKwLoc = S.getLocForEndOfToken(Then->getEndLoc());
Fixit2 =
FixItHint::CreateRemoval(SourceRange(ElseKwLoc, Else->getEndLoc()));
}
} else {
// If condition is always false, remove all but the 'else'.
Expand Down Expand Up @@ -2142,7 +2142,7 @@ AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
// Check for thread safety violations
if (P.enableThreadSafetyAnalysis) {
SourceLocation FL = AC.getDecl()->getLocation();
SourceLocation FEL = AC.getDecl()->getLocEnd();
SourceLocation FEL = AC.getDecl()->getEndLoc();
threadSafety::ThreadSafetyReporter Reporter(S, FL, FEL);
if (!Diags.isIgnored(diag::warn_thread_safety_beta, D->getBeginLoc()))
Reporter.setIssueBetaWarnings(true);
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2723,7 +2723,7 @@ ExprResult Sema::BuildCStyleCastExpr(SourceLocation LPLoc,
Expr *CastExpr) {
CastOperation Op(*this, CastTypeInfo->getType(), CastExpr);
Op.DestRange = CastTypeInfo->getTypeLoc().getSourceRange();
Op.OpRange = SourceRange(LPLoc, CastExpr->getLocEnd());
Op.OpRange = SourceRange(LPLoc, CastExpr->getEndLoc());

if (getLangOpts().CPlusPlus) {
Op.CheckCXXCStyleCast(/*FunctionalStyle=*/ false,
Expand Down Expand Up @@ -2751,7 +2751,7 @@ ExprResult Sema::BuildCXXFunctionalCastExpr(TypeSourceInfo *CastTypeInfo,
assert(LPLoc.isValid() && "List-initialization shouldn't get here.");
CastOperation Op(*this, Type, CastExpr);
Op.DestRange = CastTypeInfo->getTypeLoc().getSourceRange();
Op.OpRange = SourceRange(Op.DestRange.getBegin(), CastExpr->getLocEnd());
Op.OpRange = SourceRange(Op.DestRange.getBegin(), CastExpr->getEndLoc());

Op.CheckCXXCStyleCast(/*FunctionalStyle=*/true, /*ListInit=*/false);
if (Op.SrcExpr.isInvalid())
Expand Down
115 changes: 57 additions & 58 deletions clang/lib/Sema/SemaChecking.cpp

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1735,8 +1735,9 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx,
FixItHint &Hint) {
if (isa<LabelDecl>(D)) {
SourceLocation AfterColon = Lexer::findLocationAfterToken(D->getLocEnd(),
tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(), true);
SourceLocation AfterColon = Lexer::findLocationAfterToken(
D->getEndLoc(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(),
true);
if (AfterColon.isInvalid())
return;
Hint = FixItHint::CreateRemoval(
Expand Down Expand Up @@ -8005,7 +8006,7 @@ static FunctionDecl* CreateNewFunctionDecl(Sema &SemaRef, Declarator &D,

return CXXDeductionGuideDecl::Create(SemaRef.Context, DC, D.getBeginLoc(),
isExplicit, NameInfo, R, TInfo,
D.getLocEnd());
D.getEndLoc());
} else if (DC->isRecord()) {
// If the name of the function is the same as the name of the record,
// then this must be an invalid constructor that has a return type.
Expand Down Expand Up @@ -12479,7 +12480,7 @@ ParmVarDecl *Sema::CheckParameter(DeclContext *DC, SourceLocation StartLoc,
// passed by reference.
if (T->isObjCObjectType()) {
SourceLocation TypeEndLoc =
getLocForEndOfToken(TSInfo->getTypeLoc().getLocEnd());
getLocForEndOfToken(TSInfo->getTypeLoc().getEndLoc());
Diag(NameLoc,
diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
<< FixItHint::CreateInsertion(TypeEndLoc, "*");
Expand Down Expand Up @@ -13128,8 +13129,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
computeNRVO(Body, getCurFunction());
}
if (getCurFunction()->ObjCShouldCallSuper) {
Diag(MD->getLocEnd(), diag::warn_objc_missing_super_call)
<< MD->getSelector().getAsString();
Diag(MD->getEndLoc(), diag::warn_objc_missing_super_call)
<< MD->getSelector().getAsString();
getCurFunction()->ObjCShouldCallSuper = false;
}
if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) {
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7056,7 +7056,7 @@ struct AttributeInsertion {
StringRef Suffix;

static AttributeInsertion createInsertionAfter(const NamedDecl *D) {
return {" ", D->getLocEnd(), ""};
return {" ", D->getEndLoc(), ""};
}
static AttributeInsertion createInsertionAfter(SourceLocation Loc) {
return {" ", Loc, ""};
Expand Down Expand Up @@ -7586,19 +7586,19 @@ class DiagnoseUnguardedAvailability
bool VisitObjCMessageExpr(ObjCMessageExpr *Msg) {
if (ObjCMethodDecl *D = Msg->getMethodDecl())
DiagnoseDeclAvailability(
D, SourceRange(Msg->getSelectorStartLoc(), Msg->getLocEnd()));
D, SourceRange(Msg->getSelectorStartLoc(), Msg->getEndLoc()));
return true;
}

bool VisitDeclRefExpr(DeclRefExpr *DRE) {
DiagnoseDeclAvailability(DRE->getDecl(),
SourceRange(DRE->getBeginLoc(), DRE->getLocEnd()));
SourceRange(DRE->getBeginLoc(), DRE->getEndLoc()));
return true;
}

bool VisitMemberExpr(MemberExpr *ME) {
DiagnoseDeclAvailability(ME->getMemberDecl(),
SourceRange(ME->getBeginLoc(), ME->getLocEnd()));
SourceRange(ME->getBeginLoc(), ME->getEndLoc()));
return true;
}

Expand Down Expand Up @@ -7695,7 +7695,7 @@ void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
SM.getExpansionLoc(StmtOfUse->getBeginLoc());
SourceLocation StmtEndLoc =
SM.getExpansionRange(
(LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getLocEnd())
(LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getEndLoc())
.getEnd();
if (SM.getFileID(IfInsertionLoc) != SM.getFileID(StmtEndLoc))
return;
Expand Down
37 changes: 18 additions & 19 deletions clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3650,7 +3650,7 @@ void Sema::ActOnFinishCXXInClassMemberInitializer(Decl *D,
FD->getInClassInitStyle() == ICIS_ListInit
? InitializationKind::CreateDirectList(InitExpr->getBeginLoc(),
InitExpr->getBeginLoc(),
InitExpr->getLocEnd())
InitExpr->getEndLoc())
: InitializationKind::CreateCopy(InitExpr->getBeginLoc(), InitLoc);
InitializationSequence Seq(*this, Entity, Kind, InitExpr);
Init = Seq.Perform(*this, Entity, Kind, InitExpr);
Expand Down Expand Up @@ -3998,7 +3998,7 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init,
nullptr);
InitializationKind Kind =
InitList ? InitializationKind::CreateDirectList(
IdLoc, Init->getBeginLoc(), Init->getLocEnd())
IdLoc, Init->getBeginLoc(), Init->getEndLoc())
: InitializationKind::CreateDirect(IdLoc, InitRange.getBegin(),
InitRange.getEnd());

Expand Down Expand Up @@ -4051,7 +4051,7 @@ Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init,
QualType(ClassDecl->getTypeForDecl(), 0));
InitializationKind Kind =
InitList ? InitializationKind::CreateDirectList(
NameLoc, Init->getBeginLoc(), Init->getLocEnd())
NameLoc, Init->getBeginLoc(), Init->getEndLoc())
: InitializationKind::CreateDirect(NameLoc, InitRange.getBegin(),
InitRange.getEnd());
InitializationSequence InitSeq(*this, DelegationEntity, Kind, Args);
Expand Down Expand Up @@ -8444,7 +8444,7 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
// If we can provide a correct fix-it hint, do so.
if (After.isInvalid() && ConvTSI) {
SourceLocation InsertLoc =
getLocForEndOfToken(ConvTSI->getTypeLoc().getLocEnd());
getLocForEndOfToken(ConvTSI->getTypeLoc().getEndLoc());
DB << FixItHint::CreateInsertion(InsertLoc, " ")
<< FixItHint::CreateInsertionFromRange(
InsertLoc, CharSourceRange::getTokenRange(Before))
Expand Down Expand Up @@ -10237,8 +10237,7 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc,
" = ");
} else {
// Convert 'using X::Y;' to 'typedef X::Y Y;'.
SourceLocation InsertLoc =
getLocForEndOfToken(NameInfo.getLocEnd());
SourceLocation InsertLoc = getLocForEndOfToken(NameInfo.getEndLoc());
Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
<< 1 // typedef declaration
<< FixItHint::CreateReplacement(UsingLoc, "typedef")
Expand Down Expand Up @@ -10873,8 +10872,8 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
return;
}

SourceLocation Loc = Constructor->getLocEnd().isValid()
? Constructor->getLocEnd()
SourceLocation Loc = Constructor->getEndLoc().isValid()
? Constructor->getEndLoc()
: Constructor->getLocation();
Constructor->setBody(new (Context) CompoundStmt(Loc));
Constructor->markUsed(Context);
Expand Down Expand Up @@ -11156,8 +11155,8 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation,
return;
}

SourceLocation Loc = Destructor->getLocEnd().isValid()
? Destructor->getLocEnd()
SourceLocation Loc = Destructor->getEndLoc().isValid()
? Destructor->getEndLoc()
: Destructor->getLocation();
Destructor->setBody(new (Context) CompoundStmt(Loc));
Destructor->markUsed(Context);
Expand Down Expand Up @@ -11828,8 +11827,8 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
}

// Our location for everything implicitly-generated.
SourceLocation Loc = CopyAssignOperator->getLocEnd().isValid()
? CopyAssignOperator->getLocEnd()
SourceLocation Loc = CopyAssignOperator->getEndLoc().isValid()
? CopyAssignOperator->getEndLoc()
: CopyAssignOperator->getLocation();

// Builds a DeclRefExpr for the "other" object.
Expand Down Expand Up @@ -12184,8 +12183,8 @@ void Sema::DefineImplicitMoveAssignment(SourceLocation CurrentLocation,
"Bad argument type of defaulted move assignment");

// Our location for everything implicitly-generated.
SourceLocation Loc = MoveAssignOperator->getLocEnd().isValid()
? MoveAssignOperator->getLocEnd()
SourceLocation Loc = MoveAssignOperator->getEndLoc().isValid()
? MoveAssignOperator->getEndLoc()
: MoveAssignOperator->getLocation();

// Builds a reference to the "other" object.
Expand Down Expand Up @@ -12469,8 +12468,8 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
if (SetCtorInitializers(CopyConstructor, /*AnyErrors=*/false)) {
CopyConstructor->setInvalidDecl();
} else {
SourceLocation Loc = CopyConstructor->getLocEnd().isValid()
? CopyConstructor->getLocEnd()
SourceLocation Loc = CopyConstructor->getEndLoc().isValid()
? CopyConstructor->getEndLoc()
: CopyConstructor->getLocation();
Sema::CompoundScopeRAII CompoundScope(*this);
CopyConstructor->setBody(
Expand Down Expand Up @@ -12592,8 +12591,8 @@ void Sema::DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
if (SetCtorInitializers(MoveConstructor, /*AnyErrors=*/false)) {
MoveConstructor->setInvalidDecl();
} else {
SourceLocation Loc = MoveConstructor->getLocEnd().isValid()
? MoveConstructor->getLocEnd()
SourceLocation Loc = MoveConstructor->getEndLoc().isValid()
? MoveConstructor->getEndLoc()
: MoveConstructor->getLocation();
Sema::CompoundScopeRAII CompoundScope(*this);
MoveConstructor->setBody(ActOnCompoundStmt(
Expand Down Expand Up @@ -12896,7 +12895,7 @@ ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field) {
RecordDecl *OutermostClass = ParentRD->getOuterLexicalRecordContext();
Diag(Loc, diag::err_in_class_initializer_not_yet_parsed)
<< OutermostClass << Field;
Diag(Field->getLocEnd(), diag::note_in_class_initializer_not_yet_parsed);
Diag(Field->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed);
// Recover by marking the field invalid, unless we're in a SFINAE context.
if (!isSFINAEContext())
Field->setInvalidDecl();
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ ActOnSuperClassOfClassInterface(Scope *S,
}

IDecl->setSuperClass(SuperClassTInfo);
IDecl->setEndOfDefinitionLoc(SuperClassTInfo->getTypeLoc().getLocEnd());
IDecl->setEndOfDefinitionLoc(SuperClassTInfo->getTypeLoc().getEndLoc());
}
}

Expand Down Expand Up @@ -829,7 +829,7 @@ static bool checkTypeParamListConsistency(Sema &S,
if (newTypeParams->size() > prevTypeParams->size()) {
diagLoc = newTypeParams->begin()[prevTypeParams->size()]->getLocation();
} else {
diagLoc = S.getLocForEndOfToken(newTypeParams->back()->getLocEnd());
diagLoc = S.getLocForEndOfToken(newTypeParams->back()->getEndLoc());
}

S.Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
Expand Down
53 changes: 26 additions & 27 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
// or 'NULL' if those are actually defined in the context. Only use
// 'nil' for ObjC methods, where it's much more likely that the
// variadic arguments form a list of object pointers.
SourceLocation MissingNilLoc
= getLocForEndOfToken(sentinelExpr->getLocEnd());
SourceLocation MissingNilLoc = getLocForEndOfToken(sentinelExpr->getEndLoc());
std::string NullValue;
if (calleeType == CT_Method && PP.isMacroDefined("nil"))
NullValue = "nil";
Expand Down Expand Up @@ -502,7 +501,7 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
&S.Context.Idents.get("object_setClass"),
SourceLocation(), S.LookupOrdinaryName);
if (ObjectSetClass) {
SourceLocation RHSLocEnd = S.getLocForEndOfToken(RHS->getLocEnd());
SourceLocation RHSLocEnd = S.getLocForEndOfToken(RHS->getEndLoc());
S.Diag(OIRE->getExprLoc(), diag::warn_objc_isa_assign)
<< FixItHint::CreateInsertion(OIRE->getBeginLoc(),
"object_setClass(")
Expand All @@ -522,7 +521,7 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
<< FixItHint::CreateInsertion(OIRE->getBeginLoc(),
"object_getClass(")
<< FixItHint::CreateReplacement(
SourceRange(OIRE->getOpLoc(), OIRE->getLocEnd()), ")");
SourceRange(OIRE->getOpLoc(), OIRE->getEndLoc()), ")");
else
S.Diag(OIRE->getLocation(), diag::warn_objc_isa_use);
}
Expand Down Expand Up @@ -897,7 +896,7 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT,
return ExprError();

ExprResult Call = ActOnCallExpr(TUScope, TrapFn.get(), E->getBeginLoc(),
None, E->getLocEnd());
None, E->getEndLoc());
if (Call.isInvalid())
return ExprError();

Expand Down Expand Up @@ -4842,7 +4841,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
<< FnKind << FDecl->getParamDecl(0)
<< static_cast<unsigned>(Args.size()) << Fn->getSourceRange()
<< SourceRange(Args[NumParams]->getBeginLoc(),
Args.back()->getLocEnd());
Args.back()->getEndLoc());
else
Diag(Args[NumParams]->getBeginLoc(),
MinArgs == NumParams
Expand All @@ -4851,7 +4850,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
<< FnKind << NumParams << static_cast<unsigned>(Args.size())
<< Fn->getSourceRange()
<< SourceRange(Args[NumParams]->getBeginLoc(),
Args.back()->getLocEnd());
Args.back()->getEndLoc());

// Emit the location of the prototype.
if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
Expand Down Expand Up @@ -5317,7 +5316,7 @@ ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
Diag(Fn->getBeginLoc(), diag::err_pseudo_dtor_call_with_args)
<< FixItHint::CreateRemoval(
SourceRange(ArgExprs.front()->getBeginLoc(),
ArgExprs.back()->getLocEnd()));
ArgExprs.back()->getEndLoc()));
}

return new (Context)
Expand Down Expand Up @@ -7214,11 +7213,11 @@ static void DiagnoseConditionalPrecedence(Sema &Self,
Self, OpLoc,
Self.PDiag(diag::note_precedence_silence)
<< BinaryOperator::getOpcodeStr(CondOpcode),
SourceRange(Condition->getBeginLoc(), Condition->getLocEnd()));
SourceRange(Condition->getBeginLoc(), Condition->getEndLoc()));

SuggestParentheses(Self, OpLoc,
Self.PDiag(diag::note_precedence_conditional_first),
SourceRange(CondRHS->getBeginLoc(), RHSExpr->getLocEnd()));
SourceRange(CondRHS->getBeginLoc(), RHSExpr->getEndLoc()));
}

/// Compute the nullability of a conditional expression.
Expand Down Expand Up @@ -8915,13 +8914,13 @@ static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc,
return;
}

SourceRange DiagRange(LHSExpr->getBeginLoc(), RHSExpr->getLocEnd());
SourceRange DiagRange(LHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
Self.Diag(OpLoc, diag::warn_string_plus_int)
<< DiagRange << IndexExpr->IgnoreImpCasts()->getType();

// Only print a fixit for "str" + int, not for int + "str".
if (IndexExpr == RHSExpr) {
SourceLocation EndLoc = Self.getLocForEndOfToken(RHSExpr->getLocEnd());
SourceLocation EndLoc = Self.getLocForEndOfToken(RHSExpr->getEndLoc());
Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
<< FixItHint::CreateInsertion(LHSExpr->getBeginLoc(), "&")
<< FixItHint::CreateReplacement(SourceRange(OpLoc), "[")
Expand Down Expand Up @@ -8956,7 +8955,7 @@ static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc,
return;

ASTContext &Ctx = Self.getASTContext();
SourceRange DiagRange(LHSExpr->getBeginLoc(), RHSExpr->getLocEnd());
SourceRange DiagRange(LHSExpr->getBeginLoc(), RHSExpr->getEndLoc());

const QualType CharType = CharExpr->getType();
if (!CharType->isAnyCharacterType() &&
Expand All @@ -8971,7 +8970,7 @@ static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc,

// Only print a fixit for str + char, not for char + str.
if (isa<CharacterLiteral>(RHSExpr->IgnoreImpCasts())) {
SourceLocation EndLoc = Self.getLocForEndOfToken(RHSExpr->getLocEnd());
SourceLocation EndLoc = Self.getLocForEndOfToken(RHSExpr->getEndLoc());
Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
<< FixItHint::CreateInsertion(LHSExpr->getBeginLoc(), "&")
<< FixItHint::CreateReplacement(SourceRange(OpLoc), "[")
Expand Down Expand Up @@ -9646,7 +9645,7 @@ static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc,
if (BinaryOperator::isEqualityOp(Opc) &&
hasIsEqualMethod(S, LHS.get(), RHS.get())) {
SourceLocation Start = LHS.get()->getBeginLoc();
SourceLocation End = S.getLocForEndOfToken(RHS.get()->getLocEnd());
SourceLocation End = S.getLocForEndOfToken(RHS.get()->getEndLoc());
CharSourceRange OpRange =
CharSourceRange::getCharRange(Loc, S.getLocForEndOfToken(Loc));

Expand Down Expand Up @@ -9679,7 +9678,7 @@ static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS,

// First note suggest !(x < y)
SourceLocation FirstOpen = SubExpr->getBeginLoc();
SourceLocation FirstClose = RHS.get()->getLocEnd();
SourceLocation FirstClose = RHS.get()->getEndLoc();
FirstClose = S.getLocForEndOfToken(FirstClose);
if (FirstClose.isInvalid())
FirstOpen = SourceLocation();
Expand All @@ -9690,7 +9689,7 @@ static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS,

// Second note suggests (!x) < y
SourceLocation SecondOpen = LHS.get()->getBeginLoc();
SourceLocation SecondClose = LHS.get()->getLocEnd();
SourceLocation SecondClose = LHS.get()->getEndLoc();
SecondClose = S.getLocForEndOfToken(SecondClose);
if (SecondClose.isInvalid())
SecondOpen = SourceLocation();
Expand Down Expand Up @@ -10619,8 +10618,8 @@ inline QualType Sema::CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS,
// Suggest replacing "Foo() && kNonZero" with "Foo()"
Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
<< FixItHint::CreateRemoval(
SourceRange(getLocForEndOfToken(LHS.get()->getLocEnd()),
RHS.get()->getLocEnd()));
SourceRange(getLocForEndOfToken(LHS.get()->getEndLoc()),
RHS.get()->getEndLoc()));
}
}

Expand Down Expand Up @@ -11265,7 +11264,7 @@ void Sema::DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc) {
<< FixItHint::CreateInsertion(LHS->getBeginLoc(),
LangOpts.CPlusPlus ? "static_cast<void>("
: "(void)(")
<< FixItHint::CreateInsertion(PP.getLocForEndOfToken(LHS->getLocEnd()),
<< FixItHint::CreateInsertion(PP.getLocForEndOfToken(LHS->getEndLoc()),
")");
}

Expand Down Expand Up @@ -11997,7 +11996,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
// The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning
// of x = {} is x = T().
InitializationKind Kind = InitializationKind::CreateDirectList(
RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getLocEnd());
RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
InitializedEntity Entity =
InitializedEntity::InitializeTemporary(LHSExpr->getType());
InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
Expand Down Expand Up @@ -12026,7 +12025,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
// OpenCLC v2.0 s6.13.11.1 allows atomic variables to be initialized by
// the ATOMIC_VAR_INIT macro.
if (LHSTy->isAtomicType() || RHSTy->isAtomicType()) {
SourceRange SR(LHSExpr->getBeginLoc(), RHSExpr->getLocEnd());
SourceRange SR(LHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
if (BO_Assign == Opc)
Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
else
Expand Down Expand Up @@ -12188,7 +12187,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
&Context.Idents.get("object_setClass"),
SourceLocation(), LookupOrdinaryName);
if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.get())) {
SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getLocEnd());
SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
Diag(LHS.get()->getExprLoc(), diag::warn_objc_isa_assign)
<< FixItHint::CreateInsertion(LHS.get()->getBeginLoc(),
"object_setClass(")
Expand Down Expand Up @@ -12253,12 +12252,12 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc,

SourceRange DiagRange = isLeftComp
? SourceRange(LHSExpr->getBeginLoc(), OpLoc)
: SourceRange(OpLoc, RHSExpr->getLocEnd());
: SourceRange(OpLoc, RHSExpr->getEndLoc());
StringRef OpStr = isLeftComp ? LHSBO->getOpcodeStr() : RHSBO->getOpcodeStr();
SourceRange ParensRange =
isLeftComp
? SourceRange(LHSBO->getRHS()->getBeginLoc(), RHSExpr->getLocEnd())
: SourceRange(LHSExpr->getBeginLoc(), RHSBO->getLHS()->getLocEnd());
? SourceRange(LHSBO->getRHS()->getBeginLoc(), RHSExpr->getEndLoc())
: SourceRange(LHSExpr->getBeginLoc(), RHSBO->getLHS()->getEndLoc());

Self.Diag(OpLoc, diag::warn_precedence_bitwise_rel)
<< DiagRange << BinaryOperator::getOpcodeStr(Opc) << OpStr;
Expand Down Expand Up @@ -12394,7 +12393,7 @@ static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc,
OCE->getSourceRange());
SuggestParentheses(
S, OpLoc, S.PDiag(diag::note_evaluate_comparison_first),
SourceRange(OCE->getArg(1)->getBeginLoc(), RHSExpr->getLocEnd()));
SourceRange(OCE->getArg(1)->getBeginLoc(), RHSExpr->getEndLoc()));
}

/// DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky
Expand Down
25 changes: 9 additions & 16 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1698,15 +1698,9 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
if (ParenListExpr *List = dyn_cast_or_null<ParenListExpr>(Initializer))
DirectInitRange = List->getSourceRange();

return BuildCXXNew(SourceRange(StartLoc, D.getLocEnd()), UseGlobal,
PlacementLParen,
PlacementArgs,
PlacementRParen,
TypeIdParens,
AllocType,
TInfo,
ArraySize,
DirectInitRange,
return BuildCXXNew(SourceRange(StartLoc, D.getEndLoc()), UseGlobal,
PlacementLParen, PlacementArgs, PlacementRParen,
TypeIdParens, AllocType, TInfo, ArraySize, DirectInitRange,
Initializer);
}

Expand Down Expand Up @@ -1804,7 +1798,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
: initStyle == CXXNewExpr::ListInit
? InitializationKind::CreateDirectList(
TypeRange.getBegin(), Initializer->getBeginLoc(),
Initializer->getLocEnd())
Initializer->getEndLoc())
: InitializationKind::CreateDirect(TypeRange.getBegin(),
DirectInitRange.getBegin(),
DirectInitRange.getEnd());
Expand Down Expand Up @@ -2087,7 +2081,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
// dialect distinction.
if (ArraySize && !isLegalArrayNewInitializer(initStyle, Initializer)) {
SourceRange InitRange(Inits[0]->getBeginLoc(),
Inits[NumInits - 1]->getLocEnd());
Inits[NumInits - 1]->getEndLoc());
Diag(StartLoc, diag::err_new_array_init_args) << InitRange;
return ExprError();
}
Expand Down Expand Up @@ -2594,7 +2588,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
SourceRange R = PlaceArgs.empty()
? SourceRange()
: SourceRange(PlaceArgs.front()->getBeginLoc(),
PlaceArgs.back()->getLocEnd());
PlaceArgs.back()->getEndLoc());
Diag(StartLoc, diag::err_placement_new_non_placement_delete) << R;
if (!OperatorDelete->isImplicit())
Diag(OperatorDelete->getLocation(), diag::note_previous_decl)
Expand Down Expand Up @@ -5421,7 +5415,7 @@ QualType Sema::CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS,
CXXCastPath BasePath;
if (CheckDerivedToBaseConversion(
LHSType, Class, Loc,
SourceRange(LHS.get()->getBeginLoc(), RHS.get()->getLocEnd()),
SourceRange(LHS.get()->getBeginLoc(), RHS.get()->getEndLoc()),
&BasePath))
return QualType();

Expand Down Expand Up @@ -7159,9 +7153,8 @@ ExprResult Sema::BuildCXXMemberCallExpr(Expr *E, NamedDecl *FoundDecl,
ExprValueKind VK = Expr::getValueKindForType(ResultType);
ResultType = ResultType.getNonLValueExprType(Context);

CXXMemberCallExpr *CE =
new (Context) CXXMemberCallExpr(Context, ME, None, ResultType, VK,
Exp.get()->getLocEnd());
CXXMemberCallExpr *CE = new (Context) CXXMemberCallExpr(
Context, ME, None, ResultType, VK, Exp.get()->getEndLoc());

if (CheckFunctionCall(Method, CE,
Method->getType()->castAs<FunctionProtoType>()))
Expand Down
9 changes: 5 additions & 4 deletions clang/lib/Sema/SemaExprObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ ExprResult Sema::BuildObjCDictionaryLiteral(SourceRange SR,
Diag(Element.EllipsisLoc,
diag::err_pack_expansion_without_parameter_packs)
<< SourceRange(Element.Key->getBeginLoc(),
Element.Value->getLocEnd());
Element.Value->getEndLoc());
return ExprError();
}

Expand Down Expand Up @@ -1697,7 +1697,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType,
<< 2 /*method*/ << NumNamedArgs << static_cast<unsigned>(Args.size())
<< Method->getSourceRange()
<< SourceRange(Args[NumNamedArgs]->getBeginLoc(),
Args.back()->getLocEnd());
Args.back()->getEndLoc());
}
}

Expand Down Expand Up @@ -4070,7 +4070,8 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
ExpressionString += RelatedClass->getNameAsString();
ExpressionString += " ";
ExpressionString += ClassMethod->getSelector().getAsString();
SourceLocation SrcExprEndLoc = getLocForEndOfToken(SrcExpr->getLocEnd());
SourceLocation SrcExprEndLoc =
getLocForEndOfToken(SrcExpr->getEndLoc());
// Provide a fixit: [RelatedClass ClassMethod SrcExpr]
Diag(Loc, diag::err_objc_bridged_related_known_method)
<< SrcType << DestType << ClassMethod->getSelector() << false
Expand Down Expand Up @@ -4098,7 +4099,7 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
if (Diagnose) {
std::string ExpressionString;
SourceLocation SrcExprEndLoc =
getLocForEndOfToken(SrcExpr->getLocEnd());
getLocForEndOfToken(SrcExpr->getEndLoc());
if (InstanceMethod->isPropertyAccessor())
if (const ObjCPropertyDecl *PDecl =
InstanceMethod->findPropertyDecl()) {
Expand Down
Loading