aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-09 15:09:02 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-09 15:09:02 +0000
commit1a51b4a11b7db25cac2134249711ecaaf9d1c0a8 (patch)
tree7581b196e4ca630c2740d7d96b0df108df28a82e /lib/Sema/SemaType.cpp
parentceca4665135722dacde063de4486813b0bd02575 (diff)
Make Sema::getTypeName return the opaque pointer of a QualType rather
than a Decl, which gives us some more flexibility to express the results with the type system. There are no clients using this flexibility yet, but it's meant to be able to describe qualified names as written in the source (e.g., "foo::type") or template-ids that name a class template specialization (e.g., "std::vector<INT>"). DeclSpec's TST_typedef has become TST_typename, to reflect its use to describe types found by name (that may or may not be typedefs). The type representation of a DeclSpec with TST_typename is an opaque QualType pointer. All users of TST_typedef, both direct and indirect, have been updated for these changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64141 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index d31402de71..25fd5c39fe 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -133,36 +133,25 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) {
Result = Context.getTypeDeclType(cast<TypeDecl>(D));
break;
}
- case DeclSpec::TST_typedef: {
- Decl *D = static_cast<Decl *>(DS.getTypeRep());
- assert(D && "Didn't get a decl for a typedef?");
+ case DeclSpec::TST_typename: {
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
DS.getTypeSpecSign() == 0 &&
"Can't handle qualifiers on typedef names yet!");
- DeclSpec::ProtocolQualifierListTy PQ = DS.getProtocolQualifiers();
-
- // FIXME: Adding a TST_objcInterface clause doesn't seem ideal, so
- // we have this "hack" for now...
- if (ObjCInterfaceDecl *ObjCIntDecl = dyn_cast<ObjCInterfaceDecl>(D)) {
- if (PQ == 0) {
- Result = Context.getObjCInterfaceType(ObjCIntDecl);
- break;
- }
-
- Result = Context.getObjCQualifiedInterfaceType(ObjCIntDecl,
- (ObjCProtocolDecl**)PQ,
- DS.getNumProtocolQualifiers());
- break;
- } else if (TypedefDecl *typeDecl = dyn_cast<TypedefDecl>(D)) {
- if (Context.getObjCIdType() == Context.getTypedefType(typeDecl) && PQ) {
+ Result = QualType::getFromOpaquePtr(DS.getTypeRep());
+
+ if (DeclSpec::ProtocolQualifierListTy PQ = DS.getProtocolQualifiers()) {
+ // FIXME: Adding a TST_objcInterface clause doesn't seem ideal, so
+ // we have this "hack" for now...
+ if (const ObjCInterfaceType *Interface = Result->getAsObjCInterfaceType())
+ Result = Context.getObjCQualifiedInterfaceType(Interface->getDecl(),
+ (ObjCProtocolDecl**)PQ,
+ DS.getNumProtocolQualifiers());
+ else if (Result == Context.getObjCIdType())
// id<protocol-list>
Result = Context.getObjCQualifiedIdType((ObjCProtocolDecl**)PQ,
DS.getNumProtocolQualifiers());
- break;
- }
}
// TypeQuals handled by caller.
- Result = Context.getTypeDeclType(dyn_cast<TypeDecl>(D));
break;
}
case DeclSpec::TST_typeofType:
@@ -240,7 +229,8 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) {
// cv-qualifiers are introduced through the use of a typedef
// (7.1.3) or of a template type argument (14.3), in which
// case the cv-qualifiers are ignored.
- if (DS.getTypeSpecType() == DeclSpec::TST_typedef &&
+ // FIXME: Shouldn't we be checking SCS_typedef here?
+ if (DS.getTypeSpecType() == DeclSpec::TST_typename &&
TypeQuals && Result->isReferenceType()) {
TypeQuals &= ~QualType::Const;
TypeQuals &= ~QualType::Volatile;