Remove ScopedDecl, collapsing all of its functionality into Decl, so
that every declaration lives inside a DeclContext.
Moved several things that don't have names but were ScopedDecls (and,
therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
store empty DeclarationNames for these things, nor do we try to insert
them into DeclContext's lookup structure.
The serialization tests are temporarily disabled. We'll re-enable them
once we've sorted out the remaining ownership/serialiazation issues
between DeclContexts and TranslationUnion, DeclGroups, etc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62562 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 6729746..6f66307 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -122,8 +122,8 @@
Out << "asm(";
AD->getAsmString()->printPretty(Out);
Out << ")\n";
- } else if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) {
- Out << "Read top-level variable decl: '" << SD->getNameAsString() << "'\n";
+ } else if (NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
+ Out << "Read top-level variable decl: '" << ND->getNameAsString() << "'\n";
} else {
assert(0 && "Unknown decl type!");
}
@@ -480,8 +480,8 @@
}
} else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
PrintTypeDefDecl(TD);
- } else if (ScopedDecl *SD = dyn_cast<ScopedDecl>(D)) {
- Out << "Read top-level variable decl: '" << SD->getNameAsString()
+ } else if (NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
+ Out << "Read top-level variable decl: '" << ND->getNameAsString()
<< "'\n";
} else if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(D)) {
Out << "Read objc interface '" << OID->getNameAsString() << "'\n";
diff --git a/Driver/RewriteBlocks.cpp b/Driver/RewriteBlocks.cpp
index c729a90..706eef8 100644
--- a/Driver/RewriteBlocks.cpp
+++ b/Driver/RewriteBlocks.cpp
@@ -1025,7 +1025,7 @@
for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
DI != DE; ++DI) {
- ScopedDecl *SD = *DI;
+ Decl *SD = *DI;
if (ValueDecl *ND = dyn_cast<ValueDecl>(SD)) {
if (isBlockPointerType(ND->getType()))
RewriteBlockPointerDecl(ND);
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp
index 8af30f2..3c797c5 100644
--- a/Driver/RewriteObjC.cpp
+++ b/Driver/RewriteObjC.cpp
@@ -224,7 +224,7 @@
ObjCImplementationDecl *IMD,
ObjCCategoryImplDecl *CID);
void RewriteInterfaceDecl(ObjCInterfaceDecl *Dcl);
- void RewriteImplementationDecl(NamedDecl *Dcl);
+ void RewriteImplementationDecl(Decl *Dcl);
void RewriteObjCMethodDecl(ObjCMethodDecl *MDecl, std::string &ResultStr);
void RewriteCategoryDecl(ObjCCategoryDecl *Dcl);
void RewriteProtocolDecl(ObjCProtocolDecl *Dcl);
@@ -967,7 +967,7 @@
}
}
}
-void RewriteObjC::RewriteImplementationDecl(NamedDecl *OID) {
+void RewriteObjC::RewriteImplementationDecl(Decl *OID) {
ObjCImplementationDecl *IMD = dyn_cast<ObjCImplementationDecl>(OID);
ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(OID);
@@ -1297,7 +1297,7 @@
buf = "\n{\n\t";
if (DeclStmt *DS = dyn_cast<DeclStmt>(S->getElement())) {
// type elem;
- ScopedDecl* D = DS->getSolitaryDecl();
+ NamedDecl* D = cast<NamedDecl>(DS->getSolitaryDecl());
QualType ElementType = cast<ValueDecl>(D)->getType();
elementTypeAsString = ElementType.getAsString();
buf += elementTypeAsString;
@@ -1920,7 +1920,7 @@
SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SelGetUidIdent, getFuncType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
// SynthGetProtocolFunctionDecl - Protocol objc_getProtocol(const char *proto);
@@ -1935,7 +1935,7 @@
GetProtocolFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SelGetProtoIdent, getFuncType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) {
@@ -1964,7 +1964,7 @@
SuperContructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
// SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...);
@@ -1983,7 +1983,7 @@
MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
// SynthMsgSendSuperFunctionDecl - id objc_msgSendSuper(struct objc_super *, SEL op, ...);
@@ -2005,7 +2005,7 @@
MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
// SynthMsgSendStretFunctionDecl - id objc_msgSend_stret(id self, SEL op, ...);
@@ -2024,7 +2024,7 @@
MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
// SynthMsgSendSuperStretFunctionDecl -
@@ -2048,7 +2048,7 @@
MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
// SynthMsgSendFpretFunctionDecl - double objc_msgSend_fpret(id self, SEL op, ...);
@@ -2067,7 +2067,7 @@
MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
// SynthGetClassFunctionDecl - id objc_getClass(const char *name);
@@ -2082,7 +2082,7 @@
GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
getClassIdent, getClassType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
// SynthGetMetaClassFunctionDecl - id objc_getClass(const char *name);
@@ -2097,7 +2097,7 @@
GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
getClassIdent, getClassType,
- FunctionDecl::Extern, false, 0);
+ FunctionDecl::Extern, false);
}
Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
@@ -2131,7 +2131,7 @@
VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
&Context->Idents.get(S.c_str()), strType,
- VarDecl::Static, NULL);
+ VarDecl::Static);
DeclRefExpr *DRE = new DeclRefExpr(NewVD, strType, SourceLocation());
Expr *Unop = new UnaryOperator(DRE, UnaryOperator::AddrOf,
Context->getPointerType(DRE->getType()),
@@ -2175,7 +2175,7 @@
SuperStructDecl->addDecl(FieldDecl::Create(*Context, SuperStructDecl,
SourceLocation(), 0,
FieldTypes[i], /*BitWidth=*/0,
- /*Mutable=*/false, 0));
+ /*Mutable=*/false));
}
SuperStructDecl->completeDefinition(*Context);
@@ -2206,7 +2206,7 @@
SourceLocation(), 0,
FieldTypes[i],
/*BitWidth=*/0,
- /*Mutable=*/true, 0));
+ /*Mutable=*/true));
}
ConstantStringDecl->completeDefinition(*Context);
@@ -3816,7 +3816,7 @@
FieldDecl *FD = FieldDecl::Create(*Context, 0, SourceLocation(),
&Context->Idents.get("FuncPtr"), Context->VoidPtrTy,
- /*BitWidth=*/0, /*Mutable=*/true, 0);
+ /*BitWidth=*/0, /*Mutable=*/true);
MemberExpr *ME = new MemberExpr(PE, true, FD, SourceLocation(), FD->getType());
CastExpr *FunkCast = new CStyleCastExpr(PtrToFuncCastType, ME, PtrToFuncCastType, SourceLocation(), SourceLocation());
@@ -4021,7 +4021,7 @@
IdentifierInfo *ID = &Context->Idents.get(name);
QualType FType = Context->getFunctionTypeNoProto(Context->VoidPtrTy);
return FunctionDecl::Create(*Context, TUDecl,SourceLocation(),
- ID, FType, FunctionDecl::Extern, false, 0);
+ ID, FType, FunctionDecl::Extern, false);
}
Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
@@ -4304,7 +4304,7 @@
// Blocks rewrite rules.
for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
DI != DE; ++DI) {
- ScopedDecl *SD = *DI;
+ Decl *SD = *DI;
if (ValueDecl *ND = dyn_cast<ValueDecl>(SD)) {
if (isTopLevelBlockPointerType(ND->getType()))
RewriteBlockPointerDecl(ND);