aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-08-01 18:02:17 +0000
committerSteve Naroff <snaroff@apple.com>2007-08-01 18:02:17 +0000
commit9752f25748d954df99087d741ea35db37ff16bea (patch)
tree0d87ccdb974183f5845adad17fb87e6134311c2e
parent8d1a3b8ca1e5fcc4567b5a6f51d82be2e460de1c (diff)
Add comments to getTypeOfExpr/getTypeOfType.
Also add instances of TypeOfExpr/TypeOfType to the Types vector (so we can keep track of them). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40677 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/ASTContext.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 12de403e3c..899f9c6de6 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -584,16 +584,28 @@ QualType ASTContext::getTypedefType(TypedefDecl *Decl) {
return QualType(Decl->TypeForDecl, 0);
}
+/// getTypeOfExpr - Unlike many "get<Type>" functions, we can't unique
+/// TypeOfExpr AST's (since expression's are never shared). For example,
+/// multiple declarations that refer to "typeof(x)" all contain different
+/// DeclRefExpr's. This doesn't effect the type checker, since it operates
+/// on canonical type's (which are always unique).
QualType ASTContext::getTypeOfExpr(Expr *tofExpr) {
QualType Canonical = tofExpr->getType().getCanonicalType();
- // Note: TypeOfExpr's aren't uniqued.
- return QualType(new TypeOfExpr(tofExpr, Canonical), 0);
+ TypeOfExpr *toe = new TypeOfExpr(tofExpr, Canonical);
+ Types.push_back(toe);
+ return QualType(toe, 0);
}
+/// getTypeOfType - Unlike many "get<Type>" functions, we don't unique
+/// TypeOfType AST's. The only motivation to unique these nodes would be
+/// memory savings. Since typeof(t) is fairly uncommon, space shouldn't be
+/// an issue. This doesn't effect the type checker, since it operates
+/// on canonical type's (which are always unique).
QualType ASTContext::getTypeOfType(QualType tofType) {
QualType Canonical = tofType.getCanonicalType();
- // Note: TypeOfType's aren't uniqued.
- return QualType(new TypeOfType(tofType, Canonical), 0);
+ TypeOfType *tot = new TypeOfType(tofType, Canonical);
+ Types.push_back(tot);
+ return QualType(tot, 0);
}
/// getTagDeclType - Return the unique reference to the type for the