forked from OSchip/llvm-project
parent
f0a40e7ef4
commit
0d8b1a1eff
|
@ -109,6 +109,8 @@ Decl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, Decl *PrevDecl) {
|
|||
assert(D.getIdentifier() && "Wrong callback for declspec withotu declarator");
|
||||
|
||||
TypeRef T = GetTypeForDeclarator(D, S);
|
||||
if (T.isNull()) return 0;
|
||||
|
||||
return new TypedefDecl(D.getIdentifier(), T, PrevDecl);
|
||||
}
|
||||
|
||||
|
|
|
@ -304,8 +304,8 @@ Action::ExprResult Sema::
|
|||
ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
|
||||
SourceLocation LParenLoc, TypeTy *Ty,
|
||||
SourceLocation RParenLoc) {
|
||||
// Error parsing type, ignore.
|
||||
if (Ty == 0) return 0;
|
||||
// If error parsing type, ignore.
|
||||
if (Ty == 0) return true;
|
||||
return new SizeOfAlignOfTypeExpr(isSizeof, TypeRef::getFromOpaquePtr(Ty));
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,9 @@ ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
|
|||
Action::ExprResult Sema::
|
||||
ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
|
||||
SourceLocation RParenLoc, ExprTy *Op) {
|
||||
return new CastExpr((Type*)Ty, (Expr*)Op);
|
||||
// If error parsing type, ignore.
|
||||
if (Ty == 0) return true;
|
||||
return new CastExpr(TypeRef::getFromOpaquePtr(Ty), (Expr*)Op);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
|
|||
/// instances.
|
||||
TypeRef Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
|
||||
TypeRef T = ConvertDeclSpecToType(D.getDeclSpec(), Context);
|
||||
|
||||
// If there was an error parsing declspecs, return a null type pointer.
|
||||
if (T.isNull()) return T;
|
||||
|
||||
// Apply const/volatile/restrict qualifiers to T.
|
||||
T = T.getQualifiedType(D.getDeclSpec().TypeQualifiers);
|
||||
|
|
|
@ -289,9 +289,9 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
|
|||
}
|
||||
void StmtPrinter::VisitCastExpr(CastExpr *Node) {
|
||||
OS << "(";
|
||||
// TODO PRINT TYPE
|
||||
OS << "<type>";
|
||||
OS << ")";
|
||||
std::string TypeStr;
|
||||
Node->getDestType().getAsString(TypeStr);
|
||||
OS << TypeStr << ")";
|
||||
PrintExpr(Node->getSubExpr());
|
||||
}
|
||||
void StmtPrinter::VisitBinaryOperator(BinaryOperator *Node) {
|
||||
|
|
|
@ -109,6 +109,8 @@ Decl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, Decl *PrevDecl) {
|
|||
assert(D.getIdentifier() && "Wrong callback for declspec withotu declarator");
|
||||
|
||||
TypeRef T = GetTypeForDeclarator(D, S);
|
||||
if (T.isNull()) return 0;
|
||||
|
||||
return new TypedefDecl(D.getIdentifier(), T, PrevDecl);
|
||||
}
|
||||
|
||||
|
|
|
@ -304,8 +304,8 @@ Action::ExprResult Sema::
|
|||
ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
|
||||
SourceLocation LParenLoc, TypeTy *Ty,
|
||||
SourceLocation RParenLoc) {
|
||||
// Error parsing type, ignore.
|
||||
if (Ty == 0) return 0;
|
||||
// If error parsing type, ignore.
|
||||
if (Ty == 0) return true;
|
||||
return new SizeOfAlignOfTypeExpr(isSizeof, TypeRef::getFromOpaquePtr(Ty));
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,9 @@ ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
|
|||
Action::ExprResult Sema::
|
||||
ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
|
||||
SourceLocation RParenLoc, ExprTy *Op) {
|
||||
return new CastExpr((Type*)Ty, (Expr*)Op);
|
||||
// If error parsing type, ignore.
|
||||
if (Ty == 0) return true;
|
||||
return new CastExpr(TypeRef::getFromOpaquePtr(Ty), (Expr*)Op);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
|
|||
/// instances.
|
||||
TypeRef Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
|
||||
TypeRef T = ConvertDeclSpecToType(D.getDeclSpec(), Context);
|
||||
|
||||
// If there was an error parsing declspecs, return a null type pointer.
|
||||
if (T.isNull()) return T;
|
||||
|
||||
// Apply const/volatile/restrict qualifiers to T.
|
||||
T = T.getQualifiedType(D.getDeclSpec().TypeQualifiers);
|
||||
|
|
|
@ -215,10 +215,12 @@ public:
|
|||
/// CastExpr - [C99 6.5.4] Cast Operators.
|
||||
///
|
||||
class CastExpr : public Expr {
|
||||
Type *Ty;
|
||||
TypeRef Ty;
|
||||
Expr *Op;
|
||||
public:
|
||||
CastExpr(Type *ty, Expr *op) : Ty(ty), Op(op) {}
|
||||
CastExpr(TypeRef ty, Expr *op) : Ty(ty), Op(op) {}
|
||||
|
||||
TypeRef getDestType() const { return Ty; }
|
||||
|
||||
Expr *getSubExpr() { return Op; }
|
||||
virtual void visit(StmtVisitor &Visitor);
|
||||
|
|
Loading…
Reference in New Issue