[clang] Thread safety analysis: Fix a bug in handling temporary constructors (PR #74020)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 4 16:01:50 PST 2023


================
@@ -2487,15 +2486,15 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
 
           // Clean up constructed object even if there are no attributes to
           // keep the number of objects in limbo as small as possible.
-          if (auto Object = LocksetBuilder.ConstructedObjects.find(
+          if (auto Object = LocksetBuilder.Analyzer->ConstructedObjects.find(
                   TD.getBindTemporaryExpr()->getSubExpr());
-              Object != LocksetBuilder.ConstructedObjects.end()) {
+              Object != LocksetBuilder.Analyzer->ConstructedObjects.end()) {
             const auto *DD = TD.getDestructorDecl(AC.getASTContext());
             if (DD->hasAttrs())
               // TODO: the location here isn't quite correct.
               LocksetBuilder.handleCall(nullptr, DD, Object->second,
                                         TD.getBindTemporaryExpr()->getEndLoc());
-            LocksetBuilder.ConstructedObjects.erase(Object);
+            LocksetBuilder.Analyzer->ConstructedObjects.erase(Object);
----------------
aaronpuchert wrote:

We're in `ThreadSafetyAnalyzer` here, so you should be able to drop `LocksetBuilder.Analyzer->` and refer to the member directly.

https://github.com/llvm/llvm-project/pull/74020


More information about the cfe-commits mailing list