From: Chandler Carruth Date: Sun, 1 May 2011 08:41:10 +0000 (+0000) Subject: Remove more dead code for emitting diagnostics. The callers of these X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d064c70bc63ad742d11625e485c1dc1631f6e303;p=clang Remove more dead code for emitting diagnostics. The callers of these functions already precluded dependent types from reaching them. Also change one of the callers to not error when a trait is applied to a dependent type. This is a perfectly reasonable pattern, and both Unary and Binary type traits already support dependent types (by populating the AST with a nonce value). Remove the actual diagnostic, since these aren't errors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130651 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index b05e13313e..0a0c91ac91 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -3339,8 +3339,6 @@ def warn_unused_call : Warning< def err_incomplete_type_used_in_type_trait_expr : Error< "incomplete type %0 used in type trait expression">; -def err_dependent_type_used_in_type_trait_expr : Error< - "dependent type %0 used in type trait expression">; def err_dimension_expr_not_constant_integer : Error< "dimension expression does not evaluate to a constant unsigned int">; def err_expected_ident_or_lparen : Error<"expected identifier or '('">; diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 7a7aabeafe..9f1329717f 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2457,8 +2457,7 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S, static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT, SourceLocation KeyLoc, QualType T) { - assert(!T->isDependentType() && - "Cannot evaluate type trait on dependent type"); + assert(!T->isDependentType() && "Cannot evaluate traits of dependent type"); ASTContext &C = Self.Context; switch(UTT) { @@ -2788,14 +2787,8 @@ ExprResult Sema::ActOnBinaryTypeTrait(BinaryTypeTrait BTT, static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT, QualType LhsT, QualType RhsT, SourceLocation KeyLoc) { - if (LhsT->isDependentType()) { - Self.Diag(KeyLoc, diag::err_dependent_type_used_in_type_trait_expr) << LhsT; - return false; - } - else if (RhsT->isDependentType()) { - Self.Diag(KeyLoc, diag::err_dependent_type_used_in_type_trait_expr) << RhsT; - return false; - } + assert(!LhsT->isDependentType() && !RhsT->isDependentType() && + "Cannot evaluate traits of dependent types"); switch(BTT) { case BTT_IsBaseOf: { @@ -2934,10 +2927,7 @@ ExprResult Sema::ActOnArrayTypeTrait(ArrayTypeTrait ATT, static uint64_t EvaluateArrayTypeTrait(Sema &Self, ArrayTypeTrait ATT, QualType T, Expr *DimExpr, SourceLocation KeyLoc) { - if (T->isDependentType()) { - Self.Diag(KeyLoc, diag::err_dependent_type_used_in_type_trait_expr) << T; - return false; - } + assert(!T->isDependentType() && "Cannot evaluate traits of dependent type"); switch(ATT) { case ATT_ArrayRank: @@ -2996,10 +2986,11 @@ ExprResult Sema::BuildArrayTypeTrait(ArrayTypeTrait ATT, Expr* DimExpr, SourceLocation RParen) { QualType T = TSInfo->getType(); - if (T->isDependentType()) - return ExprError(); - uint64_t Value = EvaluateArrayTypeTrait(*this, ATT, T, DimExpr, KWLoc); + uint64_t Value = 0; + if (!T->isDependentType()) + Value = EvaluateArrayTypeTrait(*this, ATT, T, DimExpr, KWLoc); + return Owned(new (Context) ArrayTypeTraitExpr(KWLoc, ATT, TSInfo, Value, DimExpr, RParen, Context.IntTy));