diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-16 21:35:15 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-16 21:35:15 +0000 |
commit | a4923eb7c4b04d360cb2747641a5e92818edf804 (patch) | |
tree | 573c9d43fd0b6daf0f1d5ee02ebbffd7e3e84cfd /include/clang/Frontend | |
parent | ad35a83102683b00a7e28707eee7f2d8c994b742 (diff) |
First part of changes to eliminate problems with cv-qualifiers and
sugared types. The basic problem is that our qualifier accessors
(getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at
the current QualType and not at any qualifiers that come from sugared
types, meaning that we won't see these qualifiers through, e.g.,
typedefs:
typedef const int CInt;
typedef CInt Self;
Self.isConstQualified() currently returns false!
Various bugs (e.g., PR5383) have cropped up all over the front end due
to such problems. I'm addressing this problem by splitting each
qualifier accessor into two versions:
- the "local" version only returns qualifiers on this particular
QualType instance
- the "normal" version that will eventually combine qualifiers from this
QualType instance with the qualifiers on the canonical type to
produce the full set of qualifiers.
This commit adds the local versions and switches a few callers from
the "normal" version (e.g., isConstQualified) over to the "local"
version (e.g., isLocalConstQualified) when that is the right thing to
do, e.g., because we're printing or serializing the qualifiers. Also,
switch a bunch of
Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType()
expressions over to
Context.hasSameUnqualifiedType(T1, T2)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r-- | include/clang/Frontend/PCHWriter.h | 3 | ||||
-rw-r--r-- | include/clang/Frontend/TypeXML.def | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h index 22427eb671..b520f4be1d 100644 --- a/include/clang/Frontend/PCHWriter.h +++ b/include/clang/Frontend/PCHWriter.h @@ -52,7 +52,8 @@ struct UnsafeQualTypeDenseMapInfo { return QualType::getFromOpaquePtr((void*) 2); } static inline unsigned getHashValue(QualType T) { - assert(!T.getFastQualifiers() && "hash invalid for types with fast quals"); + assert(!T.getLocalFastQualifiers() && + "hash invalid for types with fast quals"); uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr()); return (unsigned(v) >> 4) ^ (unsigned(v) >> 9); } diff --git a/include/clang/Frontend/TypeXML.def b/include/clang/Frontend/TypeXML.def index 6aca15a754..35f5debe5c 100644 --- a/include/clang/Frontend/TypeXML.def +++ b/include/clang/Frontend/TypeXML.def @@ -65,9 +65,9 @@ NODE_XML(QualType, "CvQualifiedType") ID_ATTRIBUTE_XML TYPE_ATTRIBUTE_XML(getTypePtr()) // the qualified type, e.g. for 'T* const' it's 'T*' - ATTRIBUTE_OPT_XML(isConstQualified(), "const") // boolean - ATTRIBUTE_OPT_XML(isVolatileQualified(), "volatile") // boolean - ATTRIBUTE_OPT_XML(isRestrictQualified(), "restrict") // boolean + ATTRIBUTE_OPT_XML(isLocalConstQualified(), "const") // boolean + ATTRIBUTE_OPT_XML(isLocalVolatileQualified(), "volatile") // boolean + ATTRIBUTE_OPT_XML(isLocalRestrictQualified(), "restrict") // boolean ATTRIBUTE_OPT_XML(getObjCGCAttr(), "objc_gc") // Qualifiers::GC ATTRIBUTE_OPT_XML(getAddressSpace(), "address_space") // unsigned END_NODE_XML |