[cfe-commits] r130651 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprCXX.cpp
Chandler Carruth
chandlerc at gmail.com
Sun May 1 01:41:10 PDT 2011
Author: chandlerc
Date: Sun May 1 03:41:10 2011
New Revision: 130651
URL: http://llvm.org/viewvc/llvm-project?rev=130651&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=130651&r1=130650&r2=130651&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun May 1 03:41:10 2011
@@ -3339,8 +3339,6 @@
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 '('">;
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=130651&r1=130650&r2=130651&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sun May 1 03:41:10 2011
@@ -2457,8 +2457,7 @@
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 @@
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 @@
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 @@
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));
More information about the cfe-commits
mailing list