summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-06 22:41:35 +0000
committerChris Lattner <sabre@nondot.org>2008-04-06 22:41:35 +0000
commited0d0795ff580ab5ad6f83361caa459e468e4345 (patch)
tree3f8412fcf30665badab0c53db3a0f3fa90b860f6 /clang/lib/AST/ASTContext.cpp
parent56a7bf5a7e3526966ffeb96d6b084c7afef6bdef (diff)
downloadbcm5719-llvm-ed0d0795ff580ab5ad6f83361caa459e468e4345.tar.gz
bcm5719-llvm-ed0d0795ff580ab5ad6f83361caa459e468e4345.zip
introduce a new ASTContext::getCanonicalType method. This is the first
step towards fixing PR2189. llvm-svn: 49291
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a68fea469d1..0b513ecbd19 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/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,
OpenPOWER on IntegriCloud