diff options
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 1c698da053..fbdf080bc4 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -949,8 +949,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS, // Actually quite difficult! if (isInstance) Diag(R.getNameLoc(), diagnostic) << Name - << CodeModificationHint::CreateInsertion(R.getNameLoc(), - "this->"); + << FixItHint::CreateInsertion(R.getNameLoc(), "this->"); else Diag(R.getNameLoc(), diagnostic) << Name; @@ -969,14 +968,14 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS, if (isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin())) { if (SS.isEmpty()) Diag(R.getNameLoc(), diagnostic_suggest) << Name << R.getLookupName() - << CodeModificationHint::CreateReplacement(R.getNameLoc(), - R.getLookupName().getAsString()); + << FixItHint::CreateReplacement(R.getNameLoc(), + R.getLookupName().getAsString()); else Diag(R.getNameLoc(), diag::err_no_member_suggest) << Name << computeDeclContext(SS, false) << R.getLookupName() << SS.getRange() - << CodeModificationHint::CreateReplacement(R.getNameLoc(), - R.getLookupName().getAsString()); + << FixItHint::CreateReplacement(R.getNameLoc(), + R.getLookupName().getAsString()); if (NamedDecl *ND = R.getAsSingle<NamedDecl>()) Diag(ND->getLocation(), diag::note_previous_decl) << ND->getDeclName(); @@ -2614,8 +2613,8 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, (isa<ValueDecl>(*R.begin()) || isa<FunctionTemplateDecl>(*R.begin()))) { SemaRef.Diag(R.getNameLoc(), diag::err_no_member_suggest) << Name << DC << R.getLookupName() << SS.getRange() - << CodeModificationHint::CreateReplacement(R.getNameLoc(), - R.getLookupName().getAsString()); + << FixItHint::CreateReplacement(R.getNameLoc(), + R.getLookupName().getAsString()); if (NamedDecl *ND = R.getAsSingle<NamedDecl>()) SemaRef.Diag(ND->getLocation(), diag::note_previous_decl) << ND->getDeclName(); @@ -2893,7 +2892,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, SourceLocation Loc = PP.getLocForEndOfToken(BaseExpr->getLocEnd()); Diag(Loc, diag::err_member_reference_needs_call) << QualType(Fun, 0) - << CodeModificationHint::CreateInsertion(Loc, "()"); + << FixItHint::CreateInsertion(Loc, "()"); OwningExprResult NewBase = ActOnCallExpr(0, ExprArg(*this, BaseExpr), Loc, @@ -3012,7 +3011,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, // by now. Diag(OpLoc, diag::err_typecheck_member_reference_suggestion) << BaseType << int(IsArrow) << BaseExpr->getSourceRange() - << CodeModificationHint::CreateReplacement(OpLoc, "."); + << FixItHint::CreateReplacement(OpLoc, "."); IsArrow = false; } else { Diag(MemberLoc, diag::err_typecheck_member_reference_arrow) @@ -3032,7 +3031,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, if (PT && PT->getPointeeType()->isRecordType()) { Diag(OpLoc, diag::err_typecheck_member_reference_suggestion) << BaseType << int(IsArrow) << BaseExpr->getSourceRange() - << CodeModificationHint::CreateReplacement(OpLoc, "->"); + << FixItHint::CreateReplacement(OpLoc, "->"); BaseType = PT->getPointeeType(); IsArrow = true; } @@ -3071,8 +3070,8 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, Diag(R.getNameLoc(), diag::err_typecheck_member_reference_ivar_suggest) << IDecl->getDeclName() << MemberName << IV->getDeclName() - << CodeModificationHint::CreateReplacement(R.getNameLoc(), - IV->getNameAsString()); + << FixItHint::CreateReplacement(R.getNameLoc(), + IV->getNameAsString()); Diag(IV->getLocation(), diag::note_previous_decl) << IV->getDeclName(); } @@ -3246,8 +3245,8 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, Res.getAsSingle<ObjCPropertyDecl>()) { Diag(R.getNameLoc(), diag::err_property_not_found_suggest) << MemberName << BaseType << Res.getLookupName() - << CodeModificationHint::CreateReplacement(R.getNameLoc(), - Res.getLookupName().getAsString()); + << FixItHint::CreateReplacement(R.getNameLoc(), + Res.getLookupName().getAsString()); ObjCPropertyDecl *Property = Res.getAsSingle<ObjCPropertyDecl>(); Diag(Property->getLocation(), diag::note_previous_decl) << Property->getDeclName(); @@ -3576,7 +3575,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc, if (NumArgs > 0) { // Pseudo-destructor calls should not have any arguments. Diag(Fn->getLocStart(), diag::err_pseudo_dtor_call_with_args) - << CodeModificationHint::CreateRemoval( + << FixItHint::CreateRemoval( SourceRange(Args[0]->getLocStart(), Args[NumArgs-1]->getLocEnd())); @@ -5426,12 +5425,10 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, PDiag(diag::warn_stringcompare) << isa<ObjCEncodeExpr>(literalStringStripped) << literalString->getSourceRange() - << CodeModificationHint::CreateReplacement(SourceRange(Loc), ", ") - << CodeModificationHint::CreateInsertion(lex->getLocStart(), - "strcmp(") - << CodeModificationHint::CreateInsertion( - PP.getLocForEndOfToken(rex->getLocEnd()), - resultComparison)); + << FixItHint::CreateReplacement(SourceRange(Loc), ", ") + << FixItHint::CreateInsertion(lex->getLocStart(), "strcmp(") + << FixItHint::CreateInsertion(PP.getLocForEndOfToken(rex->getLocEnd()), + resultComparison)); } } @@ -6415,8 +6412,8 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc, } Self.Diag(Loc, PD) - << CodeModificationHint::CreateInsertion(ParenRange.getBegin(), "(") - << CodeModificationHint::CreateInsertion(EndLoc, ")"); + << FixItHint::CreateInsertion(ParenRange.getBegin(), "(") + << FixItHint::CreateInsertion(EndLoc, ")"); if (!SecondPD.getDiagID()) return; @@ -6430,8 +6427,8 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc, } Self.Diag(Loc, SecondPD) - << CodeModificationHint::CreateInsertion(SecondParenRange.getBegin(), "(") - << CodeModificationHint::CreateInsertion(EndLoc, ")"); + << FixItHint::CreateInsertion(SecondParenRange.getBegin(), "(") + << FixItHint::CreateInsertion(EndLoc, ")"); } /// DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison @@ -7135,11 +7132,8 @@ Sema::OwningExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) { return Owned(new (Context) GNUNullExpr(Ty, TokenLoc)); } -static void -MakeObjCStringLiteralCodeModificationHint(Sema& SemaRef, - QualType DstType, - Expr *SrcExpr, - CodeModificationHint &Hint) { +static void MakeObjCStringLiteralFixItHint(Sema& SemaRef, QualType DstType, + Expr *SrcExpr, FixItHint &Hint) { if (!SemaRef.getLangOptions().ObjC1) return; @@ -7160,7 +7154,7 @@ MakeObjCStringLiteralCodeModificationHint(Sema& SemaRef, if (!SL || SL->isWide()) return; - Hint = CodeModificationHint::CreateInsertion(SL->getLocStart(), "@"); + Hint = FixItHint::CreateInsertion(SL->getLocStart(), "@"); } bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, @@ -7170,7 +7164,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, // Decode the result (notice that AST's are still created for extensions). bool isInvalid = false; unsigned DiagKind; - CodeModificationHint Hint; + FixItHint Hint; switch (ConvTy) { default: assert(0 && "Unknown conversion type"); @@ -7182,7 +7176,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, DiagKind = diag::ext_typecheck_convert_int_pointer; break; case IncompatiblePointer: - MakeObjCStringLiteralCodeModificationHint(*this, DstType, SrcExpr, Hint); + MakeObjCStringLiteralFixItHint(*this, DstType, SrcExpr, Hint); DiagKind = diag::ext_typecheck_convert_incompatible_pointer; break; case IncompatiblePointerSign: @@ -7549,10 +7543,10 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) { Diag(Loc, diagnostic) << E->getSourceRange() - << CodeModificationHint::CreateInsertion(Open, "(") - << CodeModificationHint::CreateInsertion(Close, ")"); + << FixItHint::CreateInsertion(Open, "(") + << FixItHint::CreateInsertion(Close, ")"); Diag(Loc, diag::note_condition_assign_to_comparison) - << CodeModificationHint::CreateReplacement(Loc, "=="); + << FixItHint::CreateReplacement(Loc, "=="); } bool Sema::CheckBooleanCondition(Expr *&E, SourceLocation Loc) { |