[cfe-commits] r126286 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaChecking.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaStmt.cpp
Chris Lattner
clattner at apple.com
Tue Feb 22 18:25:55 PST 2011
On Feb 22, 2011, at 5:51 PM, Ted Kremenek wrote:
> Author: kremenek
> Date: Tue Feb 22 19:51:43 2011
> New Revision: 126286
>
> URL: http://llvm.org/viewvc/llvm-project?rev=126286&view=rev
> Log:
> Update Sema::DiagRuntimeBehavior() to take an optional Stmt* to indicate the code the diagnostic is associated with.
>
> This Stmt* is unused, but we will use it shortly for pruning diagnostics associated
> with unreachable code.
Cool, please add a doxygen comment on the method in Sema.h and update the one in the .cpp file. Is there a reason for the Stmt to be optional? It seems reasonable to make it required.
-Chris
>
> Modified:
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaStmt.cpp
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=126286&r1=126285&r2=126286&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 22 19:51:43 2011
> @@ -1891,7 +1891,8 @@
> void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
> void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
> void MarkDeclarationsReferencedInExpr(Expr *E);
> - bool DiagRuntimeBehavior(SourceLocation Loc, const PartialDiagnostic &PD);
> + bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *stmt,
> + const PartialDiagnostic &PD);
>
> // Primary Expressions.
> SourceRange getExprRange(Expr *E) const;
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=126286&r1=126285&r2=126286&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Feb 22 19:51:43 2011
> @@ -3135,12 +3135,12 @@
> if (index.slt(size))
> return;
>
> - DiagRuntimeBehavior(E->getBase()->getLocStart(),
> + DiagRuntimeBehavior(E->getBase()->getLocStart(), BaseExpr,
> PDiag(diag::warn_array_index_exceeds_bounds)
> << index.toString(10, true) << size.toString(10, true)
> << IndexExpr->getSourceRange());
> } else {
> - DiagRuntimeBehavior(E->getBase()->getLocStart(),
> + DiagRuntimeBehavior(E->getBase()->getLocStart(), BaseExpr,
> PDiag(diag::warn_array_index_precedes_bounds)
> << index.toString(10, true)
> << IndexExpr->getSourceRange());
> @@ -3152,7 +3152,7 @@
> if (const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr))
> ND = dyn_cast<NamedDecl>(ME->getMemberDecl());
> if (ND)
> - DiagRuntimeBehavior(ND->getLocStart(),
> + DiagRuntimeBehavior(ND->getLocStart(), BaseExpr,
> PDiag(diag::note_array_index_out_of_bounds)
> << ND->getDeclName());
> }
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=126286&r1=126285&r2=126286&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Feb 22 19:51:43 2011
> @@ -387,13 +387,13 @@
> return false;
>
> if (Expr->getType()->isObjCObjectType() &&
> - DiagRuntimeBehavior(Expr->getLocStart(),
> + DiagRuntimeBehavior(Expr->getLocStart(), Expr,
> PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
> << Expr->getType() << CT))
> return true;
>
> if (!Expr->getType()->isPODType() &&
> - DiagRuntimeBehavior(Expr->getLocStart(),
> + DiagRuntimeBehavior(Expr->getLocStart(), Expr,
> PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
> << Expr->getType() << CT))
> return true;
> @@ -6355,8 +6355,8 @@
> // Check for division by zero.
> if (isDiv &&
> rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull))
> - DiagRuntimeBehavior(Loc, PDiag(diag::warn_division_by_zero)
> - << rex->getSourceRange());
> + DiagRuntimeBehavior(Loc, rex, PDiag(diag::warn_division_by_zero)
> + << rex->getSourceRange());
>
> return compType;
> }
> @@ -6377,8 +6377,8 @@
>
> // Check for remainder by zero.
> if (rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull))
> - DiagRuntimeBehavior(Loc, PDiag(diag::warn_remainder_by_zero)
> - << rex->getSourceRange());
> + DiagRuntimeBehavior(Loc, rex, PDiag(diag::warn_remainder_by_zero)
> + << rex->getSourceRange());
>
> return compType;
> }
> @@ -6721,7 +6721,7 @@
> if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(RHSStripped)) {
> if (DRL->getDecl() == DRR->getDecl() &&
> !IsWithinTemplateSpecialization(DRL->getDecl())) {
> - DiagRuntimeBehavior(Loc, PDiag(diag::warn_comparison_always)
> + DiagRuntimeBehavior(Loc, lex, PDiag(diag::warn_comparison_always)
> << 0 // self-
> << (Opc == BO_EQ
> || Opc == BO_LE
> @@ -6743,7 +6743,7 @@
> always_evals_to = 2; // e.g. array1 <= array2
> break;
> }
> - DiagRuntimeBehavior(Loc, PDiag(diag::warn_comparison_always)
> + DiagRuntimeBehavior(Loc, lex, PDiag(diag::warn_comparison_always)
> << 1 // array
> << always_evals_to);
> }
> @@ -6784,7 +6784,7 @@
> default: assert(false && "Invalid comparison operator");
> }
>
> - DiagRuntimeBehavior(Loc,
> + DiagRuntimeBehavior(Loc, literalString,
> PDiag(diag::warn_stringcompare)
> << isa<ObjCEncodeExpr>(literalStringStripped)
> << literalString->getSourceRange());
> @@ -7094,7 +7094,7 @@
> if (DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(lex->IgnoreParens()))
> if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(rex->IgnoreParens()))
> if (DRL->getDecl() == DRR->getDecl())
> - DiagRuntimeBehavior(Loc,
> + DiagRuntimeBehavior(Loc, rex,
> PDiag(diag::warn_comparison_always)
> << 0 // self-
> << 2 // "a constant"
> @@ -8546,7 +8546,7 @@
> // (clause 9).
> if (CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
> if (!CRD->isPOD() && !DidWarnAboutNonPOD &&
> - DiagRuntimeBehavior(BuiltinLoc,
> + DiagRuntimeBehavior(BuiltinLoc, 0,
> PDiag(diag::warn_offsetof_non_pod_type)
> << SourceRange(CompPtr[0].LocStart, OC.LocEnd)
> << CurrentType))
> @@ -9470,7 +9470,7 @@
> /// behavior of a program, such as passing a non-POD value through an ellipsis.
> /// Failure to do so will likely result in spurious diagnostics or failures
> /// during overload resolution or within sizeof/alignof/typeof/typeid.
> -bool Sema::DiagRuntimeBehavior(SourceLocation Loc,
> +bool Sema::DiagRuntimeBehavior(SourceLocation Loc, const Stmt *stmt,
> const PartialDiagnostic &PD) {
> switch (ExprEvalContexts.back().Context ) {
> case Unevaluated:
>
> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=126286&r1=126285&r2=126286&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Feb 22 19:51:43 2011
> @@ -146,7 +146,7 @@
> }
> }
>
> - DiagRuntimeBehavior(Loc, PDiag(DiagID) << R1 << R2);
> + DiagRuntimeBehavior(Loc, S, PDiag(DiagID) << R1 << R2);
> }
>
> StmtResult
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list