From aecbefa519f604ceec938982db631aa0edf1fd01 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 12 Nov 2006 00:05:06 +0000 Subject: [PATCH] We can now parse and remember the distinction between: 'unsigned char' and 'unsigned char const'. -Chris llvm-svn: 39172 --- clang/AST/SemaType.cpp | 4 ++-- clang/Sema/SemaType.cpp | 4 ++-- clang/include/clang/AST/Type.h | 17 +++++++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/clang/AST/SemaType.cpp b/clang/AST/SemaType.cpp index 7fab1fa56acd..b6447efc762c 100644 --- a/clang/AST/SemaType.cpp +++ b/clang/AST/SemaType.cpp @@ -131,7 +131,6 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) { //DeclSpec::TST_union: //DeclSpec::TST_struct: //DeclSpec::TST_typedef: - } } @@ -140,7 +139,8 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) { TypeRef Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { TypeRef T = ConvertDeclSpecToType(D.getDeclSpec(), Context); - // FIXME: Apply const/volatile/restrict qualifiers to T. + // Apply const/volatile/restrict qualifiers to T. + T = T.getQualifiedType(D.getDeclSpec().TypeQualifiers); return T; return TypeRef(); diff --git a/clang/Sema/SemaType.cpp b/clang/Sema/SemaType.cpp index 7fab1fa56acd..b6447efc762c 100644 --- a/clang/Sema/SemaType.cpp +++ b/clang/Sema/SemaType.cpp @@ -131,7 +131,6 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) { //DeclSpec::TST_union: //DeclSpec::TST_struct: //DeclSpec::TST_typedef: - } } @@ -140,7 +139,8 @@ static TypeRef ConvertDeclSpecToType(const DeclSpec &DS, ASTContext &Ctx) { TypeRef Sema::GetTypeForDeclarator(Declarator &D, Scope *S) { TypeRef T = ConvertDeclSpecToType(D.getDeclSpec(), Context); - // FIXME: Apply const/volatile/restrict qualifiers to T. + // Apply const/volatile/restrict qualifiers to T. + T = T.getQualifiedType(D.getDeclSpec().TypeQualifiers); return T; return TypeRef(); diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index d3249dc400ff..fa55f162ef4b 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -51,12 +51,16 @@ public: ThePtr |= Quals; } + Type *getTypePtr() const { + return reinterpret_cast(ThePtr & ~CVRFlags); + } + Type &operator*() const { - return *reinterpret_cast(ThePtr & ~CVRFlags); + return *getTypePtr(); } Type *operator->() const { - return reinterpret_cast(ThePtr & ~CVRFlags); + return getTypePtr(); } /// isNull - Return true if this TypeRef doesn't point to a type yet. @@ -77,6 +81,15 @@ public: return ThePtr & CVRFlags; } + TypeRef getQualifiedType(unsigned TQs) const { + return TypeRef(getTypePtr(), TQs); + } + + TypeRef getUnqualifiedType() const { + return TypeRef(getTypePtr()); + } + + void dump() const; };