[PATCH] D115386: AST: Avoid using SmallVector::set_size() in UnresolvedSet
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 8 16:45:17 PST 2021
dexonsmith added inline comments.
================
Comment at: clang/lib/Sema/SemaLookup.cpp:623
- Decls.set_size(N);
+ Decls.truncate(N);
----------------
Two things to confirm here.
First is that the destructors are trivial. From clang/include/clang/AST/DeclAccessPair.h:
```
lang=c++
class DeclAccessPair {
uintptr_t Ptr; // we'd use llvm::PointerUnion, but it isn't trivial
```
(If they hadn't been trivial, then hypothetically there could been other code somewhere that ran the destructors later...)
Second is that `set_size()` was only used for truncation. I confirmed that that three ways:
- Looking backward, `N` starts as `Decls.size()` and the only changes are decrement operatoers.
- Looking forward, there's no code that would initialize / assign to the new member (so if it increased size, it would likely have led to problems elsewhere).
- Tests pass.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115386/new/
https://reviews.llvm.org/D115386
More information about the cfe-commits
mailing list