diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-12-05 23:32:09 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-12-05 23:32:09 +0000 |
commit | 898574e7496ba8fd76290079d3a9d06954992734 (patch) | |
tree | 04ec2f50ad0055a77697cb55574a4e675cf30ef8 /lib/AST/Type.cpp | |
parent | 9482a4f0feca4bc9eb7c6ad36e21cbf7365f5359 (diff) |
Introduce basic support for dependent types, type-dependent
expressions, and value-dependent expressions. This permits us to parse
some template definitions.
This is not a complete solution; we're missing type- and
value-dependent computations for most of the expression types, and
we're missing checks for dependent types and type-dependent
expressions throughout Sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 303fc7e7ca..5909c976aa 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -43,6 +43,10 @@ void VariableArrayType::Destroy(ASTContext& C) { delete this; } +void DependentSizedArrayType::Destroy(ASTContext& C) { + SizeExpr->Destroy(C); + delete this; +} /// getArrayElementTypeNoTypeQual - If this is an array type, return the /// element type of the array, potentially with type qualifiers missing. @@ -634,11 +638,12 @@ bool Type::isAggregateType() const { /// isConstantSizeType - Return true if this is not a variable sized type, /// according to the rules of C99 6.7.5p3. It is not legal to call this on -/// incomplete types. +/// incomplete types or dependent types. bool Type::isConstantSizeType() const { if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType)) return ASQT->getBaseType()->isConstantSizeType(); assert(!isIncompleteType() && "This doesn't make sense for incomplete types"); + assert(!isDependentType() && "This doesn't make sense for dependent types"); // The VAT must have a size, as it is known to be complete. return !isa<VariableArrayType>(CanonicalType); } @@ -706,6 +711,7 @@ const char *BuiltinType::getName() const { case LongDouble: return "long double"; case WChar: return "wchar_t"; case Overload: return "<overloaded function type>"; + case Dependent: return "<dependent type>"; } } @@ -780,6 +786,11 @@ QualType TypedefType::LookThroughTypedefs() const { } } +TypeOfExpr::TypeOfExpr(Expr *E, QualType can) + : Type(TypeOfExp, can, E->isTypeDependent()), TOExpr(E) { + assert(!isa<TypedefType>(can) && "Invalid canonical type"); +} + bool RecordType::classof(const TagType *TT) { return isa<RecordDecl>(TT->getDecl()); } @@ -932,6 +943,30 @@ void VariableArrayType::getAsStringInternal(std::string &S) const { getElementType().getAsStringInternal(S); } +void DependentSizedArrayType::getAsStringInternal(std::string &S) const { + S += '['; + + if (getIndexTypeQualifier()) { + AppendTypeQualList(S, getIndexTypeQualifier()); + S += ' '; + } + + if (getSizeModifier() == Static) + S += "static"; + else if (getSizeModifier() == Star) + S += '*'; + + if (getSizeExpr()) { + std::string SStr; + llvm::raw_string_ostream s(SStr); + getSizeExpr()->printPretty(s); + S += s.str(); + } + S += ']'; + + getElementType().getAsStringInternal(S); +} + void VectorType::getAsStringInternal(std::string &S) const { // FIXME: We prefer to print the size directly here, but have no way // to get the size of the type. |