This was regressed in ca619613801233ef2def8c3cc7d311d5ed0033cb. As we
attached InitExprs as-is to the AST, without performing transformations.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Randomly chiming in here.
I never had a good model of where CorrectDelayedTyposInExpr, but wanted to note that ActOnFullExpr also calls it. This may be fine, I just wanted to mention it as it stood out.
clang/lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
4101–4105 | Should we pass FD here to avoid correcting to itself? |
+1, we seem to call CorrectDelayedTyposInExpr in an ad-hoc way.
The fix looks good to me, but I will leave the final stamp to @aaron.ballman, @cor3ntin.
clang/test/PCH/typo3.cpp | ||
---|---|---|
7 | IIUC, the issue is that, we have a dangling TypoExpr under the FieldDecl in the final AST, which violates the contract of TypoExpr. |
clang/lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
4103 | Should we be checking for Init.isUsable() before calling .get()? |
clang/lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
4101–4105 | unfortunately the interface requires a VarDecl, hence we can't pass a FieldDecl. | |
4103 | because InitExpr is never null here (we bail out early), and because we're converting any leftover TypoExprs to RecoveryExpr Init should always be Usable here. adding an assert. | |
clang/test/PCH/typo3.cpp | ||
7 | yes |
clang/lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
4101–4105 | Ah, it also does not seem to suggest any FieldDecls for typo correction. Nevermind then, sorry for the noise. |
Should we be checking for Init.isUsable() before calling .get()?