Skip to content

Commit ec2a592

Browse files
committed
Remove the unused StmtClone clone mapping. NFC
StmtCloneMapping recorded, for each cloned Stmt and VarDecl, the original it came from. Nothing ever read either map, and no caller passed a mapping in the first place -- the sole StmtClone is constructed without one -- so m_OriginalToClonedStmts was permanently null and both writes were dead. Drop the struct, the member, the typedefs and the two writes. Cloning that must remap references to its clones does so through m_DeclReplacements, which the callers already maintain.
1 parent 5538c90 commit ec2a592

2 files changed

Lines changed: 3 additions & 24 deletions

File tree

include/clad/Differentiator/StmtClone.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,11 @@ namespace clang {
2828
namespace clad {
2929
namespace utils {
3030

31-
struct StmtCloneMapping;
32-
3331
class StmtClone : public clang::StmtVisitor<StmtClone, clang::Stmt*> {
3432
public:
35-
// first: original stmt, second: appropriate cloned stmt
36-
typedef llvm::DenseMap<const clang::Stmt*, clang::Stmt*> StmtMapping;
37-
typedef llvm::DenseMap<clang::ValueDecl*, clang::ValueDecl*> DeclMapping;
38-
typedef StmtCloneMapping Mapping;
39-
4033
private:
4134
clang::Sema& m_Sema;
4235
clang::ASTContext& Ctx;
43-
Mapping* m_OriginalToClonedStmts;
4436
// While cloning a PseudoObjectExpr, maps each original OpaqueValueExpr to
4537
// its clone so the syntactic form and the semantic expressions reference
4638
// the same fresh OVE (null outside such a clone). See
@@ -52,8 +44,8 @@ namespace utils {
5244
clang::VarDecl* CloneDeclOrNull(clang::VarDecl* Node);
5345

5446
public:
55-
StmtClone(clang::Sema& sema, clang::ASTContext& ctx, Mapping* originalToClonedStmts = 0)
56-
: m_Sema(sema), Ctx(ctx), m_OriginalToClonedStmts(originalToClonedStmts) {}
47+
StmtClone(clang::Sema& sema, clang::ASTContext& ctx)
48+
: m_Sema(sema), Ctx(ctx) {}
5749

5850
template<class StmtTy>
5951
StmtTy* Clone(const StmtTy* S);
@@ -141,22 +133,12 @@ namespace utils {
141133
clang::Stmt* VisitStmt(clang::Stmt*);
142134
};
143135

144-
// Not a StmtClone member class to make it forwardable:
145-
struct StmtCloneMapping {
146-
StmtClone::StmtMapping m_StmtMapping;
147-
StmtClone::DeclMapping m_DeclMapping;
148-
};
149-
150136
template<class StmtTy>
151137
StmtTy* StmtClone::Clone(const StmtTy* S) {
152138
if (!S)
153139
return 0;
154140

155141
clang::Stmt* clonedStmt = Visit(const_cast<StmtTy*>(S));
156-
157-
if (m_OriginalToClonedStmts)
158-
m_OriginalToClonedStmts->m_StmtMapping[S] = clonedStmt;
159-
160142
return static_cast<StmtTy*>(clonedStmt);
161143
}
162144

lib/Differentiator/StmtClone.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,7 @@ Decl* StmtClone::CloneDecl(Decl* Node) {
614614
if (VD->getInit())
615615
m_Sema.AddInitializerToDecl(cloned_Decl, Clone(VD->getInit()), VD->isDirectInit());
616616
cloned_Decl->setTSCSpec(VD->getTSCSpec());
617-
//cloned_Decl->setDeclaredInCondition(VD->isDeclaredInCondition());
618-
if (m_OriginalToClonedStmts != 0)
619-
m_OriginalToClonedStmts->m_DeclMapping[VD] = cloned_Decl;
620-
617+
// cloned_Decl->setDeclaredInCondition(VD->isDeclaredInCondition());
621618
return cloned_Decl;
622619
}
623620
assert(0 && "other decl clones aren't supported");

0 commit comments

Comments
 (0)