From: Chris Lattner Date: Wed, 19 Nov 2008 05:27:50 +0000 (+0000) Subject: remove one more old-style Diag method. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dcd5ef12488e4c7ea844327835896ca86b609a97;p=clang remove one more old-style Diag method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59589 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index d1e4338999..1a9e1a062c 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -137,8 +137,8 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, bool isLvalue) { QualType BaseType = cast(TypeTy.getUnqualifiedType())->getPointeeType(); if (ExprBaseType.getAddressSpace() != BaseType.getAddressSpace()) { - Diag(Expr->getExprLoc(), diag::err_implicit_pointer_address_space_cast, - Expr->getSourceRange()); + Diag(Expr->getExprLoc(), diag::err_implicit_pointer_address_space_cast) + << Expr->getSourceRange(); } } @@ -184,11 +184,6 @@ bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, return true; } -bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const SourceRange& Range) { - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Range; - return true; -} - bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, const SourceRange& Range) { PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg << Range; diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index c3df6bae7d..4fc06f8a3f 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -244,7 +244,6 @@ public: const std::string &Msg2); /// More expressive diagnostic helpers for expressions (say that 6 times:-) - bool Diag(SourceLocation Loc, unsigned DiagID, const SourceRange& R1); bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, const SourceRange& R1); diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 741d939c2a..df428971d1 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -414,8 +414,8 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, // CHECK: printf-like function is called with no format string. if (format_idx >= TheCall->getNumArgs()) { - Diag(TheCall->getRParenLoc(), diag::warn_printf_missing_format_string, - Fn->getSourceRange()); + Diag(TheCall->getRParenLoc(), diag::warn_printf_missing_format_string) + << Fn->getSourceRange(); return; } @@ -466,16 +466,16 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, return; Diag(TheCall->getArg(format_idx)->getLocStart(), - diag::warn_printf_not_string_constant, - OrigFormatExpr->getSourceRange()); + diag::warn_printf_not_string_constant) + << OrigFormatExpr->getSourceRange(); return; } // CHECK: is the format string a wide literal? if (FExpr->isWide()) { Diag(FExpr->getLocStart(), - diag::warn_printf_format_string_is_wide_literal, - OrigFormatExpr->getSourceRange()); + diag::warn_printf_format_string_is_wide_literal) + << OrigFormatExpr->getSourceRange(); return; } @@ -486,8 +486,8 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, const unsigned StrLen = FExpr->getByteLength(); if (StrLen == 0) { - Diag(FExpr->getLocStart(), diag::warn_printf_empty_format_string, - OrigFormatExpr->getSourceRange()); + Diag(FExpr->getLocStart(), diag::warn_printf_empty_format_string) + << OrigFormatExpr->getSourceRange(); return; } @@ -526,8 +526,8 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, // The string returned by getStrData() is not null-terminated, // so the presence of a null character is likely an error. Diag(PP.AdvanceToTokenCharacter(FExpr->getLocStart(), StrIdx+1), - diag::warn_printf_format_string_contains_null_char, - OrigFormatExpr->getSourceRange()); + diag::warn_printf_format_string_contains_null_char) + << OrigFormatExpr->getSourceRange(); return; } @@ -551,11 +551,11 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, Loc = PP.AdvanceToTokenCharacter(Loc, StrIdx+1); if (Str[StrIdx-1] == '.') - Diag(Loc, diag::warn_printf_asterisk_precision_missing_arg, - OrigFormatExpr->getSourceRange()); + Diag(Loc, diag::warn_printf_asterisk_precision_missing_arg) + << OrigFormatExpr->getSourceRange(); else - Diag(Loc, diag::warn_printf_asterisk_width_missing_arg, - OrigFormatExpr->getSourceRange()); + Diag(Loc, diag::warn_printf_asterisk_width_missing_arg) + << OrigFormatExpr->getSourceRange(); // Don't do any more checking. We'll just emit spurious errors. return; @@ -571,11 +571,11 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, PP.AdvanceToTokenCharacter(FExpr->getLocStart(), StrIdx+1); if (Str[StrIdx-1] == '.') - Diag(Loc, diag::warn_printf_asterisk_precision_wrong_type, - E->getType().getAsString(), E->getSourceRange()); + Diag(Loc, diag::warn_printf_asterisk_precision_wrong_type) + << E->getType().getAsString() << E->getSourceRange(); else - Diag(Loc, diag::warn_printf_asterisk_width_wrong_type, - E->getType().getAsString(), E->getSourceRange()); + Diag(Loc, diag::warn_printf_asterisk_width_wrong_type) + << E->getType().getAsString() << E->getSourceRange(); break; } @@ -618,7 +618,7 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, SourceLocation Loc = PP.AdvanceToTokenCharacter(FExpr->getLocStart(), LastConversionIdx+1); - Diag(Loc, diag::warn_printf_write_back, OrigFormatExpr->getSourceRange()); + Diag(Loc, diag::warn_printf_write_back)<getSourceRange(); break; } @@ -690,15 +690,15 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, SourceLocation Loc = PP.AdvanceToTokenCharacter(FExpr->getLocStart(), LastConversionIdx); - Diag(Loc, diag::warn_printf_insufficient_data_args, - OrigFormatExpr->getSourceRange()); + Diag(Loc, diag::warn_printf_insufficient_data_args) + << OrigFormatExpr->getSourceRange(); } // CHECK: Does the number of data arguments exceed the number of // format conversions in the format string? else if (numConversions < numDataArgs) Diag(TheCall->getArg(format_idx+numConversions+1)->getLocStart(), - diag::warn_printf_too_many_data_args, - OrigFormatExpr->getSourceRange()); + diag::warn_printf_too_many_data_args) + << OrigFormatExpr->getSourceRange(); } } @@ -726,16 +726,16 @@ Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, RetValExp = IcExpr->getSubExpr(); if (BlockExpr *C = dyn_cast_or_null(RetValExp)) - Diag(C->getLocStart(), diag::err_ret_local_block, - C->getSourceRange()); + Diag(C->getLocStart(), diag::err_ret_local_block) + << C->getSourceRange(); } // Perform checking for stack values returned by reference. else if (lhsType->isReferenceType()) { // Check for a reference to the stack if (DeclRefExpr *DR = EvalVal(RetValExp)) - Diag(DR->getLocStart(), diag::warn_ret_stack_ref, - DR->getDecl()->getIdentifier()->getName(), - RetValExp->getSourceRange()); + Diag(DR->getLocStart(), diag::warn_ret_stack_ref) + << DR->getDecl()->getIdentifier()->getName() + << RetValExp->getSourceRange(); } } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 24308f6b4a..c9fbdc4cb2 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -640,8 +640,8 @@ bool Sema::CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT) { // FIXME: Avoid truncation for 64-bit length strings. if (strLiteral->getByteLength() > (unsigned)CAT->getSize().getZExtValue()) Diag(strLiteral->getSourceRange().getBegin(), - diag::warn_initializer_string_for_char_array_too_long, - strLiteral->getSourceRange()); + diag::warn_initializer_string_for_char_array_too_long) + << strLiteral->getSourceRange(); } // Set type from "char *" to "constant array of char". strLiteral->setType(DeclT); @@ -670,9 +670,8 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType, // C99 6.7.8p3: The type of the entity to be initialized shall be an array // of unknown size ("[]") or an object type that is not a variable array type. if (const VariableArrayType *VAT = Context.getAsVariableArrayType(DeclType)) - return Diag(InitLoc, - diag::err_variable_object_no_init, - VAT->getSizeExpr()->getSourceRange()); + return Diag(InitLoc, diag::err_variable_object_no_init) + << VAT->getSizeExpr()->getSourceRange(); InitListExpr *InitList = dyn_cast(Init); if (!InitList) { @@ -724,9 +723,8 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType, // C99 6.7.8p16. if (DeclType->isArrayType()) - return Diag(Init->getLocStart(), - diag::err_array_init_list_required, - Init->getSourceRange()); + return Diag(Init->getLocStart(), diag::err_array_init_list_required) + << Init->getSourceRange(); return CheckSingleInitializer(Init, DeclType); } else if (getLangOptions().CPlusPlus) { @@ -741,10 +739,8 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType, if (const RecordType *ClassRec = DeclType->getAsRecordType()) { const CXXRecordDecl *ClassDecl = cast(ClassRec->getDecl()); if (!ClassDecl->isAggregate()) - return Diag(InitLoc, - diag::err_init_non_aggr_init_list, - DeclType.getAsString(), - Init->getSourceRange()); + return Diag(InitLoc, diag::err_init_non_aggr_init_list) + << DeclType.getAsString() << Init->getSourceRange(); } } @@ -1228,8 +1224,8 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { } void Sema::InitializerElementNotConstant(const Expr *Init) { - Diag(Init->getExprLoc(), - diag::err_init_element_not_constant, Init->getSourceRange()); + Diag(Init->getExprLoc(), diag::err_init_element_not_constant) + << Init->getSourceRange(); } bool Sema::CheckAddressConstantExpressionLValue(const Expr* Init) { @@ -1633,8 +1629,8 @@ bool Sema::CheckArithmeticConstantExpression(const Expr* Init) { // emit a warning that this is a GNU extension. if (FalseSide && !FalseSide->isEvaluatable(Context)) Diag(Init->getExprLoc(), - diag::ext_typecheck_expression_not_constant_but_accepted, - FalseSide->getSourceRange()); + diag::ext_typecheck_expression_not_constant_but_accepted) + << FalseSide->getSourceRange(); return false; } } @@ -2673,7 +2669,7 @@ Sema::DeclTy *Sema::ActOnIvar(Scope *S, // than a variably modified type. if (T->isVariablyModifiedType()) { // FIXME: This diagnostic needs work - Diag(Loc, diag::err_typecheck_illegal_vla, Loc); + Diag(Loc, diag::err_typecheck_illegal_vla) << SourceRange(Loc); InvalidDecl = true; } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index f2de5b21d8..7a94309f64 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1370,8 +1370,8 @@ void Sema::AddCXXDirectInitializerToDecl(DeclTy *Dcl, SourceLocation LParenLoc, } if (NumExprs > 1) { - Diag(CommaLocs[0], diag::err_builtin_direct_init_more_than_one_arg, - SourceRange(VDecl->getLocation(), RParenLoc)); + Diag(CommaLocs[0], diag::err_builtin_direct_init_more_than_one_arg) + << SourceRange(VDecl->getLocation(), RParenLoc); RealDecl->setInvalidDecl(); return; } diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index cae6fe649a..07d25f0114 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -831,11 +831,11 @@ ObjCMethodDecl *Sema::LookupInstanceMethodInGlobalPool(Selector Sel, } if (issueWarning && (MethList.Method && MethList.Next)) { Diag(R.getBegin(), diag::warn_multiple_method_decl, Sel.getName(), R); - Diag(MethList.Method->getLocStart(), diag::warn_using_decl, - MethList.Method->getSourceRange()); + Diag(MethList.Method->getLocStart(), diag::warn_using_decl) + << MethList.Method->getSourceRange(); for (ObjCMethodList *Next = MethList.Next; Next; Next = Next->Next) - Diag(Next->Method->getLocStart(), diag::warn_also_found_decl, - Next->Method->getSourceRange()); + Diag(Next->Method->getLocStart(), diag::warn_also_found_decl) + << Next->Method->getSourceRange(); } return MethList.Method; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d4307c1e3e..853ecaf3fa 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1421,11 +1421,11 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 // The following || allows only one side to be void (a GCC-ism). if (lexT->isVoidType() || rexT->isVoidType()) { if (!lexT->isVoidType()) - Diag(rex->getLocStart(), diag::ext_typecheck_cond_one_void, - rex->getSourceRange()); + Diag(rex->getLocStart(), diag::ext_typecheck_cond_one_void) + << rex->getSourceRange(); if (!rexT->isVoidType()) - Diag(lex->getLocStart(), diag::ext_typecheck_cond_one_void, - lex->getSourceRange()); + Diag(lex->getLocStart(), diag::ext_typecheck_cond_one_void) + << lex->getSourceRange(); ImpCastExprToType(lex, Context.VoidTy); ImpCastExprToType(rex, Context.VoidTy); return Context.VoidTy; @@ -2387,9 +2387,9 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) { } if (NeedType) - S.Diag(Loc, Diag, E->getType().getAsString(), E->getSourceRange()); + S.Diag(Loc, Diag) << E->getType().getAsString() << E->getSourceRange(); else - S.Diag(Loc, Diag, E->getSourceRange()); + S.Diag(Loc, Diag) << E->getSourceRange(); return true; } @@ -2464,21 +2464,21 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc) { // C99 6.5.2.4p1: We allow complex as a GCC extension. if (const PointerType *pt = resType->getAsPointerType()) { if (pt->getPointeeType()->isVoidType()) { - Diag(OpLoc, diag::ext_gnu_void_ptr, op->getSourceRange()); + Diag(OpLoc, diag::ext_gnu_void_ptr) << op->getSourceRange(); } else if (!pt->getPointeeType()->isObjectType()) { // C99 6.5.2.4p2, 6.5.6p2 - Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type, - resType.getAsString(), op->getSourceRange()); + Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type) + << resType.getAsString() << op->getSourceRange(); return QualType(); } } else if (!resType->isRealType()) { if (resType->isComplexType()) // C99 does not support ++/-- on complex types. - Diag(OpLoc, diag::ext_integer_increment_complex, - resType.getAsString(), op->getSourceRange()); + Diag(OpLoc, diag::ext_integer_increment_complex) + << resType.getAsString() << op->getSourceRange(); else { - Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement, - resType.getAsString(), op->getSourceRange()); + Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement) + << resType.getAsString() << op->getSourceRange(); return QualType(); } } @@ -2595,8 +2595,8 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) { if (lval != Expr::LV_Valid) { // C99 6.5.3.2p1 if (!dcl || !isa(dcl)) {// allow function designators // FIXME: emit more specific diag... - Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof, - op->getSourceRange()); + Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof) + << op->getSourceRange(); return QualType(); } } else if (MemberExpr *MemExpr = dyn_cast(op)) { // C99 6.5.3.2p1 @@ -3069,8 +3069,8 @@ Sema::ExprResult Sema::ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc, // offsetof with non-identifier designators (e.g. "offsetof(x, a.b[c])") are a // GCC extension, diagnose them. if (NumComponents != 1) - Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator, - SourceRange(CompPtr[1].LocStart, CompPtr[NumComponents-1].LocEnd)); + Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator) + << SourceRange(CompPtr[1].LocStart, CompPtr[NumComponents-1].LocEnd); for (unsigned i = 0; i != NumComponents; ++i) { const OffsetOfComponent &OC = CompPtr[i]; @@ -3088,8 +3088,8 @@ Sema::ExprResult Sema::ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc, // C99 6.5.2.1p1 Expr *Idx = static_cast(OC.U.E); if (!Idx->getType()->isIntegerType()) - return Diag(Idx->getLocStart(), diag::err_typecheck_subscript, - Idx->getSourceRange()); + return Diag(Idx->getLocStart(), diag::err_typecheck_subscript) + << Idx->getSourceRange(); Res = new ArraySubscriptExpr(Res, Idx, AT->getElementType(), OC.LocEnd); continue; @@ -3147,8 +3147,8 @@ Sema::ExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc, ExprTy *cond, llvm::APSInt condEval(32); SourceLocation ExpLoc; if (!CondExpr->isIntegerConstantExpr(condEval, Context, &ExpLoc)) - return Diag(ExpLoc, diag::err_typecheck_choose_expr_requires_constant, - CondExpr->getSourceRange()); + return Diag(ExpLoc, diag::err_typecheck_choose_expr_requires_constant) + << CondExpr->getSourceRange(); // If the condition is > zero, then the AST type is the same as the LSHExpr. QualType resType = condEval.getZExtValue() ? LHSExpr->getType() : @@ -3277,8 +3277,8 @@ Sema::ExprResult Sema::ActOnOverloadExpr(ExprTy **args, unsigned NumArgs, SourceLocation RParenLoc) { // __builtin_overload requires at least 2 arguments if (NumArgs < 2) - return Diag(RParenLoc, diag::err_typecheck_call_too_few_args, - SourceRange(BuiltinLoc, RParenLoc)); + return Diag(RParenLoc, diag::err_typecheck_call_too_few_args) + << SourceRange(BuiltinLoc, RParenLoc); // The first argument is required to be a constant expression. It tells us // the number of arguments to pass to each of the functions to be overloaded. @@ -3287,18 +3287,18 @@ Sema::ExprResult Sema::ActOnOverloadExpr(ExprTy **args, unsigned NumArgs, llvm::APSInt constEval(32); SourceLocation ExpLoc; if (!NParamsExpr->isIntegerConstantExpr(constEval, Context, &ExpLoc)) - return Diag(ExpLoc, diag::err_overload_expr_requires_non_zero_constant, - NParamsExpr->getSourceRange()); + return Diag(ExpLoc, diag::err_overload_expr_requires_non_zero_constant) + << NParamsExpr->getSourceRange(); // Verify that the number of parameters is > 0 unsigned NumParams = constEval.getZExtValue(); if (NumParams == 0) - return Diag(ExpLoc, diag::err_overload_expr_requires_non_zero_constant, - NParamsExpr->getSourceRange()); + return Diag(ExpLoc, diag::err_overload_expr_requires_non_zero_constant) + << NParamsExpr->getSourceRange(); // Verify that we have at least 1 + NumParams arguments to the builtin. if ((NumParams + 1) > NumArgs) - return Diag(RParenLoc, diag::err_typecheck_call_too_few_args, - SourceRange(BuiltinLoc, RParenLoc)); + return Diag(RParenLoc, diag::err_typecheck_call_too_few_args) + << SourceRange(BuiltinLoc, RParenLoc); // Figure out the return type, by matching the args to one of the functions // listed after the parameters. @@ -3315,16 +3315,16 @@ Sema::ExprResult Sema::ActOnOverloadExpr(ExprTy **args, unsigned NumArgs, // parameters, and the number of parameters must match the value passed to // the builtin. if (!FnType || (FnType->getNumArgs() != NumParams)) - return Diag(Fn->getExprLoc(), diag::err_overload_incorrect_fntype, - Fn->getSourceRange()); + return Diag(Fn->getExprLoc(), diag::err_overload_incorrect_fntype) + << Fn->getSourceRange(); // Scan the parameter list for the FunctionType, checking the QualType of // each parameter against the QualTypes of the arguments to the builtin. // If they match, return a new OverloadExpr. if (ExprsMatchFnType(Args+1, FnType, Context)) { if (OE) - return Diag(Fn->getExprLoc(), diag::err_overload_multiple_match, - OE->getFn()->getSourceRange()); + return Diag(Fn->getExprLoc(), diag::err_overload_multiple_match) + << OE->getFn()->getSourceRange(); // Remember our match, and continue processing the remaining arguments // to catch any errors. OE = new OverloadExpr(Args, NumArgs, i, diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 5864f222df..94fca00779 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -156,8 +156,8 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, // be a class with a suitably declared constructor. // if (NumExprs > 1) - return Diag(CommaLocs[0], diag::err_builtin_func_cast_more_than_one_arg, - FullRange); + return Diag(CommaLocs[0], diag::err_builtin_func_cast_more_than_one_arg) + << FullRange; assert(NumExprs == 0 && "Expected 0 expressions"); @@ -167,10 +167,10 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, // rvalue of the specified type, which is value-initialized. // if (Ty->isArrayType()) - return Diag(TyBeginLoc, diag::err_value_init_for_array_type, FullRange); + return Diag(TyBeginLoc, diag::err_value_init_for_array_type) << FullRange; if (Ty->isIncompleteType() && !Ty->isVoidType()) - return Diag(TyBeginLoc, diag::err_invalid_incomplete_type_use, - Ty.getAsString(), FullRange); + return Diag(TyBeginLoc, diag::err_invalid_incomplete_type_use) + << Ty.getAsString() << FullRange; return new CXXZeroInitValueExpr(Ty, TyBeginLoc, RParenLoc); } @@ -199,11 +199,11 @@ Sema::ActOnCXXConditionDeclarationExpr(Scope *S, SourceLocation StartLoc, if (Ty->isFunctionType()) { // The declarator shall not specify a function... // We exit without creating a CXXConditionDeclExpr because a FunctionDecl // would be created and CXXConditionDeclExpr wants a VarDecl. - return Diag(StartLoc, diag::err_invalid_use_of_function_type, - SourceRange(StartLoc, EqualLoc)); + return Diag(StartLoc, diag::err_invalid_use_of_function_type) + << SourceRange(StartLoc, EqualLoc); } else if (Ty->isArrayType()) { // ...or an array. - Diag(StartLoc, diag::err_invalid_use_of_array_type, - SourceRange(StartLoc, EqualLoc)); + Diag(StartLoc, diag::err_invalid_use_of_array_type) + << SourceRange(StartLoc, EqualLoc); } else if (const RecordType *RT = Ty->getAsRecordType()) { RecordDecl *RD = RT->getDecl(); // The type-specifier-seq shall not declare a new class... diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 0e627a1aab..a2bbbba688 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -110,20 +110,20 @@ void InitListChecker::CheckExplicitInitList(InitListExpr *IList, QualType &T, SemaRef->IsStringLiteralInit(IList->getInit(Index), T)) { // Special-case SemaRef->Diag(IList->getInit(Index)->getLocStart(), - diag::err_excess_initializers_in_char_array_initializer, - IList->getInit(Index)->getSourceRange()); + diag::err_excess_initializers_in_char_array_initializer) + << IList->getInit(Index)->getSourceRange(); hadError = true; } else if (!T->isIncompleteType()) { // Don't warn for incomplete types, since we'll get an error elsewhere SemaRef->Diag(IList->getInit(Index)->getLocStart(), - diag::warn_excess_initializers, - IList->getInit(Index)->getSourceRange()); + diag::warn_excess_initializers) + << IList->getInit(Index)->getSourceRange(); } } if (T->isScalarType()) - SemaRef->Diag(IList->getLocStart(), diag::warn_braces_around_scalar_init, - IList->getSourceRange()); + SemaRef->Diag(IList->getLocStart(), diag::warn_braces_around_scalar_init) + << IList->getSourceRange(); } void InitListChecker::CheckListElementTypes(InitListExpr *IList, @@ -185,8 +185,8 @@ void InitListChecker::CheckScalarType(InitListExpr *IList, QualType &DeclType, Expr* expr = IList->getInit(Index); if (isa(expr)) { SemaRef->Diag(IList->getLocStart(), - diag::err_many_braces_around_scalar_init, - IList->getSourceRange()); + diag::err_many_braces_around_scalar_init) + << IList->getSourceRange(); hadError = true; ++Index; return; @@ -199,9 +199,8 @@ void InitListChecker::CheckScalarType(InitListExpr *IList, QualType &DeclType, IList->setInit(Index, expr); ++Index; } else { - SemaRef->Diag(IList->getLocStart(), - diag::err_empty_scalar_initializer, - IList->getSourceRange()); + SemaRef->Diag(IList->getLocStart(), diag::err_empty_scalar_initializer) + << IList->getSourceRange(); hadError = true; return; } @@ -240,8 +239,8 @@ void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType, // earlier, but I don't know where clang accepts VLAs (gcc accepts // them in all sorts of strange places). SemaRef->Diag(VAT->getSizeExpr()->getLocStart(), - diag::err_variable_object_no_init, - VAT->getSizeExpr()->getSourceRange()); + diag::err_variable_object_no_init) + << VAT->getSizeExpr()->getSourceRange(); hadError = true; return; } diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 70231ec1be..4b239be6e2 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -128,15 +128,15 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprTy *lhsval, SourceLocation ExpLoc; // C99 6.8.4.2p3: The expression shall be an integer constant. if (!LHSVal->isIntegerConstantExpr(Context, &ExpLoc)) { - Diag(ExpLoc, diag::err_case_label_not_integer_constant_expr, - LHSVal->getSourceRange()); + Diag(ExpLoc, diag::err_case_label_not_integer_constant_expr) + << LHSVal->getSourceRange(); return SubStmt; } // GCC extension: The expression shall be an integer constant. if (RHSVal && !RHSVal->isIntegerConstantExpr(Context, &ExpLoc)) { - Diag(ExpLoc, diag::err_case_label_not_integer_constant_expr, - RHSVal->getSourceRange()); + Diag(ExpLoc, diag::err_case_label_not_integer_constant_expr) + << RHSVal->getSourceRange(); RHSVal = 0; // Recover by just forgetting about it. } @@ -458,9 +458,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch, // If the low value is bigger than the high value, the case is empty. if (CaseRanges[i].first > HiVal) { - Diag(CR->getLHS()->getLocStart(), diag::warn_case_empty_range, - SourceRange(CR->getLHS()->getLocStart(), - CR->getRHS()->getLocEnd())); + Diag(CR->getLHS()->getLocStart(), diag::warn_case_empty_range) + << SourceRange(CR->getLHS()->getLocStart(), + CR->getRHS()->getLocEnd()); CaseRanges.erase(CaseRanges.begin()+i); --i, --e; continue; @@ -625,21 +625,21 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, Expr::isLvalueResult lval = cast(First)->isLvalue(Context); if (lval != Expr::LV_Valid) - return Diag(First->getLocStart(), diag::err_selector_element_not_lvalue, - First->getSourceRange()); + return Diag(First->getLocStart(), diag::err_selector_element_not_lvalue) + << First->getSourceRange(); FirstType = static_cast(first)->getType(); } if (!Context.isObjCObjectPointerType(FirstType)) - Diag(ForLoc, diag::err_selector_element_type, - FirstType.getAsString(), First->getSourceRange()); + Diag(ForLoc, diag::err_selector_element_type) + << FirstType.getAsString() << First->getSourceRange(); } if (Second) { DefaultFunctionArrayConversion(Second); QualType SecondType = Second->getType(); if (!Context.isObjCObjectPointerType(SecondType)) - Diag(ForLoc, diag::err_collection_expr_type, - SecondType.getAsString(), Second->getSourceRange()); + Diag(ForLoc, diag::err_collection_expr_type) + << SecondType.getAsString() << Second->getSourceRange(); } return new ObjCForCollectionStmt(First, Second, Body, ForLoc, RParenLoc); } @@ -814,16 +814,16 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, // The parser verifies that there is a string literal here. if (AsmString->isWide()) // FIXME: We currently leak memory here. - return Diag(AsmString->getLocStart(), diag::err_asm_wide_character, - AsmString->getSourceRange()); + return Diag(AsmString->getLocStart(), diag::err_asm_wide_character) + << AsmString->getSourceRange(); for (unsigned i = 0; i != NumOutputs; i++) { StringLiteral *Literal = Constraints[i]; if (Literal->isWide()) // FIXME: We currently leak memory here. - return Diag(Literal->getLocStart(), diag::err_asm_wide_character, - Literal->getSourceRange()); + return Diag(Literal->getLocStart(), diag::err_asm_wide_character) + << Literal->getSourceRange(); std::string OutputConstraint(Literal->getStrData(), Literal->getByteLength()); @@ -840,8 +840,8 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, if (Result != Expr::LV_Valid) { // FIXME: We currently leak memory here. return Diag(OutputExpr->getSubExpr()->getLocStart(), - diag::err_asm_invalid_lvalue_in_output, - OutputExpr->getSubExpr()->getSourceRange()); + diag::err_asm_invalid_lvalue_in_output) + << OutputExpr->getSubExpr()->getSourceRange(); } } @@ -849,8 +849,8 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, StringLiteral *Literal = Constraints[i]; if (Literal->isWide()) // FIXME: We currently leak memory here. - return Diag(Literal->getLocStart(), diag::err_asm_wide_character, - Literal->getSourceRange()); + return Diag(Literal->getLocStart(), diag::err_asm_wide_character) + << Literal->getSourceRange(); std::string InputConstraint(Literal->getStrData(), Literal->getByteLength()); @@ -860,7 +860,7 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, NumOutputs, info)) { // FIXME: We currently leak memory here. return Diag(Literal->getLocStart(), - diag::err_asm_invalid_input_constraint, InputConstraint); + diag::err_asm_invalid_input_constraint) << InputConstraint; } // Check that the input exprs aren't of type void. @@ -880,8 +880,8 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, StringLiteral *Literal = Clobbers[i]; if (Literal->isWide()) // FIXME: We currently leak memory here. - return Diag(Literal->getLocStart(), diag::err_asm_wide_character, - Literal->getSourceRange()); + return Diag(Literal->getLocStart(), diag::err_asm_wide_character) + << Literal->getSourceRange(); llvm::SmallString<16> Clobber(Literal->getStrData(), Literal->getStrData() + diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 85c57f53ad..945082ad46 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -405,14 +405,14 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { // have a value greater than zero. if (ConstVal.isSigned()) { if (ConstVal.isNegative()) { - Diag(ArraySize->getLocStart(), - diag::err_typecheck_negative_array_size, - ArraySize->getSourceRange()); + Diag(ArraySize->getLocStart(), + diag::err_typecheck_negative_array_size) + << ArraySize->getSourceRange(); D.setInvalidType(true); } else if (ConstVal == 0) { // GCC accepts zero sized static arrays. - Diag(ArraySize->getLocStart(), diag::ext_typecheck_zero_array_size, - ArraySize->getSourceRange()); + Diag(ArraySize->getLocStart(), diag::ext_typecheck_zero_array_size) + << ArraySize->getSourceRange(); } } T = Context.getConstantArrayType(T, ConstVal, ASM, ATI.TypeQuals); @@ -663,8 +663,8 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type, Expr *ASArgExpr = static_cast(Attr.getArg(0)); llvm::APSInt addrSpace(32); if (!ASArgExpr->isIntegerConstantExpr(addrSpace, S.Context)) { - S.Diag(Attr.getLoc(), diag::err_attribute_address_space_not_int, - ASArgExpr->getSourceRange()); + S.Diag(Attr.getLoc(), diag::err_attribute_address_space_not_int) + << ASArgExpr->getSourceRange(); return; }