llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Akira Hatanaka (ahatanak)

<details>
<summary>Changes</summary>

operator[] can potentially cause reallocation and invalidate live iterators if 
it's called with a key that isn't present in the DenseMap. Call lookup() 
instead to prevent the function from inserting new entries into the DenseMap 
for ObjC classes that don't have any subclasses.

rdar://165448332

---
Full diff: https://github.com/llvm/llvm-project/pull/170360.diff


1 Files Affected:

- (modified) clang/lib/AST/ASTContext.cpp (+1-1) 


``````````diff
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b359fc8350375..404ce3ffd77c7 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -12040,7 +12040,7 @@ bool ASTContext::mergeExtParameterInfo(
 void ASTContext::ResetObjCLayout(const ObjCInterfaceDecl *D) {
   if (auto It = ObjCLayouts.find(D); It != ObjCLayouts.end()) {
     It->second = nullptr;
-    for (auto *SubClass : ObjCSubClasses[D])
+    for (auto *SubClass : ObjCSubClasses.lookup(D))
       ResetObjCLayout(SubClass);
   }
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/170360
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to