Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.
Patch by David Chisnall!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52422 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 8b355e9..bf7efe8 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -308,6 +308,20 @@
static VarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
};
+class ImplicitParamDecl : public VarDecl {
+protected:
+ ImplicitParamDecl(Kind DK, DeclContext *DC, SourceLocation L,
+ IdentifierInfo *Id, QualType T, ScopedDecl *PrevDecl)
+ : VarDecl(DK, DC, L, Id, T, VarDecl::None, PrevDecl) {}
+public:
+ static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation L, IdentifierInfo *Id,
+ QualType T, ScopedDecl *PrevDecl);
+ // Implement isa/cast/dyncast/etc.
+ static bool classof(const ImplicitParamDecl *D) { return true; }
+ static bool classof(const Decl *D) { return D->getKind() == ImplicitParam; }
+};
+
/// ParmVarDecl - Represent a parameter to a function.
class ParmVarDecl : public VarDecl {
// NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 60387b1..55c2e61 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -69,6 +69,7 @@
Function, // [DeclContext]
CXXMethod,
Var,
+ ImplicitParam,
CXXClassVar,
ParmVar,
ObjCInterface, // [DeclContext]
@@ -172,6 +173,7 @@
IdentifierNamespace getIdentifierNamespace() const {
switch (DeclKind) {
default: assert(0 && "Unknown decl kind!");
+ case ImplicitParam:
case Typedef:
case Function:
case Var:
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index be1e888..093a5cf 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -91,7 +91,9 @@
// The following are only used for method definitions, null otherwise.
// FIXME: space savings opportunity, consider a sub-class.
Stmt *Body;
- ParmVarDecl *SelfDecl;
+ // Decls for implicit parameters
+ ImplicitParamDecl *SelfDecl;
+ ImplicitParamDecl *CmdDecl;
ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
Selector SelInfo, QualType T,
@@ -107,8 +109,8 @@
DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
MethodContext(static_cast<NamedDecl*>(contextDecl)),
SelName(SelInfo), MethodDeclType(T),
- ParamInfo(0), NumMethodParams(0),
- MethodAttrs(M), EndLoc(endLoc), Body(0), SelfDecl(0) {}
+ ParamInfo(0), NumMethodParams(0), MethodAttrs(M),
+ EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
virtual ~ObjCMethodDecl();
@@ -164,6 +166,11 @@
ParamInfo[i] = pDecl;
}
void setMethodParams(ParmVarDecl **NewParamInfo, unsigned NumParams);
+
+ ImplicitParamDecl * getSelfDecl() const { return SelfDecl; }
+ void setSelfDecl(ImplicitParamDecl *decl) { SelfDecl = decl; }
+ ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
+ void setCmdDecl(ImplicitParamDecl *decl) { CmdDecl = decl; }
AttributeList *getMethodAttrs() const {return MethodAttrs;}
bool isInstance() const { return IsInstance; }
@@ -182,10 +189,6 @@
const Stmt *getBody() const { return Body; }
void setBody(Stmt *B) { Body = B; }
- const ParmVarDecl *getSelfDecl() const { return SelfDecl; }
- ParmVarDecl *getSelfDecl() { return SelfDecl; }
- void setSelfDecl(ParmVarDecl *PVD) { SelfDecl = PVD; }
-
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == ObjCMethod; }
static bool classof(const ObjCMethodDecl *D) { return true; }
diff --git a/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h b/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
index fab14c3..754bbb4 100644
--- a/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
+++ b/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
@@ -56,6 +56,7 @@
DISPATCH_CASE(Function,FunctionDecl)
DISPATCH_CASE(Var,VarDecl)
DISPATCH_CASE(ParmVar,ParmVarDecl) // FIXME: (same)
+ DISPATCH_CASE(ImplicitParam,ImplicitParamDecl)
DISPATCH_CASE(EnumConstant,EnumConstantDecl)
DISPATCH_CASE(Typedef,TypedefDecl)
DISPATCH_CASE(Struct,RecordDecl) // FIXME: Refine. VisitStructDecl?
@@ -70,6 +71,7 @@
DEFAULT_DISPATCH(VarDecl)
DEFAULT_DISPATCH(FunctionDecl)
DEFAULT_DISPATCH_VARDECL(ParmVarDecl)
+ DEFAULT_DISPATCH(ImplicitParamDecl)
DEFAULT_DISPATCH(EnumConstantDecl)
DEFAULT_DISPATCH(TypedefDecl)
DEFAULT_DISPATCH(RecordDecl)