[PATCH] D22419: [CFG] Fix crash in thread sanitizer.
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 26 02:17:56 PDT 2016
NoQ added a comment.
Thanks for working on this!
While i probably won't be of much help (no expert in temporaries yet), i notice that this code piece (with `getReferenceInitTemporaryType()`) seems to be duplicated at least three times in this file, with slight variations and FIXMEs. So i guess this needs some care, not necessarily in this patch.
================
Comment at: lib/Analysis/CFG.cpp:3910
@@ +3909,3 @@
+ // temporary in an initializer expression.
+ if (ty.getTypePtr()->isReferenceType()) {
+ if (const Expr *Init = var->getInit()) {
----------------
Simple `ty->isReferenceType()` should work as well (the overloaded `operator ->()` in `QualType`).
================
Comment at: lib/Analysis/CFG.cpp:3912-3914
@@ +3911,5 @@
+ if (const Expr *Init = var->getInit()) {
+ if (const ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(Init))
+ Init = EWC->getSubExpr();
+ if (isa<MaterializeTemporaryExpr>(Init))
+ ty = getReferenceInitTemporaryType(astContext, Init);
----------------
Is this sequence of checks certainly needed? All tests seem to pass without it. Or maybe it's also needed in `addAutomaticObjectDtors()`? Perhaps just nest these checks inside `getReferenceInitTemporaryType()`?
https://reviews.llvm.org/D22419
More information about the cfe-commits
mailing list