diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-05-01 08:41:10 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-05-01 08:41:10 +0000 |
commit | 0d1a54f8e1e9d06a037c4c67309ad785b3383fc8 (patch) | |
tree | 87da1c0e6d182dbb21fd1e399ea54ebd5beeffd8 /clang/lib/Sema/SemaExprCXX.cpp | |
parent | d8970dde43e2ee79fe61cbc46b5989240d296b3f (diff) | |
download | bcm5719-llvm-0d1a54f8e1e9d06a037c4c67309ad785b3383fc8.tar.gz bcm5719-llvm-0d1a54f8e1e9d06a037c4c67309ad785b3383fc8.zip |
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.
llvm-svn: 130651
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 7a7aabeafe4..9f1329717f0 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/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)); |