[cfe-commits] r110663 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/RecursiveASTVisitor.h lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp lib/Sema/Sema.h lib/Sema/SemaExpr.cpp lib/Sema/TreeTransform.h
Abramo Bagnara
abramo.bagnara at gmail.com
Tue Aug 10 01:50:03 PDT 2010
Author: abramo
Date: Tue Aug 10 03:50:03 2010
New Revision: 110663
URL: http://llvm.org/viewvc/llvm-project?rev=110663&view=rev
Log:
Added TypeLocs to TypesCompatibleExpr node.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=110663&r1=110662&r2=110663&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Aug 10 03:50:03 2010
@@ -2537,23 +2537,27 @@
/// expressions) are compatible. The result of this built-in function can be
/// used in integer constant expressions.
class TypesCompatibleExpr : public Expr {
- QualType Type1;
- QualType Type2;
+ TypeSourceInfo *TInfo1;
+ TypeSourceInfo *TInfo2;
SourceLocation BuiltinLoc, RParenLoc;
public:
TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
- QualType t1, QualType t2, SourceLocation RP) :
+ TypeSourceInfo *tinfo1, TypeSourceInfo *tinfo2,
+ SourceLocation RP) :
Expr(TypesCompatibleExprClass, ReturnType, false, false),
- Type1(t1), Type2(t2), BuiltinLoc(BLoc), RParenLoc(RP) {}
+ TInfo1(tinfo1), TInfo2(tinfo2), BuiltinLoc(BLoc), RParenLoc(RP) {}
/// \brief Build an empty __builtin_type_compatible_p expression.
explicit TypesCompatibleExpr(EmptyShell Empty)
: Expr(TypesCompatibleExprClass, Empty) { }
- QualType getArgType1() const { return Type1; }
- void setArgType1(QualType T) { Type1 = T; }
- QualType getArgType2() const { return Type2; }
- void setArgType2(QualType T) { Type2 = T; }
+ 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; }
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=110663&r1=110662&r2=110663&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Aug 10 03:50:03 2010
@@ -1633,8 +1633,8 @@
})
DEF_TRAVERSE_STMT(TypesCompatibleExpr, {
- TRY_TO(TraverseType(S->getArgType1()));
- TRY_TO(TraverseType(S->getArgType2()));
+ TRY_TO(TraverseTypeLoc(S->getArgTInfo1()->getTypeLoc()));
+ TRY_TO(TraverseTypeLoc(S->getArgTInfo2()->getTypeLoc()));
})
DEF_TRAVERSE_STMT(UnaryTypeTraitExpr, {
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=110663&r1=110662&r2=110663&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Tue Aug 10 03:50:03 2010
@@ -730,8 +730,8 @@
void PCHStmtReader::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
VisitExpr(E);
- E->setArgType1(Reader.GetType(Record[Idx++]));
- E->setArgType2(Reader.GetType(Record[Idx++]));
+ E->setArgTInfo1(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
+ E->setArgTInfo2(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
}
Modified: cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterStmt.cpp?rev=110663&r1=110662&r2=110663&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterStmt.cpp Tue Aug 10 03:50:03 2010
@@ -718,8 +718,8 @@
void PCHStmtWriter::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
VisitExpr(E);
- Writer.AddTypeRef(E->getArgType1(), Record);
- Writer.AddTypeRef(E->getArgType2(), Record);
+ Writer.AddTypeSourceInfo(E->getArgTInfo1(), Record);
+ Writer.AddTypeSourceInfo(E->getArgTInfo2(), Record);
Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_TYPES_COMPATIBLE;
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=110663&r1=110662&r2=110663&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Aug 10 03:50:03 2010
@@ -2154,6 +2154,10 @@
virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
TypeTy *arg1, TypeTy *arg2,
SourceLocation RPLoc);
+ OwningExprResult BuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
+ TypeSourceInfo *argTInfo1,
+ TypeSourceInfo *argTInfo2,
+ SourceLocation RPLoc);
// __builtin_choose_expr(constExpr, expr1, expr2)
virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=110663&r1=110662&r2=110663&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 10 03:50:03 2010
@@ -7019,12 +7019,21 @@
Sema::OwningExprResult Sema::ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
TypeTy *arg1,TypeTy *arg2,
SourceLocation RPLoc) {
- // FIXME: Preserve type source info.
- QualType argT1 = GetTypeFromParser(arg1);
- QualType argT2 = GetTypeFromParser(arg2);
+ 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);
+}
+
+Sema::OwningExprResult
+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);
@@ -7032,9 +7041,10 @@
}
return Owned(new (Context) TypesCompatibleExpr(Context.IntTy, BuiltinLoc,
- argT1, argT2, RPLoc));
+ argTInfo1, argTInfo2, RPLoc));
}
+
Sema::OwningExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc,
ExprArg cond,
ExprArg expr1, ExprArg expr2,
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=110663&r1=110662&r2=110663&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Aug 10 03:50:03 2010
@@ -1354,11 +1354,11 @@
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
- QualType T1, QualType T2,
+ TypeSourceInfo *TInfo1,
+ TypeSourceInfo *TInfo2,
SourceLocation RParenLoc) {
- return getSema().ActOnTypesCompatibleExpr(BuiltinLoc,
- T1.getAsOpaquePtr(),
- T2.getAsOpaquePtr(),
+ return getSema().BuildTypesCompatibleExpr(BuiltinLoc,
+ TInfo1, TInfo2,
RParenLoc);
}
@@ -4855,27 +4855,29 @@
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformTypesCompatibleExpr(TypesCompatibleExpr *E) {
- QualType T1, T2;
+ TypeSourceInfo *TInfo1;
+ TypeSourceInfo *TInfo2;
{
// FIXME: Source location isn't quite accurate.
TemporaryBase Rebase(*this, E->getBuiltinLoc(), DeclarationName());
- T1 = getDerived().TransformType(E->getArgType1());
- if (T1.isNull())
+ TInfo1 = getDerived().TransformType(E->getArgTInfo1());
+ if (!TInfo1)
return SemaRef.ExprError();
- T2 = getDerived().TransformType(E->getArgType2());
- if (T2.isNull())
+ TInfo2 = getDerived().TransformType(E->getArgTInfo2());
+ if (!TInfo2)
return SemaRef.ExprError();
}
if (!getDerived().AlwaysRebuild() &&
- T1 == E->getArgType1() &&
- T2 == E->getArgType2())
+ TInfo1 == E->getArgTInfo1() &&
+ TInfo2 == E->getArgTInfo2())
return SemaRef.Owned(E->Retain());
return getDerived().RebuildTypesCompatibleExpr(E->getBuiltinLoc(),
- T1, T2, E->getRParenLoc());
+ TInfo1, TInfo2,
+ E->getRParenLoc());
}
template<typename Derived>
More information about the cfe-commits
mailing list