@@ -1010,6 +1010,8 @@ class ThreadSafetyAnalyzer {
1010
1010
ThreadSafetyHandler &Handler;
1011
1011
const FunctionDecl *CurrentFunction;
1012
1012
LocalVariableMap LocalVarMap;
1013
+ // Maps constructed objects to `this` placeholder prior to initialization.
1014
+ llvm::SmallDenseMap<const Expr *, til::LiteralPtr *> ConstructedObjects;
1013
1015
FactManager FactMan;
1014
1016
std::vector<CFGBlockInfo> BlockInfo;
1015
1017
@@ -1543,8 +1545,6 @@ class BuildLockset : public ConstStmtVisitor<BuildLockset> {
1543
1545
FactSet FSet;
1544
1546
// The fact set for the function on exit.
1545
1547
const FactSet &FunctionExitFSet;
1546
- // / Maps constructed objects to `this` placeholder prior to initialization.
1547
- llvm::SmallDenseMap<const Expr *, til::LiteralPtr *> ConstructedObjects;
1548
1548
LocalVariableMap::Context LVarCtx;
1549
1549
unsigned CtxIndex;
1550
1550
@@ -1808,7 +1808,7 @@ void BuildLockset::handleCall(const Expr *Exp, const NamedDecl *D,
1808
1808
std::pair<til::LiteralPtr *, StringRef> Placeholder =
1809
1809
Analyzer->SxBuilder .createThisPlaceholder (Exp);
1810
1810
[[maybe_unused]] auto inserted =
1811
- ConstructedObjects.insert ({Exp, Placeholder.first });
1811
+ Analyzer-> ConstructedObjects .insert ({Exp, Placeholder.first });
1812
1812
assert (inserted.second && " Are we visiting the same expression again?" );
1813
1813
if (isa<CXXConstructExpr>(Exp))
1814
1814
Self = Placeholder.first ;
@@ -2128,10 +2128,10 @@ void BuildLockset::VisitDeclStmt(const DeclStmt *S) {
2128
2128
E = EWC->getSubExpr ()->IgnoreParens ();
2129
2129
E = UnpackConstruction (E);
2130
2130
2131
- if (auto Object = ConstructedObjects.find (E);
2132
- Object != ConstructedObjects.end ()) {
2131
+ if (auto Object = Analyzer-> ConstructedObjects .find (E);
2132
+ Object != Analyzer-> ConstructedObjects .end ()) {
2133
2133
Object->second ->setClangDecl (VD);
2134
- ConstructedObjects.erase (Object);
2134
+ Analyzer-> ConstructedObjects .erase (Object);
2135
2135
}
2136
2136
}
2137
2137
}
@@ -2140,11 +2140,11 @@ void BuildLockset::VisitDeclStmt(const DeclStmt *S) {
2140
2140
void BuildLockset::VisitMaterializeTemporaryExpr (
2141
2141
const MaterializeTemporaryExpr *Exp) {
2142
2142
if (const ValueDecl *ExtD = Exp->getExtendingDecl ()) {
2143
- if (auto Object =
2144
- ConstructedObjects. find ( UnpackConstruction (Exp->getSubExpr ()));
2145
- Object != ConstructedObjects.end ()) {
2143
+ if (auto Object = Analyzer-> ConstructedObjects . find (
2144
+ UnpackConstruction (Exp->getSubExpr ()));
2145
+ Object != Analyzer-> ConstructedObjects .end ()) {
2146
2146
Object->second ->setClangDecl (ExtD);
2147
- ConstructedObjects.erase (Object);
2147
+ Analyzer-> ConstructedObjects .erase (Object);
2148
2148
}
2149
2149
}
2150
2150
}
@@ -2487,15 +2487,15 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
2487
2487
2488
2488
// Clean up constructed object even if there are no attributes to
2489
2489
// keep the number of objects in limbo as small as possible.
2490
- if (auto Object = LocksetBuilder. ConstructedObjects .find (
2490
+ if (auto Object = ConstructedObjects.find (
2491
2491
TD.getBindTemporaryExpr ()->getSubExpr ());
2492
- Object != LocksetBuilder. ConstructedObjects .end ()) {
2492
+ Object != ConstructedObjects.end ()) {
2493
2493
const auto *DD = TD.getDestructorDecl (AC.getASTContext ());
2494
2494
if (DD->hasAttrs ())
2495
2495
// TODO: the location here isn't quite correct.
2496
2496
LocksetBuilder.handleCall (nullptr , DD, Object->second ,
2497
2497
TD.getBindTemporaryExpr ()->getEndLoc ());
2498
- LocksetBuilder. ConstructedObjects .erase (Object);
2498
+ ConstructedObjects.erase (Object);
2499
2499
}
2500
2500
break ;
2501
2501
}
0 commit comments