[cfe-commits] r121298 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Frontend/ include/clang/Sema/ include/clang/Serialization/ lib/AST/ lib/Checker/ lib/CodeGen/ lib/Frontend/ lib/Parse/ lib/Sema/ lib/Serialization/ tools/libclang/
Francois Pichet
pichet2000 at gmail.com
Wed Dec 8 14:35:30 PST 2010
Author: fpichet
Date: Wed Dec 8 16:35:30 2010
New Revision: 121298
URL: http://llvm.org/viewvc/llvm-project?rev=121298&view=rev
Log:
Remove the TypesCompatibleExprClass AST node. Merge its functionality into BinaryTypeTraitExpr.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Basic/TypeTraits.h
cfe/trunk/include/clang/Frontend/StmtXML.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/StmtDumper.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/lib/Frontend/StmtXML.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Dec 8 16:35:30 2010
@@ -2641,52 +2641,6 @@
virtual child_iterator child_end();
};
-/// TypesCompatibleExpr - GNU builtin-in function __builtin_types_compatible_p.
-/// This AST node represents a function that returns 1 if two *types* (not
-/// expressions) are compatible. The result of this built-in function can be
-/// used in integer constant expressions.
-class TypesCompatibleExpr : public Expr {
- TypeSourceInfo *TInfo1;
- TypeSourceInfo *TInfo2;
- SourceLocation BuiltinLoc, RParenLoc;
-public:
- TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
- TypeSourceInfo *tinfo1, TypeSourceInfo *tinfo2,
- SourceLocation RP) :
- Expr(TypesCompatibleExprClass, ReturnType, VK_RValue, OK_Ordinary,
- false, false),
- TInfo1(tinfo1), TInfo2(tinfo2), BuiltinLoc(BLoc), RParenLoc(RP) {}
-
- /// \brief Build an empty __builtin_type_compatible_p expression.
- explicit TypesCompatibleExpr(EmptyShell Empty)
- : Expr(TypesCompatibleExprClass, Empty) { }
-
- TypeSourceInfo *getArgTInfo1() const { return TInfo1; }
- void setArgTInfo1(TypeSourceInfo *TInfo) { TInfo1 = TInfo; }
- TypeSourceInfo *getArgTInfo2() const { return TInfo2; }
- void setArgTInfo2(TypeSourceInfo *TInfo) { TInfo2 = TInfo; }
-
- QualType getArgType1() const { return TInfo1->getType(); }
- QualType getArgType2() const { return TInfo2->getType(); }
-
- SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
- void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
-
- SourceLocation getRParenLoc() const { return RParenLoc; }
- void setRParenLoc(SourceLocation L) { RParenLoc = L; }
-
- virtual SourceRange getSourceRange() const {
- return SourceRange(BuiltinLoc, RParenLoc);
- }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == TypesCompatibleExprClass;
- }
- static bool classof(const TypesCompatibleExpr *) { return true; }
-
- // Iterators
- virtual child_iterator child_begin();
- virtual child_iterator child_end();
-};
/// ShuffleVectorExpr - clang-specific builtin-in function
/// __builtin_shufflevector.
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Wed Dec 8 16:35:30 2010
@@ -1488,7 +1488,7 @@
explicit BinaryTypeTraitExpr(EmptyShell Empty)
: Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false),
- LhsType() { }
+ LhsType(), RhsType() { }
virtual SourceRange getSourceRange() const {
return SourceRange(Loc, RParen);
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Dec 8 16:35:30 2010
@@ -1726,11 +1726,6 @@
TRY_TO(TraverseTypeLoc(S->getTypeOperandSourceInfo()->getTypeLoc()));
})
-DEF_TRAVERSE_STMT(TypesCompatibleExpr, {
- TRY_TO(TraverseTypeLoc(S->getArgTInfo1()->getTypeLoc()));
- TRY_TO(TraverseTypeLoc(S->getArgTInfo2()->getTypeLoc()));
- })
-
DEF_TRAVERSE_STMT(UnaryTypeTraitExpr, {
TRY_TO(TraverseTypeLoc(S->getQueriedTypeSourceInfo()->getTypeLoc()));
})
Modified: cfe/trunk/include/clang/Basic/StmtNodes.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/StmtNodes.td?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/StmtNodes.td (original)
+++ cfe/trunk/include/clang/Basic/StmtNodes.td Wed Dec 8 16:35:30 2010
@@ -76,7 +76,6 @@
// GNU Extensions.
def AddrLabelExpr : DStmt<Expr>;
def StmtExpr : DStmt<Expr>;
-def TypesCompatibleExpr : DStmt<Expr>;
def ChooseExpr : DStmt<Expr>;
def GNUNullExpr : DStmt<Expr>;
Modified: cfe/trunk/include/clang/Basic/TypeTraits.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TypeTraits.h?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TypeTraits.h (original)
+++ cfe/trunk/include/clang/Basic/TypeTraits.h Wed Dec 8 16:35:30 2010
@@ -38,7 +38,8 @@
/// BinaryTypeTrait - Names for the binary type traits.
enum BinaryTypeTrait {
- BTT_IsBaseOf
+ BTT_IsBaseOf,
+ BTT_TypeCompatible
};
}
Modified: cfe/trunk/include/clang/Frontend/StmtXML.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/StmtXML.def?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/StmtXML.def (original)
+++ cfe/trunk/include/clang/Frontend/StmtXML.def Wed Dec 8 16:35:30 2010
@@ -415,13 +415,6 @@
SUB_NODE_XML(CompoundStmt)
END_NODE_XML
-NODE_XML(TypesCompatibleExpr, "TypesCompatibleExpr") // GNU builtin-in function __builtin_types_compatible_p
- ATTRIBUTE_FILE_LOCATION_XML
- TYPE_ATTRIBUTE_XML(getType())
- ATTRIBUTE_XML(getArgType1(), "type1_ref") // id of type1
- ATTRIBUTE_XML(getArgType2(), "type2_ref") // id of type2
-END_NODE_XML
-
NODE_XML(ChooseExpr, "ChooseExpr") // GNU builtin-in function __builtin_choose_expr(expr1, expr2, expr3)
ATTRIBUTE_FILE_LOCATION_XML
TYPE_ATTRIBUTE_XML(getType())
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Dec 8 16:35:30 2010
@@ -1953,16 +1953,6 @@
unsigned NumComponents,
SourceLocation RParenLoc);
- // __builtin_types_compatible_p(type1, type2)
- ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
- ParsedType arg1,
- ParsedType arg2,
- SourceLocation RPLoc);
- ExprResult BuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
- TypeSourceInfo *argTInfo1,
- TypeSourceInfo *argTInfo2,
- SourceLocation RPLoc);
-
// __builtin_choose_expr(constExpr, expr1, expr2)
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
Expr *cond, Expr *expr1,
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Dec 8 16:35:30 2010
@@ -826,8 +826,6 @@
EXPR_ADDR_LABEL,
/// \brief A StmtExpr record.
EXPR_STMT,
- /// \brief A TypesCompatibleExpr record.
- EXPR_TYPES_COMPATIBLE,
/// \brief A ChooseExpr record.
EXPR_CHOOSE,
/// \brief A GNUNullExpr record.
@@ -927,7 +925,7 @@
EXPR_CXX_NOEXCEPT, // CXXNoexceptExpr
EXPR_OPAQUE_VALUE, // OpaqueValueExpr
- EXPR_CXX_BINARY_TYPE_TRAIT // BinaryTypeTraitExpr
+ EXPR_BINARY_TYPE_TRAIT // BinaryTypeTraitExpr
};
/// \brief The kinds of designators that can occur in a
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Dec 8 16:35:30 2010
@@ -2708,14 +2708,6 @@
Stmt::child_iterator StmtExpr::child_begin() { return &SubStmt; }
Stmt::child_iterator StmtExpr::child_end() { return &SubStmt+1; }
-// TypesCompatibleExpr
-Stmt::child_iterator TypesCompatibleExpr::child_begin() {
- return child_iterator();
-}
-
-Stmt::child_iterator TypesCompatibleExpr::child_end() {
- return child_iterator();
-}
// ChooseExpr
Stmt::child_iterator ChooseExpr::child_begin() { return &SubExprs[0]; }
Modified: cfe/trunk/lib/AST/ExprClassification.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprClassification.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprClassification.cpp (original)
+++ cfe/trunk/lib/AST/ExprClassification.cpp Wed Dec 8 16:35:30 2010
@@ -130,7 +130,6 @@
case Expr::CXXNewExprClass:
case Expr::CXXThisExprClass:
case Expr::CXXNullPtrLiteralExprClass:
- case Expr::TypesCompatibleExprClass:
case Expr::ImaginaryLiteralClass:
case Expr::GNUNullExprClass:
case Expr::OffsetOfExprClass:
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Dec 8 16:35:30 2010
@@ -910,16 +910,6 @@
bool VisitCharacterLiteral(const CharacterLiteral *E) {
return Success(E->getValue(), E);
}
- bool VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
- // Per gcc docs "this built-in function ignores top level
- // qualifiers". We need to use the canonical version to properly
- // be able to strip CRV qualifiers from the type.
- QualType T0 = Info.Ctx.getCanonicalType(E->getArgType1());
- QualType T1 = Info.Ctx.getCanonicalType(E->getArgType2());
- return Success(Info.Ctx.typesAreCompatible(T0.getUnqualifiedType(),
- T1.getUnqualifiedType()),
- E);
- }
bool CheckReferencedDecl(const Expr *E, const Decl *D);
bool VisitDeclRefExpr(const DeclRefExpr *E) {
@@ -2527,7 +2517,6 @@
case Expr::CharacterLiteralClass:
case Expr::CXXBoolLiteralExprClass:
case Expr::CXXScalarValueInitExprClass:
- case Expr::TypesCompatibleExprClass:
case Expr::UnaryTypeTraitExprClass:
case Expr::BinaryTypeTraitExprClass:
case Expr::CXXNoexceptExprClass:
Modified: cfe/trunk/lib/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtDumper.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtDumper.cpp (original)
+++ cfe/trunk/lib/AST/StmtDumper.cpp Wed Dec 8 16:35:30 2010
@@ -152,7 +152,6 @@
void VisitBinaryOperator(BinaryOperator *Node);
void VisitCompoundAssignOperator(CompoundAssignOperator *Node);
void VisitAddrLabelExpr(AddrLabelExpr *Node);
- void VisitTypesCompatibleExpr(TypesCompatibleExpr *Node);
// C++
void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
@@ -482,14 +481,6 @@
<< " " << (void*)Node->getLabel();
}
-void StmtDumper::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
- DumpExpr(Node);
- OS << " ";
- DumpType(Node->getArgType1());
- OS << " ";
- DumpType(Node->getArgType2());
-}
-
//===----------------------------------------------------------------------===//
// C++ Expressions
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Wed Dec 8 16:35:30 2010
@@ -814,12 +814,6 @@
OS << ")";
}
-void StmtPrinter::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
- OS << "__builtin_types_compatible_p(";
- OS << Node->getArgType1().getAsString(Policy) << ",";
- OS << Node->getArgType2().getAsString(Policy) << ")";
-}
-
void StmtPrinter::VisitChooseExpr(ChooseExpr *Node) {
OS << "__builtin_choose_expr(";
PrintExpr(Node->getCond());
@@ -1229,7 +1223,8 @@
static const char *getTypeTraitName(BinaryTypeTrait BTT) {
switch (BTT) {
default: llvm_unreachable("Unknown binary type trait");
- case BTT_IsBaseOf: return "__is_base_of";
+ case BTT_IsBaseOf: return "__is_base_of";
+ case BTT_TypeCompatible: return "__builtin_types_compatible_p";
}
return "";
}
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Wed Dec 8 16:35:30 2010
@@ -359,12 +359,6 @@
VisitExpr(S);
}
-void StmtProfiler::VisitTypesCompatibleExpr(TypesCompatibleExpr *S) {
- VisitExpr(S);
- VisitType(S->getArgType1());
- VisitType(S->getArgType2());
-}
-
void StmtProfiler::VisitShuffleVectorExpr(ShuffleVectorExpr *S) {
VisitExpr(S);
}
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Wed Dec 8 16:35:30 2010
@@ -866,7 +866,6 @@
case Stmt::ParenListExprClass:
case Stmt::PredefinedExprClass:
case Stmt::ShuffleVectorExprClass:
- case Stmt::TypesCompatibleExprClass:
case Stmt::VAArgExprClass:
// Fall through.
Modified: cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp (original)
+++ cfe/trunk/lib/Checker/IdempotentOperationChecker.cpp Wed Dec 8 16:35:30 2010
@@ -646,7 +646,7 @@
case Stmt::OffsetOfExprClass:
case Stmt::CompoundLiteralExprClass:
case Stmt::AddrLabelExprClass:
- case Stmt::TypesCompatibleExprClass:
+ case Stmt::BinaryTypeTraitExprClass:
case Stmt::GNUNullExprClass:
case Stmt::InitListExprClass:
case Stmt::DesignatedInitExprClass:
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Dec 8 16:35:30 2010
@@ -188,11 +188,6 @@
Value *VisitGNUNullExpr(const GNUNullExpr *E) {
return EmitNullValue(E->getType());
}
- Value *VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
- return llvm::ConstantInt::get(ConvertType(E->getType()),
- CGF.getContext().typesAreCompatible(
- E->getArgType1(), E->getArgType2()));
- }
Value *VisitOffsetOfExpr(OffsetOfExpr *E);
Value *VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E);
Value *VisitAddrLabelExpr(const AddrLabelExpr *E) {
@@ -354,7 +349,7 @@
}
Value *VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *E) {
- return llvm::ConstantInt::get(Builder.getInt1Ty(), E->getValue());
+ return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
}
Value *VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *E) {
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Wed Dec 8 16:35:30 2010
@@ -1662,7 +1662,6 @@
case Expr::PredefinedExprClass:
case Expr::ShuffleVectorExprClass:
case Expr::StmtExprClass:
- case Expr::TypesCompatibleExprClass:
case Expr::UnaryTypeTraitExprClass:
case Expr::BinaryTypeTraitExprClass:
case Expr::VAArgExprClass:
Modified: cfe/trunk/lib/Frontend/StmtXML.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/StmtXML.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/StmtXML.cpp (original)
+++ cfe/trunk/lib/Frontend/StmtXML.cpp Wed Dec 8 16:35:30 2010
@@ -133,7 +133,6 @@
void VisitBinaryOperator(BinaryOperator *Node);
void VisitCompoundAssignOperator(CompoundAssignOperator *Node);
void VisitAddrLabelExpr(AddrLabelExpr *Node);
- void VisitTypesCompatibleExpr(TypesCompatibleExpr *Node);
// C++
void VisitCXXNamedCastExpr(CXXNamedCastExpr *Node);
@@ -356,12 +355,6 @@
Doc.addAttribute("name", Node->getLabel()->getName());
}
-void StmtXML::VisitTypesCompatibleExpr(TypesCompatibleExpr *Node) {
- DumpExpr(Node);
- DumpTypeExpr(Node->getArgType1());
- DumpTypeExpr(Node->getArgType2());
-}
-
//===----------------------------------------------------------------------===//
// C++ Expressions
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Dec 8 16:35:30 2010
@@ -728,7 +728,6 @@
case tok::kw___builtin_va_arg:
case tok::kw___builtin_offsetof:
case tok::kw___builtin_choose_expr:
- case tok::kw___builtin_types_compatible_p:
return ParseBuiltinPrimaryExpression();
case tok::kw___null:
return Actions.ActOnGNUNullExpr(ConsumeToken());
@@ -987,6 +986,7 @@
case tok::kw___has_virtual_destructor:
return ParseUnaryTypeTrait();
+ case tok::kw___builtin_types_compatible_p:
case tok::kw___is_base_of:
return ParseBinaryTypeTrait();
@@ -1477,25 +1477,6 @@
Expr2.take(), ConsumeParen());
break;
}
- case tok::kw___builtin_types_compatible_p:
- TypeResult Ty1 = ParseTypeName();
-
- if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
- return ExprError();
-
- TypeResult Ty2 = ParseTypeName();
-
- if (Tok.isNot(tok::r_paren)) {
- Diag(Tok, diag::err_expected_rparen);
- return ExprError();
- }
-
- if (Ty1.isInvalid() || Ty2.isInvalid())
- Res = ExprError();
- else
- Res = Actions.ActOnTypesCompatibleExpr(StartLoc, Ty1.get(), Ty2.get(),
- ConsumeParen());
- break;
}
if (Res.isInvalid())
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Wed Dec 8 16:35:30 2010
@@ -1823,7 +1823,8 @@
static BinaryTypeTrait BinaryTypeTraitFromTokKind(tok::TokenKind kind) {
switch(kind) {
default: llvm_unreachable("Not a known binary type trait");
- case tok::kw___is_base_of: return BTT_IsBaseOf;
+ case tok::kw___is_base_of: return BTT_IsBaseOf;
+ case tok::kw___builtin_types_compatible_p: return BTT_TypeCompatible;
}
}
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Dec 8 16:35:30 2010
@@ -8126,35 +8126,6 @@
}
-ExprResult Sema::ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
- ParsedType arg1, ParsedType arg2,
- SourceLocation RPLoc) {
- TypeSourceInfo *argTInfo1;
- QualType argT1 = GetTypeFromParser(arg1, &argTInfo1);
- TypeSourceInfo *argTInfo2;
- QualType argT2 = GetTypeFromParser(arg2, &argTInfo2);
-
- assert((!argT1.isNull() && !argT2.isNull()) && "Missing type argument(s)");
-
- return BuildTypesCompatibleExpr(BuiltinLoc, argTInfo1, argTInfo2, RPLoc);
-}
-
-ExprResult
-Sema::BuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
- TypeSourceInfo *argTInfo1,
- TypeSourceInfo *argTInfo2,
- SourceLocation RPLoc) {
- if (getLangOptions().CPlusPlus) {
- Diag(BuiltinLoc, diag::err_types_compatible_p_in_cplusplus)
- << SourceRange(BuiltinLoc, RPLoc);
- return ExprError();
- }
-
- return Owned(new (Context) TypesCompatibleExpr(Context.IntTy, BuiltinLoc,
- argTInfo1, argTInfo2, RPLoc));
-}
-
-
ExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc,
Expr *CondExpr,
Expr *LHSExpr, Expr *RHSExpr,
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Dec 8 16:35:30 2010
@@ -2378,6 +2378,9 @@
return true;
return false;
+ case BTT_TypeCompatible:
+ return Self.Context.typesAreCompatible(LhsT.getUnqualifiedType(),
+ RhsT.getUnqualifiedType());
}
llvm_unreachable("Unknown type trait or not implemented");
}
@@ -2402,15 +2405,29 @@
RequireCompleteType(KWLoc, RhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
return ExprError();
+ } else if (BTT == BTT_TypeCompatible) {
+ if (getLangOptions().CPlusPlus) {
+ Diag(KWLoc, diag::err_types_compatible_p_in_cplusplus)
+ << SourceRange(KWLoc, RParen);
+ return ExprError();
+ }
}
bool Value = false;
if (!LhsT->isDependentType() && !RhsT->isDependentType())
Value = EvaluateBinaryTypeTrait(*this, BTT, LhsT, RhsT, KWLoc);
+ // Select trait result type.
+ QualType ResultType;
+ switch (BTT) {
+ default: llvm_unreachable("Unknown type trait or not implemented");
+ case BTT_IsBaseOf: ResultType = Context.BoolTy; break;
+ case BTT_TypeCompatible: ResultType = Context.IntTy; break;
+ }
+
return Owned(new (Context) BinaryTypeTraitExpr(KWLoc, BTT, LhsTSInfo,
RhsTSInfo, Value, RParen,
- Context.BoolTy));
+ ResultType));
}
QualType Sema::CheckPointerToMemberOperands(Expr *&lex, Expr *&rex,
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Dec 8 16:35:30 2010
@@ -1348,19 +1348,6 @@
return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc);
}
- /// \brief Build a new __builtin_types_compatible_p expression.
- ///
- /// By default, performs semantic analysis to build the new expression.
- /// Subclasses may override this routine to provide different behavior.
- ExprResult RebuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
- TypeSourceInfo *TInfo1,
- TypeSourceInfo *TInfo2,
- SourceLocation RParenLoc) {
- return getSema().BuildTypesCompatibleExpr(BuiltinLoc,
- TInfo1, TInfo2,
- RParenLoc);
- }
-
/// \brief Build a new __builtin_choose_expr expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -4936,30 +4923,6 @@
template<typename Derived>
ExprResult
-TreeTransform<Derived>::TransformTypesCompatibleExpr(TypesCompatibleExpr *E) {
- TypeSourceInfo *TInfo1;
- TypeSourceInfo *TInfo2;
-
- TInfo1 = getDerived().TransformType(E->getArgTInfo1());
- if (!TInfo1)
- return ExprError();
-
- TInfo2 = getDerived().TransformType(E->getArgTInfo2());
- if (!TInfo2)
- return ExprError();
-
- if (!getDerived().AlwaysRebuild() &&
- TInfo1 == E->getArgTInfo1() &&
- TInfo2 == E->getArgTInfo2())
- return SemaRef.Owned(E);
-
- return getDerived().RebuildTypesCompatibleExpr(E->getBuiltinLoc(),
- TInfo1, TInfo2,
- E->getRParenLoc());
-}
-
-template<typename Derived>
-ExprResult
TreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) {
ExprResult Cond = getDerived().TransformExpr(E->getCond());
if (Cond.isInvalid())
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Wed Dec 8 16:35:30 2010
@@ -115,7 +115,6 @@
void VisitVAArgExpr(VAArgExpr *E);
void VisitAddrLabelExpr(AddrLabelExpr *E);
void VisitStmtExpr(StmtExpr *E);
- void VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
void VisitChooseExpr(ChooseExpr *E);
void VisitGNUNullExpr(GNUNullExpr *E);
void VisitShuffleVectorExpr(ShuffleVectorExpr *E);
@@ -759,14 +758,6 @@
E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
}
-void ASTStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
- VisitExpr(E);
- E->setArgTInfo1(GetTypeSourceInfo(Record, Idx));
- E->setArgTInfo2(GetTypeSourceInfo(Record, Idx));
- E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
-}
-
void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
VisitExpr(E);
E->setCond(Reader.ReadSubExpr());
@@ -1606,10 +1597,6 @@
S = new (Context) StmtExpr(Empty);
break;
- case EXPR_TYPES_COMPATIBLE:
- S = new (Context) TypesCompatibleExpr(Empty);
- break;
-
case EXPR_CHOOSE:
S = new (Context) ChooseExpr(Empty);
break;
@@ -1812,7 +1799,7 @@
S = new (Context) UnaryTypeTraitExpr(Empty);
break;
- case EXPR_CXX_BINARY_TYPE_TRAIT:
+ case EXPR_BINARY_TYPE_TRAIT:
S = new (Context) BinaryTypeTraitExpr(Empty);
break;
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Dec 8 16:35:30 2010
@@ -581,7 +581,6 @@
RECORD(EXPR_VA_ARG);
RECORD(EXPR_ADDR_LABEL);
RECORD(EXPR_STMT);
- RECORD(EXPR_TYPES_COMPATIBLE);
RECORD(EXPR_CHOOSE);
RECORD(EXPR_GNU_NULL);
RECORD(EXPR_SHUFFLE_VECTOR);
Modified: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterStmt.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Wed Dec 8 16:35:30 2010
@@ -86,7 +86,6 @@
void VisitVAArgExpr(VAArgExpr *E);
void VisitAddrLabelExpr(AddrLabelExpr *E);
void VisitStmtExpr(StmtExpr *E);
- void VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
void VisitChooseExpr(ChooseExpr *E);
void VisitGNUNullExpr(GNUNullExpr *E);
void VisitShuffleVectorExpr(ShuffleVectorExpr *E);
@@ -728,15 +727,6 @@
Code = serialization::EXPR_STMT;
}
-void ASTStmtWriter::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
- VisitExpr(E);
- Writer.AddTypeSourceInfo(E->getArgTInfo1(), Record);
- Writer.AddTypeSourceInfo(E->getArgTInfo2(), Record);
- Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
- Code = serialization::EXPR_TYPES_COMPATIBLE;
-}
-
void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) {
VisitExpr(E);
Writer.AddStmt(E->getCond());
@@ -1293,7 +1283,7 @@
Writer.AddSourceRange(E->getSourceRange(), Record);
Writer.AddTypeSourceInfo(E->getLhsTypeSourceInfo(), Record);
Writer.AddTypeSourceInfo(E->getRhsTypeSourceInfo(), Record);
- Code = serialization::EXPR_CXX_BINARY_TYPE_TRAIT;
+ Code = serialization::EXPR_BINARY_TYPE_TRAIT;
}
void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Dec 8 16:35:30 2010
@@ -1605,7 +1605,6 @@
void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
void VisitStmt(Stmt *S);
void VisitSwitchStmt(SwitchStmt *S);
- void VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
void VisitWhileStmt(WhileStmt *W);
void VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E);
void VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E);
@@ -1878,10 +1877,6 @@
AddStmt(S->getCond());
AddDecl(S->getConditionVariable());
}
-void EnqueueVisitor::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
- AddTypeLoc(E->getArgTInfo2());
- AddTypeLoc(E->getArgTInfo1());
-}
void EnqueueVisitor::VisitWhileStmt(WhileStmt *W) {
AddStmt(W->getBody());
Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=121298&r1=121297&r2=121298&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Wed Dec 8 16:35:30 2010
@@ -128,7 +128,6 @@
case Stmt::VAArgExprClass:
case Stmt::AddrLabelExprClass:
case Stmt::StmtExprClass:
- case Stmt::TypesCompatibleExprClass:
case Stmt::ChooseExprClass:
case Stmt::GNUNullExprClass:
case Stmt::CXXStaticCastExprClass:
More information about the cfe-commits
mailing list