diff options
-rw-r--r-- | lib/Sema/Sema.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 4 | ||||
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 22 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 14 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 22 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 61 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaNamedCast.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 32 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 50 |
11 files changed, 109 insertions, 125 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index c9e4cd9833..063399aee7 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -173,12 +173,6 @@ bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, 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; - return true; -} - const LangOptions &Sema::getLangOptions() const { return PP.getLangOptions(); } diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 52610ef6b7..5f3d466174 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -232,10 +232,6 @@ public: bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, const std::string &Msg2); - /// More expressive diagnostic helpers for expressions (say that 6 times:-) - bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, - const SourceRange& R1); - virtual void DeleteExpr(ExprTy *E); virtual void DeleteStmt(StmtTy *S); diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 7e6c6362de..eb961d14fa 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -632,10 +632,10 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, SourceLocation Loc = PP.AdvanceToTokenCharacter(FExpr->getLocStart(), LastConversionIdx+1); - Diag(Loc, diag::warn_printf_invalid_conversion, - std::string(Str+LastConversionIdx, - Str+std::min(LastConversionIdx+2, StrLen)), - OrigFormatExpr->getSourceRange()); + Diag(Loc, diag::warn_printf_invalid_conversion) + << std::string(Str+LastConversionIdx, + Str+std::min(LastConversionIdx+2, StrLen)) + << OrigFormatExpr->getSourceRange(); } ++numConversions; break; @@ -653,9 +653,9 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, SourceLocation Loc = PP.AdvanceToTokenCharacter(FExpr->getLocStart(), LastConversionIdx+1); - Diag(Loc, diag::warn_printf_invalid_conversion, - std::string(Str+LastConversionIdx, Str+StrIdx), - OrigFormatExpr->getSourceRange()); + Diag(Loc, diag::warn_printf_invalid_conversion) + << std::string(Str+LastConversionIdx, Str+StrIdx) + << OrigFormatExpr->getSourceRange(); // This conversion is broken. Advance to the next format // conversion. @@ -676,10 +676,10 @@ Sema::CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, SourceLocation Loc = PP.AdvanceToTokenCharacter(FExpr->getLocStart(), LastConversionIdx+1); - Diag(Loc, diag::warn_printf_invalid_conversion, - std::string(Str+LastConversionIdx, - Str+std::min(LastConversionIdx+2, StrLen)), - OrigFormatExpr->getSourceRange()); + Diag(Loc, diag::warn_printf_invalid_conversion) + << std::string(Str+LastConversionIdx, + Str+std::min(LastConversionIdx+2, StrLen)) + << OrigFormatExpr->getSourceRange(); return; } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index aa2154f0c6..ad656a351a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -841,16 +841,16 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { // if (PrevDecl == 0) { // No previous declaration in the qualifying scope. - Diag(D.getIdentifierLoc(), diag::err_typecheck_no_member, - Name.getAsString(), D.getCXXScopeSpec().getRange()); + Diag(D.getIdentifierLoc(), diag::err_typecheck_no_member) + << Name.getAsString() << D.getCXXScopeSpec().getRange(); } else if (!CurContext->Encloses(DC)) { // The qualifying scope doesn't enclose the original declaration. // Emit diagnostic based on current scope. SourceLocation L = D.getIdentifierLoc(); SourceRange R = D.getCXXScopeSpec().getRange(); if (isa<FunctionDecl>(CurContext)) { - Diag(L, diag::err_invalid_declarator_in_function, Name.getAsString(), - R); + Diag(L, diag::err_invalid_declarator_in_function) + << Name.getAsString() << R; } else { Diag(L, diag::err_invalid_declarator_scope) << Name.getAsString() << cast<NamedDecl>(DC)->getName() << R; @@ -1808,10 +1808,8 @@ void Sema::ActOnUninitializedDecl(DeclTy *dcl) { // within its class declaration (9.2), and where the extern // specifier is explicitly used. if (Type->isReferenceType() && Var->getStorageClass() != VarDecl::Extern) { - Diag(Var->getLocation(), - diag::err_reference_var_requires_init, - Var->getName(), - SourceRange(Var->getLocation(), Var->getLocation())); + Diag(Var->getLocation(), diag::err_reference_var_requires_init) + << Var->getName() << SourceRange(Var->getLocation(), Var->getLocation()); Var->setInvalidDecl(); return; } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index bf160ac545..743f6a8d1d 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -576,15 +576,15 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, } else { // not const integral. - Diag(Loc, diag::err_member_initialization, - Name.getAsString(), Init->getSourceRange()); + Diag(Loc, diag::err_member_initialization) + << Name.getAsString() << Init->getSourceRange(); InvalidDecl = true; } } else { // not static member. - Diag(Loc, diag::err_member_initialization, - Name.getAsString(), Init->getSourceRange()); + Diag(Loc, diag::err_member_initialization) + << Name.getAsString() << Init->getSourceRange(); InvalidDecl = true; } } @@ -1442,18 +1442,16 @@ Sema::PerformInitializationByConstructor(QualType ClassType, case OR_No_Viable_Function: if (CandidateSet.empty()) - Diag(Loc, diag::err_ovl_no_viable_function_in_init, - InitEntity, Range); + Diag(Loc, diag::err_ovl_no_viable_function_in_init) << InitEntity, Range; else { - Diag(Loc, diag::err_ovl_no_viable_function_in_init_with_cands, - InitEntity, Range); + Diag(Loc, diag::err_ovl_no_viable_function_in_init_with_cands) + << InitEntity << Range; PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false); } return 0; case OR_Ambiguous: - Diag(Loc, diag::err_ovl_ambiguous_init, - InitEntity, Range); + Diag(Loc, diag::err_ovl_ambiguous_init) << InitEntity << Range; PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true); return 0; } @@ -1848,8 +1846,8 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) { Param != FnDecl->param_end(); ++Param) { if (Expr *DefArg = (*Param)->getDefaultArg()) return Diag((*Param)->getLocation(), - diag::err_operator_overload_default_arg, - FnDecl->getName(), DefArg->getSourceRange()); + diag::err_operator_overload_default_arg) + << FnDecl->getName() << DefArg->getSourceRange(); } } diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 6e90e8403d..7c54962f40 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -581,7 +581,7 @@ void Sema::WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method, Diag(ImpLoc, diag::warn_incomplete_impl); IncompleteImpl = true; } - Diag(ImpLoc, diag::warn_undef_method_impl, method->getSelector().getName()); + Diag(ImpLoc, diag::warn_undef_method_impl) << method->getSelector().getName(); } /// FIXME: Type hierarchies in Objective-C can be deep. We could most @@ -824,7 +824,7 @@ ObjCMethodDecl *Sema::LookupInstanceMethodInGlobalPool(Selector Sel, issueWarning = true; } if (issueWarning && (MethList.Method && MethList.Next)) { - Diag(R.getBegin(), diag::warn_multiple_method_decl, Sel.getName(), R); + Diag(R.getBegin(), diag::warn_multiple_method_decl) << Sel.getName() << R; Diag(MethList.Method->getLocStart(), diag::warn_using_decl) << MethList.Method->getSourceRange(); for (ObjCMethodList *Next = MethList.Next; Next; Next = Next->Next) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 12f059e11a..46831dcef0 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -416,8 +416,8 @@ Sema::ExprResult Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, // If this name wasn't predeclared and if this is not a function call, // diagnose the problem. if (SS && !SS->isEmpty()) - return Diag(Loc, diag::err_typecheck_no_member, - Name.getAsString(), SS->getRange()); + return Diag(Loc, diag::err_typecheck_no_member) + << Name.getAsString() << SS->getRange(); else if (Name.getNameKind() == DeclarationName::CXXOperatorName || Name.getNameKind() == DeclarationName::CXXConversionFunctionName) return Diag(Loc, diag::err_undeclared_use) << Name.getAsString(); @@ -2598,9 +2598,9 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS, Loc.isFileID() && UO->getOperatorLoc().isFileID() && // Only if the two operators are exactly adjacent. Loc.getFileLocWithOffset(1) == UO->getOperatorLoc()) - Diag(Loc, diag::warn_not_compound_assign, - UO->getOpcode() == UnaryOperator::Plus ? "+" : "-", - SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc())); + Diag(Loc, diag::warn_not_compound_assign) + << (UO->getOpcode() == UnaryOperator::Plus ? "+" : "-") + << SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc()); } } else { // Compound assignment "x += y" @@ -2776,23 +2776,23 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) { } } else if (MemberExpr *MemExpr = dyn_cast<MemberExpr>(op)) { // C99 6.5.3.2p1 if (MemExpr->getMemberDecl()->isBitField()) { - Diag(OpLoc, diag::err_typecheck_address_of, - std::string("bit-field"), op->getSourceRange()); + Diag(OpLoc, diag::err_typecheck_address_of) + << "bit-field" << op->getSourceRange(); return QualType(); } // Check for Apple extension for accessing vector components. } else if (isa<ArraySubscriptExpr>(op) && cast<ArraySubscriptExpr>(op)->getBase()->getType()->isVectorType()) { - Diag(OpLoc, diag::err_typecheck_address_of, - std::string("vector"), op->getSourceRange()); + Diag(OpLoc, diag::err_typecheck_address_of) + << "vector" << op->getSourceRange(); return QualType(); } else if (dcl) { // C99 6.5.3.2p1 // We have an lvalue with a decl. Make sure the decl is not declared // with the register storage-class specifier. if (const VarDecl *vd = dyn_cast<VarDecl>(dcl)) { if (vd->getStorageClass() == VarDecl::Register) { - Diag(OpLoc, diag::err_typecheck_address_of, - std::string("register variable"), op->getSourceRange()); + Diag(OpLoc, diag::err_typecheck_address_of) + << "register variable" << op->getSourceRange(); return QualType(); } } else if (isa<OverloadedFunctionDecl>(dcl)) @@ -2817,8 +2817,8 @@ QualType Sema::CheckIndirectionOperand(Expr *op, SourceLocation OpLoc) { // and such a warning is unlikely to catch any mistakes. return PT->getPointeeType(); } - Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer, - qType.getAsString(), op->getSourceRange()); + Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer) + << qType.getAsString() << op->getSourceRange(); return QualType(); } @@ -3223,27 +3223,27 @@ Action::ExprResult Sema::ActOnUnaryOp(Scope *S, SourceLocation OpLoc, resultType->isPointerType()) break; - return Diag(OpLoc, diag::err_typecheck_unary_expr, - resultType.getAsString()); + return Diag(OpLoc, diag::err_typecheck_unary_expr) + << resultType.getAsString(); case UnaryOperator::Not: // bitwise complement UsualUnaryConversions(Input); resultType = Input->getType(); // C99 6.5.3.3p1. We allow complex int and float as a GCC extension. if (resultType->isComplexType() || resultType->isComplexIntegerType()) // C99 does not support '~' for complex conjugation. - Diag(OpLoc, diag::ext_integer_complement_complex, - resultType.getAsString(), Input->getSourceRange()); + Diag(OpLoc, diag::ext_integer_complement_complex) + << resultType.getAsString() << Input->getSourceRange(); else if (!resultType->isIntegerType()) - return Diag(OpLoc, diag::err_typecheck_unary_expr, - resultType.getAsString(), Input->getSourceRange()); + return Diag(OpLoc, diag::err_typecheck_unary_expr) + << resultType.getAsString() << Input->getSourceRange(); break; case UnaryOperator::LNot: // logical negation // Unlike +/-/~, integer promotions aren't done here (C99 6.5.3.3p5). DefaultFunctionArrayConversion(Input); resultType = Input->getType(); if (!resultType->isScalarType()) // C99 6.5.3.3p1 - return Diag(OpLoc, diag::err_typecheck_unary_expr, - resultType.getAsString()); + return Diag(OpLoc, diag::err_typecheck_unary_expr) + << resultType.getAsString(); // LNot always has type int. C99 6.5.3.3p5. resultType = Context.IntTy; break; @@ -3320,7 +3320,7 @@ Sema::ExprResult Sema::ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc, // one is known to be a field designator. Verify that the ArgTy represents // a struct/union/class. if (!ArgTy->isRecordType()) - return Diag(TypeLoc, diag::err_offsetof_record_type,ArgTy.getAsString()); + return Diag(TypeLoc, diag::err_offsetof_record_type) << ArgTy.getAsString(); // Otherwise, create a compound literal expression as the base, and // iteratively process the offsetof designators. @@ -3339,8 +3339,8 @@ Sema::ExprResult Sema::ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc, const ArrayType *AT = Context.getAsArrayType(Res->getType()); if (!AT) { delete Res; - return Diag(OC.LocEnd, diag::err_offsetof_array_type, - Res->getType().getAsString()); + return Diag(OC.LocEnd, diag::err_offsetof_array_type) + << Res->getType().getAsString(); } // FIXME: C++: Verify that operator[] isn't overloaded. @@ -3358,8 +3358,8 @@ Sema::ExprResult Sema::ActOnBuiltinOffsetOf(SourceLocation BuiltinLoc, const RecordType *RC = Res->getType()->getAsRecordType(); if (!RC) { delete Res; - return Diag(OC.LocEnd, diag::err_offsetof_record_type, - Res->getType().getAsString()); + return Diag(OC.LocEnd, diag::err_offsetof_record_type) + << Res->getType().getAsString(); } // Get the decl corresponding to this. @@ -3604,8 +3604,8 @@ Sema::ExprResult Sema::ActOnOverloadExpr(ExprTy **args, unsigned NumArgs, typeNames += Args[i+1]->getType().getAsString(); } - return Diag(BuiltinLoc, diag::err_overload_no_match, typeNames, - SourceRange(BuiltinLoc, RParenLoc)); + return Diag(BuiltinLoc, diag::err_overload_no_match) + << typeNames << SourceRange(BuiltinLoc, RParenLoc); } Sema::ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, @@ -3628,9 +3628,8 @@ Sema::ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, if (CheckAssignmentConstraints(VaListType, E->getType()) != Compatible) return Diag(E->getLocStart(), - diag::err_first_argument_to_va_arg_not_of_type_va_list, - E->getType().getAsString(), - E->getSourceRange()); + diag::err_first_argument_to_va_arg_not_of_type_va_list) + << E->getType().getAsString() << E->getSourceRange(); // FIXME: Warn if a non-POD type is passed in. diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 80bd8eeef3..55616bad76 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -125,8 +125,8 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, // be complete. // if (!RT->getDecl()->isDefinition()) - return Diag(TyBeginLoc, diag::err_invalid_incomplete_type_use, - Ty.getAsString(), FullRange); + return Diag(TyBeginLoc, diag::err_invalid_incomplete_type_use) + << Ty.getAsString() << FullRange; unsigned DiagID = PP.getDiagnostics().getCustomDiagID(Diagnostic::Error, "class constructors are not supported yet"); @@ -233,8 +233,8 @@ bool Sema::CheckCXXBooleanCondition(Expr *&CondExpr) { AssignConvertType ConvTy = CheckSingleAssignmentConstraints(Context.BoolTy, CondExpr); if (ConvTy == Incompatible) - return Diag(CondExpr->getLocStart(), diag::err_typecheck_bool_condition, - Ty.getAsString(), CondExpr->getSourceRange()); + return Diag(CondExpr->getLocStart(), diag::err_typecheck_bool_condition) + << Ty.getAsString() << CondExpr->getSourceRange(); return false; } diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp index bffdb3f7f6..c243fac553 100644 --- a/lib/Sema/SemaNamedCast.cpp +++ b/lib/Sema/SemaNamedCast.cpp @@ -730,9 +730,9 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, return; } } else { - Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class, - SrcPointee.getUnqualifiedType().getAsString(), - SrcExpr->getSourceRange()); + Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class) + << SrcPointee.getUnqualifiedType().getAsString() + << SrcExpr->getSourceRange(); return; } @@ -769,8 +769,9 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, const RecordDecl *SrcDecl = SrcRecord->getDecl()->getDefinition(Self.Context); assert(SrcDecl && "Definition missing"); if (!cast<CXXRecordDecl>(SrcDecl)->isPolymorphic()) { - Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic, - SrcPointee.getUnqualifiedType().getAsString(), SrcExpr->getSourceRange()); + Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic) + << SrcPointee.getUnqualifiedType().getAsString() + << SrcExpr->getSourceRange(); } // Done. Everything else is run-time checks. diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 72901f1969..10ca53f86b 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -210,8 +210,8 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, ExprTy *CondVal, if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4 return true; } else if (!condType->isScalarType()) // C99 6.8.4.1p1 - return Diag(IfLoc, diag::err_typecheck_statement_requires_scalar, - condType.getAsString(), condExpr->getSourceRange()); + return Diag(IfLoc, diag::err_typecheck_statement_requires_scalar) + << condType.getAsString() << condExpr->getSourceRange(); // Warn if the if block has a null body without an else value. // this helps prevent bugs due to typos, such as @@ -275,7 +275,7 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val, // If the input was signed and negative and the output is unsigned, // warn. if (!NewSign && OldVal.isSigned() && OldVal.isNegative()) - Diag(Loc, DiagID, OldVal.toString(10), Val.toString(10)); + Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10); Val.setIsSigned(NewSign); } else if (NewWidth < Val.getBitWidth()) { @@ -286,7 +286,7 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val, ConvVal.extend(Val.getBitWidth()); ConvVal.setIsSigned(Val.isSigned()); if (ConvVal != Val) - Diag(Loc, DiagID, Val.toString(10), ConvVal.toString(10)); + Diag(Loc, DiagID) << Val.toString(10) << ConvVal.toString(10); // Regardless of whether a diagnostic was emitted, really do the // truncation. @@ -299,7 +299,7 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val, Val.setIsSigned(NewSign); if (Val.isNegative()) // Sign bit changes meaning. - Diag(Loc, DiagID, OldVal.toString(10), Val.toString(10)); + Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10); } } @@ -349,8 +349,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch, QualType CondType = CondExpr->getType(); if (!CondType->isIntegerType()) { // C99 6.8.4.2p1 - Diag(SwitchLoc, diag::err_typecheck_statement_requires_integer, - CondType.getAsString(), CondExpr->getSourceRange()); + Diag(SwitchLoc, diag::err_typecheck_statement_requires_integer) + << CondType.getAsString() << CondExpr->getSourceRange(); return true; } @@ -422,7 +422,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch, if (CaseVals[i].first == CaseVals[i+1].first) { // If we have a duplicate, report it. Diag(CaseVals[i+1].second->getLHS()->getLocStart(), - diag::err_duplicate_case, CaseVals[i].first.toString(10)); + diag::err_duplicate_case) << CaseVals[i].first.toString(10); Diag(CaseVals[i].second->getLHS()->getLocStart(), diag::err_duplicate_case_prev); // FIXME: We really want to remove the bogus case stmt from the substmt, @@ -505,8 +505,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtTy *Switch, if (OverlapStmt) { // If we have a duplicate, report it. - Diag(CR->getLHS()->getLocStart(), - diag::err_duplicate_case, OverlapVal.toString(10)); + Diag(CR->getLHS()->getLocStart(), diag::err_duplicate_case) + << OverlapVal.toString(10); Diag(OverlapStmt->getLHS()->getLocStart(), diag::err_duplicate_case_prev); // FIXME: We really want to remove the bogus case stmt from the substmt, @@ -536,8 +536,8 @@ Sema::ActOnWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body) { if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4 return true; } else if (!condType->isScalarType()) // C99 6.8.5p2 - return Diag(WhileLoc, diag::err_typecheck_statement_requires_scalar, - condType.getAsString(), condExpr->getSourceRange()); + return Diag(WhileLoc, diag::err_typecheck_statement_requires_scalar) + << condType.getAsString() << condExpr->getSourceRange(); return new WhileStmt(condExpr, (Stmt*)Body, WhileLoc); } @@ -555,8 +555,8 @@ Sema::ActOnDoStmt(SourceLocation DoLoc, StmtTy *Body, if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4 return true; } else if (!condType->isScalarType()) // C99 6.8.5p2 - return Diag(DoLoc, diag::err_typecheck_statement_requires_scalar, - condType.getAsString(), condExpr->getSourceRange()); + return Diag(DoLoc, diag::err_typecheck_statement_requires_scalar) + << condType.getAsString() << condExpr->getSourceRange(); return new DoStmt((Stmt*)Body, condExpr, DoLoc); } @@ -593,8 +593,8 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, if (CheckCXXBooleanCondition(Second)) // C++ 6.4p4 return true; } else if (!SecondType->isScalarType()) // C99 6.8.5p2 - return Diag(ForLoc, diag::err_typecheck_statement_requires_scalar, - SecondType.getAsString(), Second->getSourceRange()); + return Diag(ForLoc, diag::err_typecheck_statement_requires_scalar) + << SecondType.getAsString() << Second->getSourceRange(); } return new ForStmt(First, Second, Third, Body, ForLoc); } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 945082ad46..8c46fab586 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -203,14 +203,14 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) { // incomplete type. if (!EltTy->isIncompleteOrObjectType()) { Diag(DS.getRestrictSpecLoc(), - diag::err_typecheck_invalid_restrict_invalid_pointee, - EltTy.getAsString(), DS.getSourceRange()); + diag::err_typecheck_invalid_restrict_invalid_pointee) + << EltTy.getAsString() << DS.getSourceRange(); TypeQuals &= ~QualType::Restrict; // Remove the restrict qualifier. } } else { Diag(DS.getRestrictSpecLoc(), - diag::err_typecheck_invalid_restrict_not_pointer, - Result.getAsString(), DS.getSourceRange()); + diag::err_typecheck_invalid_restrict_not_pointer) + << Result.getAsString() << DS.getSourceRange(); TypeQuals &= ~QualType::Restrict; // Remove the restrict qualifier. } } @@ -228,8 +228,8 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) { "Has CV quals but not C or V?"); Loc = DS.getVolatileSpecLoc(); } - Diag(Loc, diag::warn_typecheck_function_qualifiers, - Result.getAsString(), DS.getSourceRange()); + Diag(Loc, diag::warn_typecheck_function_qualifiers) + << Result.getAsString() << DS.getSourceRange(); } // C++ [dcl.ref]p1: @@ -275,8 +275,8 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { case DeclaratorChunk::Pointer: if (T->isReferenceType()) { // C++ 8.3.2p4: There shall be no ... pointers to references ... - Diag(DeclType.Loc, diag::err_illegal_decl_pointer_to_reference, - D.getIdentifier() ? D.getIdentifier()->getName() : "type name"); + Diag(DeclType.Loc, diag::err_illegal_decl_pointer_to_reference) + << (D.getIdentifier() ? D.getIdentifier()->getName() : "type name"); D.setInvalidType(true); T = Context.IntTy; } @@ -285,9 +285,8 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { // object or incomplete types shall not be restrict-qualified." if ((DeclType.Ptr.TypeQuals & QualType::Restrict) && !T->isIncompleteOrObjectType()) { - Diag(DeclType.Loc, - diag::err_typecheck_invalid_restrict_invalid_pointee, - T.getAsString()); + Diag(DeclType.Loc, diag::err_typecheck_invalid_restrict_invalid_pointee) + << T.getAsString(); DeclType.Ptr.TypeQuals &= QualType::Restrict; } @@ -327,9 +326,8 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { // object or incomplete types shall not be restrict-qualified." if (DeclType.Ref.HasRestrict && !T->isIncompleteOrObjectType()) { - Diag(DeclType.Loc, - diag::err_typecheck_invalid_restrict_invalid_pointee, - T.getAsString()); + Diag(DeclType.Loc, diag::err_typecheck_invalid_restrict_invalid_pointee) + << T.getAsString(); DeclType.Ref.HasRestrict = false; } @@ -355,39 +353,39 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { // C99 6.7.5.2p1: If the element type is an incomplete or function type, // reject it (e.g. void ary[7], struct foo ary[7], void ary[7]()) if (T->isIncompleteType()) { - Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_incomplete_type, - T.getAsString()); + Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_incomplete_type) + << T.getAsString(); T = Context.IntTy; D.setInvalidType(true); } else if (T->isFunctionType()) { - Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions, - D.getIdentifier() ? D.getIdentifier()->getName() : "type name"); + Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions) + << (D.getIdentifier() ? D.getIdentifier()->getName() : "type name"); T = Context.getPointerType(T); D.setInvalidType(true); } else if (const ReferenceType *RT = T->getAsReferenceType()) { // C++ 8.3.2p4: There shall be no ... arrays of references ... - Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_references, - D.getIdentifier() ? D.getIdentifier()->getName() : "type name"); + Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_references) + << (D.getIdentifier() ? D.getIdentifier()->getName() : "type name"); T = RT->getPointeeType(); D.setInvalidType(true); } else if (const RecordType *EltTy = T->getAsRecordType()) { // If the element type is a struct or union that contains a variadic // array, reject it: C99 6.7.2.1p2. if (EltTy->getDecl()->hasFlexibleArrayMember()) { - Diag(DeclType.Loc, diag::err_flexible_array_in_array, - T.getAsString()); + Diag(DeclType.Loc, diag::err_flexible_array_in_array) + << T.getAsString(); T = Context.IntTy; D.setInvalidType(true); } } else if (T->isObjCInterfaceType()) { - Diag(DeclType.Loc, diag::warn_objc_array_of_interfaces, - T.getAsString()); + Diag(DeclType.Loc, diag::warn_objc_array_of_interfaces) + << T.getAsString(); } // C99 6.7.5.2p1: The size expression shall have integer type. if (ArraySize && !ArraySize->getType()->isIntegerType()) { - Diag(ArraySize->getLocStart(), diag::err_array_size_non_int, - ArraySize->getType().getAsString(), ArraySize->getSourceRange()); + Diag(ArraySize->getLocStart(), diag::err_array_size_non_int) + << ArraySize->getType().getAsString() << ArraySize->getSourceRange(); D.setInvalidType(true); delete ArraySize; ATI.NumElts = ArraySize = 0; |