forked from OSchip/llvm-project
Use Sema::getLocForEndOfToken instead of Preprocessor::getLocForEndOfToken. NFC
llvm-svn: 253155
This commit is contained in:
parent
12545075f0
commit
07fa176669
|
@ -34,7 +34,6 @@
|
|||
#include "clang/Analysis/CFGStmtMap.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
#include "clang/Sema/ScopeInfo.h"
|
||||
#include "clang/Sema/SemaInternal.h"
|
||||
|
@ -657,8 +656,7 @@ static void CreateIfFixit(Sema &S, const Stmt *If, const Stmt *Then,
|
|||
CharSourceRange::getCharRange(If->getLocStart(),
|
||||
Then->getLocStart()));
|
||||
if (Else) {
|
||||
SourceLocation ElseKwLoc = Lexer::getLocForEndOfToken(
|
||||
Then->getLocEnd(), 0, S.getSourceManager(), S.getLangOpts());
|
||||
SourceLocation ElseKwLoc = S.getLocForEndOfToken(Then->getLocEnd());
|
||||
Fixit2 = FixItHint::CreateRemoval(
|
||||
SourceRange(ElseKwLoc, Else->getLocEnd()));
|
||||
}
|
||||
|
|
|
@ -1469,7 +1469,7 @@ bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD,
|
|||
// arguments and that it returns something of a reasonable type,
|
||||
// so we can emit a fixit and carry on pretending that E was
|
||||
// actually a CallExpr.
|
||||
SourceLocation ParenInsertionLoc = PP.getLocForEndOfToken(Range.getEnd());
|
||||
SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
|
||||
Diag(Loc, PD)
|
||||
<< /*zero-arg*/ 1 << Range
|
||||
<< (IsCallableWithAppend(E.get())
|
||||
|
|
|
@ -316,7 +316,7 @@ bool Sema::checkStringLiteralArgumentAttr(const AttributeList &Attr,
|
|||
Diag(Loc->Loc, diag::err_attribute_argument_type)
|
||||
<< Attr.getName() << AANT_ArgumentString
|
||||
<< FixItHint::CreateInsertion(Loc->Loc, "\"")
|
||||
<< FixItHint::CreateInsertion(PP.getLocForEndOfToken(Loc->Loc), "\"");
|
||||
<< FixItHint::CreateInsertion(getLocForEndOfToken(Loc->Loc), "\"");
|
||||
Str = Loc->Ident->getName();
|
||||
if (ArgLocation)
|
||||
*ArgLocation = Loc->Loc;
|
||||
|
|
|
@ -7035,7 +7035,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 =
|
||||
PP.getLocForEndOfToken(ConvTSI->getTypeLoc().getLocEnd());
|
||||
getLocForEndOfToken(ConvTSI->getTypeLoc().getLocEnd());
|
||||
DB << FixItHint::CreateInsertion(InsertLoc, " ")
|
||||
<< FixItHint::CreateInsertionFromRange(
|
||||
InsertLoc, CharSourceRange::getTokenRange(Before))
|
||||
|
@ -8388,7 +8388,7 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc,
|
|||
} else {
|
||||
// Convert 'using X::Y;' to 'typedef X::Y Y;'.
|
||||
SourceLocation InsertLoc =
|
||||
PP.getLocForEndOfToken(NameInfo.getLocEnd());
|
||||
getLocForEndOfToken(NameInfo.getLocEnd());
|
||||
Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
|
||||
<< 1 // typedef declaration
|
||||
<< FixItHint::CreateReplacement(UsingLoc, "typedef")
|
||||
|
@ -12213,7 +12213,7 @@ FriendDecl *Sema::CheckFriendTypeDecl(SourceLocation LocStart,
|
|||
diag::ext_unelaborated_friend_type)
|
||||
<< (unsigned) RD->getTagKind()
|
||||
<< T
|
||||
<< FixItHint::CreateInsertion(PP.getLocForEndOfToken(FriendLoc),
|
||||
<< FixItHint::CreateInsertion(getLocForEndOfToken(FriendLoc),
|
||||
InsertionText);
|
||||
} else {
|
||||
Diag(FriendLoc,
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/ExprObjC.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
#include "clang/Sema/DeclSpec.h"
|
||||
#include "clang/Sema/ExternalSemaSource.h"
|
||||
#include "clang/Sema/Lookup.h"
|
||||
|
@ -607,7 +606,7 @@ DeclResult Sema::actOnObjCTypeParam(Scope *S,
|
|||
} else if (typeBound->isObjCObjectType()) {
|
||||
// The user forgot the * on an Objective-C pointer type, e.g.,
|
||||
// "T : NSView".
|
||||
SourceLocation starLoc = PP.getLocForEndOfToken(
|
||||
SourceLocation starLoc = getLocForEndOfToken(
|
||||
typeBoundInfo->getTypeLoc().getEndLoc());
|
||||
Diag(typeBoundInfo->getTypeLoc().getBeginLoc(),
|
||||
diag::err_objc_type_param_bound_missing_pointer)
|
||||
|
@ -760,7 +759,7 @@ static bool checkTypeParamListConsistency(Sema &S,
|
|||
if (newTypeParams->size() > prevTypeParams->size()) {
|
||||
diagLoc = newTypeParams->begin()[prevTypeParams->size()]->getLocation();
|
||||
} else {
|
||||
diagLoc = S.PP.getLocForEndOfToken(newTypeParams->back()->getLocEnd());
|
||||
diagLoc = S.getLocForEndOfToken(newTypeParams->back()->getLocEnd());
|
||||
}
|
||||
|
||||
S.Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
|
||||
|
@ -875,7 +874,7 @@ static bool checkTypeParamListConsistency(Sema &S,
|
|||
newContext == TypeParamListContext::Definition) {
|
||||
// Diagnose this problem for forward declarations and definitions.
|
||||
SourceLocation insertionLoc
|
||||
= S.PP.getLocForEndOfToken(newTypeParam->getLocation());
|
||||
= S.getLocForEndOfToken(newTypeParam->getLocation());
|
||||
std::string newCode
|
||||
= " : " + prevTypeParam->getUnderlyingType().getAsString(
|
||||
S.Context.getPrintingPolicy());
|
||||
|
@ -1407,8 +1406,8 @@ void Sema::actOnObjCTypeArgsOrProtocolQualifiers(
|
|||
if (allProtocolsDeclared) {
|
||||
Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
|
||||
<< baseClass->getDeclName() << SourceRange(lAngleLoc, rAngleLoc)
|
||||
<< FixItHint::CreateInsertion(
|
||||
PP.getLocForEndOfToken(firstClassNameLoc), " *");
|
||||
<< FixItHint::CreateInsertion(getLocForEndOfToken(firstClassNameLoc),
|
||||
" *");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1488,7 +1487,7 @@ void Sema::actOnObjCTypeArgsOrProtocolQualifiers(
|
|||
// If we have a typedef of an Objective-C class type that is missing a '*',
|
||||
// add the '*'.
|
||||
if (type->getAs<ObjCInterfaceType>()) {
|
||||
SourceLocation starLoc = PP.getLocForEndOfToken(loc);
|
||||
SourceLocation starLoc = getLocForEndOfToken(loc);
|
||||
ParsedAttributes parsedAttrs(attrFactory);
|
||||
D.AddTypeInfo(DeclaratorChunk::getPointer(/*typeQuals=*/0, starLoc,
|
||||
SourceLocation(),
|
||||
|
|
|
@ -467,7 +467,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
|
|||
// 'nil' for ObjC methods, where it's much more likely that the
|
||||
// variadic arguments form a list of object pointers.
|
||||
SourceLocation MissingNilLoc
|
||||
= PP.getLocForEndOfToken(sentinelExpr->getLocEnd());
|
||||
= getLocForEndOfToken(sentinelExpr->getLocEnd());
|
||||
std::string NullValue;
|
||||
if (calleeType == CT_Method && PP.isMacroDefined("nil"))
|
||||
NullValue = "nil";
|
||||
|
@ -582,7 +582,7 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
|
|||
&S.Context.Idents.get("object_setClass"),
|
||||
SourceLocation(), S.LookupOrdinaryName);
|
||||
if (ObjectSetClass) {
|
||||
SourceLocation RHSLocEnd = S.PP.getLocForEndOfToken(RHS->getLocEnd());
|
||||
SourceLocation RHSLocEnd = S.getLocForEndOfToken(RHS->getLocEnd());
|
||||
S.Diag(OIRE->getExprLoc(), diag::warn_objc_isa_assign) <<
|
||||
FixItHint::CreateInsertion(OIRE->getLocStart(), "object_setClass(") <<
|
||||
FixItHint::CreateReplacement(SourceRange(OIRE->getOpLoc(),
|
||||
|
@ -6476,7 +6476,7 @@ QualType Sema::FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS,
|
|||
static void SuggestParentheses(Sema &Self, SourceLocation Loc,
|
||||
const PartialDiagnostic &Note,
|
||||
SourceRange ParenRange) {
|
||||
SourceLocation EndLoc = Self.PP.getLocForEndOfToken(ParenRange.getEnd());
|
||||
SourceLocation EndLoc = Self.getLocForEndOfToken(ParenRange.getEnd());
|
||||
if (ParenRange.getBegin().isFileID() && ParenRange.getEnd().isFileID() &&
|
||||
EndLoc.isValid()) {
|
||||
Self.Diag(Loc, Note)
|
||||
|
@ -7818,7 +7818,7 @@ static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc,
|
|||
|
||||
// Only print a fixit for "str" + int, not for int + "str".
|
||||
if (IndexExpr == RHSExpr) {
|
||||
SourceLocation EndLoc = Self.PP.getLocForEndOfToken(RHSExpr->getLocEnd());
|
||||
SourceLocation EndLoc = Self.getLocForEndOfToken(RHSExpr->getLocEnd());
|
||||
Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
|
||||
<< FixItHint::CreateInsertion(LHSExpr->getLocStart(), "&")
|
||||
<< FixItHint::CreateReplacement(SourceRange(OpLoc), "[")
|
||||
|
@ -7868,7 +7868,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.PP.getLocForEndOfToken(RHSExpr->getLocEnd());
|
||||
SourceLocation EndLoc = Self.getLocForEndOfToken(RHSExpr->getLocEnd());
|
||||
Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
|
||||
<< FixItHint::CreateInsertion(LHSExpr->getLocStart(), "&")
|
||||
<< FixItHint::CreateReplacement(SourceRange(OpLoc), "[")
|
||||
|
@ -8514,9 +8514,9 @@ static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc,
|
|||
if (BinaryOperator::isEqualityOp(Opc) &&
|
||||
hasIsEqualMethod(S, LHS.get(), RHS.get())) {
|
||||
SourceLocation Start = LHS.get()->getLocStart();
|
||||
SourceLocation End = S.PP.getLocForEndOfToken(RHS.get()->getLocEnd());
|
||||
SourceLocation End = S.getLocForEndOfToken(RHS.get()->getLocEnd());
|
||||
CharSourceRange OpRange =
|
||||
CharSourceRange::getCharRange(Loc, S.PP.getLocForEndOfToken(Loc));
|
||||
CharSourceRange::getCharRange(Loc, S.getLocForEndOfToken(Loc));
|
||||
|
||||
S.Diag(Loc, diag::note_objc_literal_comparison_isequal)
|
||||
<< FixItHint::CreateInsertion(Start, Opc == BO_EQ ? "[" : "![")
|
||||
|
@ -8547,7 +8547,7 @@ static void diagnoseLogicalNotOnLHSofComparison(Sema &S, ExprResult &LHS,
|
|||
// First note suggest !(x < y)
|
||||
SourceLocation FirstOpen = SubExpr->getLocStart();
|
||||
SourceLocation FirstClose = RHS.get()->getLocEnd();
|
||||
FirstClose = S.getPreprocessor().getLocForEndOfToken(FirstClose);
|
||||
FirstClose = S.getLocForEndOfToken(FirstClose);
|
||||
if (FirstClose.isInvalid())
|
||||
FirstOpen = SourceLocation();
|
||||
S.Diag(UO->getOperatorLoc(), diag::note_logical_not_fix)
|
||||
|
@ -8557,7 +8557,7 @@ static void diagnoseLogicalNotOnLHSofComparison(Sema &S, ExprResult &LHS,
|
|||
// Second note suggests (!x) < y
|
||||
SourceLocation SecondOpen = LHS.get()->getLocStart();
|
||||
SourceLocation SecondClose = LHS.get()->getLocEnd();
|
||||
SecondClose = S.getPreprocessor().getLocForEndOfToken(SecondClose);
|
||||
SecondClose = S.getLocForEndOfToken(SecondClose);
|
||||
if (SecondClose.isInvalid())
|
||||
SecondOpen = SourceLocation();
|
||||
S.Diag(UO->getOperatorLoc(), diag::note_logical_not_silence_with_parens)
|
||||
|
@ -9120,17 +9120,13 @@ inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14]
|
|||
Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
|
||||
<< (Opc == BO_LAnd ? "&" : "|")
|
||||
<< FixItHint::CreateReplacement(SourceRange(
|
||||
Loc, Lexer::getLocForEndOfToken(Loc, 0, getSourceManager(),
|
||||
getLangOpts())),
|
||||
Loc, getLocForEndOfToken(Loc)),
|
||||
Opc == BO_LAnd ? "&" : "|");
|
||||
if (Opc == BO_LAnd)
|
||||
// Suggest replacing "Foo() && kNonZero" with "Foo()"
|
||||
Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
|
||||
<< FixItHint::CreateRemoval(
|
||||
SourceRange(
|
||||
Lexer::getLocForEndOfToken(LHS.get()->getLocEnd(),
|
||||
0, getSourceManager(),
|
||||
getLangOpts()),
|
||||
SourceRange(getLocForEndOfToken(LHS.get()->getLocEnd()),
|
||||
RHS.get()->getLocEnd()));
|
||||
}
|
||||
}
|
||||
|
@ -10400,7 +10396,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
|
|||
&Context.Idents.get("object_setClass"),
|
||||
SourceLocation(), LookupOrdinaryName);
|
||||
if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.get())) {
|
||||
SourceLocation RHSLocEnd = PP.getLocForEndOfToken(RHS.get()->getLocEnd());
|
||||
SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getLocEnd());
|
||||
Diag(LHS.get()->getExprLoc(), diag::warn_objc_isa_assign) <<
|
||||
FixItHint::CreateInsertion(LHS.get()->getLocStart(), "object_setClass(") <<
|
||||
FixItHint::CreateReplacement(SourceRange(OISA->getOpLoc(), OpLoc), ",") <<
|
||||
|
@ -13822,7 +13818,7 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
|
|||
Diag(Loc, diagnostic) << E->getSourceRange();
|
||||
|
||||
SourceLocation Open = E->getLocStart();
|
||||
SourceLocation Close = PP.getLocForEndOfToken(E->getSourceRange().getEnd());
|
||||
SourceLocation Close = getLocForEndOfToken(E->getSourceRange().getEnd());
|
||||
Diag(Loc, diag::note_condition_assign_silence)
|
||||
<< FixItHint::CreateInsertion(Open, "(")
|
||||
<< FixItHint::CreateInsertion(Close, ")");
|
||||
|
|
|
@ -2727,7 +2727,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
|
|||
if (Pointee->isArrayType() && !ArrayForm) {
|
||||
Diag(StartLoc, diag::warn_delete_array_type)
|
||||
<< Type << Ex.get()->getSourceRange()
|
||||
<< FixItHint::CreateInsertion(PP.getLocForEndOfToken(StartLoc), "[]");
|
||||
<< FixItHint::CreateInsertion(getLocForEndOfToken(StartLoc), "[]");
|
||||
ArrayForm = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1092,7 +1092,7 @@ ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc,
|
|||
QualType EncodedType = GetTypeFromParser(ty, &TInfo);
|
||||
if (!TInfo)
|
||||
TInfo = Context.getTrivialTypeSourceInfo(EncodedType,
|
||||
PP.getLocForEndOfToken(LParenLoc));
|
||||
getLocForEndOfToken(LParenLoc));
|
||||
|
||||
return BuildObjCEncodeExpression(AtLoc, TInfo, RParenLoc);
|
||||
}
|
||||
|
@ -3397,7 +3397,7 @@ static void addFixitForObjCARCConversion(Sema &S,
|
|||
DiagB.AddFixItHint(FixItHint::CreateInsertion(range.getBegin(),
|
||||
BridgeCall));
|
||||
DiagB.AddFixItHint(FixItHint::CreateInsertion(
|
||||
S.PP.getLocForEndOfToken(range.getEnd()),
|
||||
S.getLocForEndOfToken(range.getEnd()),
|
||||
")"));
|
||||
}
|
||||
return;
|
||||
|
@ -3430,7 +3430,7 @@ static void addFixitForObjCARCConversion(Sema &S,
|
|||
DiagB.AddFixItHint(FixItHint::CreateInsertion(range.getBegin(),
|
||||
castCode));
|
||||
DiagB.AddFixItHint(FixItHint::CreateInsertion(
|
||||
S.PP.getLocForEndOfToken(range.getEnd()),
|
||||
S.getLocForEndOfToken(range.getEnd()),
|
||||
")"));
|
||||
}
|
||||
}
|
||||
|
@ -3498,7 +3498,7 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange,
|
|||
}
|
||||
|
||||
// Check whether this could be fixed with a bridge cast.
|
||||
SourceLocation afterLParen = S.PP.getLocForEndOfToken(castRange.getBegin());
|
||||
SourceLocation afterLParen = S.getLocForEndOfToken(castRange.getBegin());
|
||||
SourceLocation noteLoc = afterLParen.isValid() ? afterLParen : loc;
|
||||
|
||||
// Bridge from an ARC type to a CF type.
|
||||
|
@ -3901,7 +3901,7 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
|
|||
ExpressionString += RelatedClass->getNameAsString();
|
||||
ExpressionString += " ";
|
||||
ExpressionString += ClassMethod->getSelector().getAsString();
|
||||
SourceLocation SrcExprEndLoc = PP.getLocForEndOfToken(SrcExpr->getLocEnd());
|
||||
SourceLocation SrcExprEndLoc = getLocForEndOfToken(SrcExpr->getLocEnd());
|
||||
// Provide a fixit: [RelatedClass ClassMethod SrcExpr]
|
||||
Diag(Loc, diag::err_objc_bridged_related_known_method)
|
||||
<< SrcType << DestType << ClassMethod->getSelector() << false
|
||||
|
@ -3926,7 +3926,7 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
|
|||
// Implicit conversion from ObjC type to CF object is needed.
|
||||
if (InstanceMethod) {
|
||||
std::string ExpressionString;
|
||||
SourceLocation SrcExprEndLoc = PP.getLocForEndOfToken(SrcExpr->getLocEnd());
|
||||
SourceLocation SrcExprEndLoc = getLocForEndOfToken(SrcExpr->getLocEnd());
|
||||
if (InstanceMethod->isPropertyAccessor())
|
||||
if (const ObjCPropertyDecl *PDecl = InstanceMethod->findPropertyDecl()) {
|
||||
// fixit: ObjectExpr.propertyname when it is aproperty accessor.
|
||||
|
|
|
@ -58,7 +58,7 @@ bool ConversionFixItGenerator::tryToFixConversion(const Expr *FullExpr,
|
|||
const CanQualType FromQTy = S.Context.getCanonicalType(FromTy);
|
||||
const CanQualType ToQTy = S.Context.getCanonicalType(ToTy);
|
||||
const SourceLocation Begin = FullExpr->getSourceRange().getBegin();
|
||||
const SourceLocation End = S.PP.getLocForEndOfToken(FullExpr->getSourceRange()
|
||||
const SourceLocation End = S.getLocForEndOfToken(FullExpr->getSourceRange()
|
||||
.getEnd());
|
||||
|
||||
// Strip the implicit casts - those are implied by the compiler, not the
|
||||
|
|
Loading…
Reference in New Issue