[PATCH] D137263: add boundary check for ASTUnresolvedSet::erase
zhouyizhou via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 6 14:32:17 PST 2022
zhouyizhou updated this revision to Diff 473509.
zhouyizhou added a comment.
Thank Ray for your guidance!
I achieved a lot in the process ;-)
Thanks
Zhouyi
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137263/new/
https://reviews.llvm.org/D137263
Files:
clang/include/clang/AST/ASTUnresolvedSet.h
clang/test/SemaCXX/using-decl-templates.cpp
Index: clang/test/SemaCXX/using-decl-templates.cpp
===================================================================
--- clang/test/SemaCXX/using-decl-templates.cpp
+++ clang/test/SemaCXX/using-decl-templates.cpp
@@ -102,6 +102,28 @@
};
} // namespace DontDiagnoseInvalidTest
+namespace shadow_nested_operator {
+ template <typename T>
+ struct A {
+ struct Nested {};
+ operator Nested*() {return 0;};
+ };
+
+ template <typename T>
+ struct B : A<T> {
+ using A<T>::operator typename A<T>::Nested*;
+ operator typename A<T>::Nested *() {
+ struct A<T> * thi = this;
+ return *thi;
+ };
+ };
+
+ int foo () {
+ struct B<int> b;
+ auto s = *b;
+ }
+} // namespace shadow_nested_operator
+
namespace func_templ {
namespace sss {
double foo(int, double);
Index: clang/include/clang/AST/ASTUnresolvedSet.h
===================================================================
--- clang/include/clang/AST/ASTUnresolvedSet.h
+++ clang/include/clang/AST/ASTUnresolvedSet.h
@@ -69,7 +69,12 @@
return false;
}
- void erase(unsigned I) { Decls[I] = Decls.pop_back_val(); }
+ void erase(unsigned I) {
+ if (I == Decls.size() - 1)
+ Decls.pop_back();
+ else
+ Decls[I] = Decls.pop_back_val();
+ }
void clear() { Decls.clear(); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137263.473509.patch
Type: text/x-patch
Size: 1299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221106/bfab7b0a/attachment-0001.bin>
More information about the cfe-commits
mailing list