aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/Type.h
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2008-03-25 18:36:32 +0000
committerNate Begeman <natebegeman@mac.com>2008-03-25 18:36:32 +0000
commit8e7dafec4b70303dfaff95151cd06bfc5532720c (patch)
tree834ff5f234c78956634632aadc23f410fad41b17 /include/clang/AST/Type.h
parent245f1b559e162e487c9f2c47778cbd150f32fd34 (diff)
Extend QualType::getAddressSpace to do the right thing for array types, and in
the future, RecordTypes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48784 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/Type.h')
-rw-r--r--include/clang/AST/Type.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index e434ea2c0b..60cbfc83ad 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -1087,7 +1087,11 @@ public:
// FIXME: This predicate is a helper to QualType/Type. It needs to
// recursively check all fields for const-ness. If any field is declared
// const, it needs to return false.
- bool hasConstFields() const { return false; }
+ bool hasConstFields() const { return false; }
+
+ // FIXME: RecordType needs to check when it is created that all fields are in
+ // the same address space, and return that.
+ unsigned getAddressSpace() const { return 0; }
static bool classof(const Type *T);
static bool classof(const RecordType *) { return true; }
@@ -1114,6 +1118,10 @@ inline QualType QualType::getUnqualifiedType() const {
/// getAddressSpace - Return the address space of this type.
inline unsigned QualType::getAddressSpace() const {
+ if (const ArrayType *AT = dyn_cast<ArrayType>(getCanonicalType()))
+ return AT->getBaseType().getAddressSpace();
+ if (const RecordType *RT = dyn_cast<RecordType>(getCanonicalType()))
+ return RT->getAddressSpace();
if (const ASQualType *ASQT = dyn_cast<ASQualType>(getCanonicalType()))
return ASQT->getAddressSpace();
return 0;