aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index a68fea469d..0b513ecbd1 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -931,6 +931,19 @@ QualType ASTContext::getPointerDiffType() const {
// Type Operators
//===----------------------------------------------------------------------===//
+/// getCanonicalType - Return the canonical (structural) type corresponding to
+/// the specified potentially non-canonical type. The non-canonical version
+/// of a type may have many "decorated" versions of types. Decorators can
+/// include typedefs, 'typeof' operators, etc. The returned type is guaranteed
+/// to be free of any of these, allowing two canonical types to be compared
+/// for exact equality with a simple pointer comparison.
+QualType ASTContext::getCanonicalType(QualType T) {
+ QualType CanType = T.getTypePtr()->getCanonicalTypeInternal();
+ return QualType(CanType.getTypePtr(),
+ T.getCVRQualifiers() | CanType.getCVRQualifiers());
+}
+
+
/// getArrayDecayedType - Return the properly qualified result of decaying the
/// specified array type to a pointer. This operation is non-trivial when
/// handling typedefs etc. The canonical type of "T" must be an array type,