[PATCH] D131866: [clang] fix frontend crash in auto type templates
Matheus Izvekov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 14 15:37:12 PDT 2022
mizvekov added inline comments.
================
Comment at: clang/lib/AST/ASTContext.cpp:5735-5736
// Find the insert position again.
- AutoTypes.FindNodeOrInsertPos(ID, InsertPos);
+ if (AutoType *AT = AutoTypes.FindNodeOrInsertPos(ID, InsertPos))
+ return QualType(AT, 0);
}
----------------
The original code is correct, `AutoTypes.FindNodeOrInsertPos(ID, InsertPos)` returning non-null should be impossible here, as we are just refreshing the insert position after having possibly invalidated it when we created the canonical node.
We had looked for the node before and didn't find it, so finding it just after having created the canonical node means this is a canonicalization bug.
I think this could have used an assert on the return value to better explain that is going on.
FWIW, someone else already started working on this bug some time ago, and I made some comments there which I think explain the problem better: See https://reviews.llvm.org/D126172
Might be worth a ping since might have stalled on it though.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131866/new/
https://reviews.llvm.org/D131866
More information about the cfe-commits
mailing list