The goal of this commit is to get just enough Sema support to recognize Objective-C classes
as types. That said, the AST nodes ObjcInterfaceDecl, ObjcInterfaceType, and ObjcClassDecl are *very*
preliminary.
The good news is we no longer need -parse-noop (aka MinimalActions) to parse cocoa.m.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41752 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 8879336..7e9f5e9 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -596,6 +596,16 @@
return QualType(Decl->TypeForDecl, 0);
}
+/// getObjcInterfaceType - Return the unique reference to the type for the
+/// specified ObjC interface decl.
+QualType ASTContext::getObjcInterfaceType(ObjcInterfaceDecl *Decl) {
+ if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
+
+ Decl->TypeForDecl = new ObjcInterfaceType(Decl);
+ Types.push_back(Decl->TypeForDecl);
+ 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
diff --git a/AST/Decl.cpp b/AST/Decl.cpp
index f4a346f..5f87d93 100644
--- a/AST/Decl.cpp
+++ b/AST/Decl.cpp
@@ -25,6 +25,7 @@
static unsigned nEnumDecls = 0;
static unsigned nTypedef = 0;
static unsigned nFieldDecls = 0;
+static unsigned nInterfaceDecls = 0;
static bool StatSwitch = false;
bool Decl::CollectingStats(bool enable) {
@@ -101,6 +102,9 @@
case Enum:
nEnumDecls++;
break;
+ case ObjcInterface:
+ nInterfaceDecls++;
+ break;
}
}
diff --git a/AST/Type.cpp b/AST/Type.cpp
index 26bfbe2..f7779bc 100644
--- a/AST/Type.cpp
+++ b/AST/Type.cpp
@@ -836,6 +836,12 @@
InnerString = getDecl()->getIdentifier()->getName() + InnerString;
}
+void ObjcInterfaceType::getAsStringInternal(std::string &InnerString) const {
+ if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
+ InnerString = ' ' + InnerString;
+ InnerString = getDecl()->getIdentifier()->getName() + InnerString;
+}
+
void TagType::getAsStringInternal(std::string &InnerString) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString;