correctly handle stuff like:

typedef int G;
  X = sizeof(const G);
  X = sizeof(restrict G);

llvm-svn: 39190
This commit is contained in:
Chris Lattner 2006-11-20 04:17:27 +00:00
parent d0342e5989
commit f0a40e7ef4
4 changed files with 12 additions and 6 deletions

View File

@ -79,10 +79,10 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
case DeclSpec::TST_typedef: {
Decl *D = (Decl *)DS.TypenameRep;
assert(D && "Didn't get a decl for a typedef?");
// FIXME: apply type quals!
assert(DS.TypeSpecWidth == 0 && DS.TypeSpecComplex == 0 &&
DS.TypeSpecSign == 0 && DS.TypeQualifiers == 0 &&
DS.TypeSpecSign == 0 &&
"Can't handle qualifiers on typedef names yet!");
// TypeQuals handled by caller.
return Ctx.getTypeDeclType(cast<TypedefDecl>(D));
}
}

View File

@ -260,7 +260,7 @@ void StmtPrinter::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node) {
OS << (Node->isSizeOf() ? "sizeof(" : "__alignof(");
std::string TypeStr;
Node->getArgumentType()->getAsString(TypeStr);
Node->getArgumentType().getAsString(TypeStr);
OS << TypeStr << ")";
}
void StmtPrinter::VisitArraySubscriptExpr(ArraySubscriptExpr *Node) {

View File

@ -98,5 +98,11 @@ void ArrayType::getAsString(std::string &S) const {
}
void TypeNameType::getAsString(std::string &InnerString) const {
InnerString += getDecl()->getIdentifier()->getName();
if (InnerString.empty()) {
InnerString = getDecl()->getIdentifier()->getName();
} else {
// Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString;
InnerString = getDecl()->getIdentifier()->getName() + InnerString;
}
}

View File

@ -79,10 +79,10 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) {
case DeclSpec::TST_typedef: {
Decl *D = (Decl *)DS.TypenameRep;
assert(D && "Didn't get a decl for a typedef?");
// FIXME: apply type quals!
assert(DS.TypeSpecWidth == 0 && DS.TypeSpecComplex == 0 &&
DS.TypeSpecSign == 0 && DS.TypeQualifiers == 0 &&
DS.TypeSpecSign == 0 &&
"Can't handle qualifiers on typedef names yet!");
// TypeQuals handled by caller.
return Ctx.getTypeDeclType(cast<TypedefDecl>(D));
}
}