[PATCH] D142187: [clang] Fix typos in member initializers

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 20 05:24:08 PST 2023


kadircet marked 3 inline comments as done.
kadircet added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:4101
 
-  ExprResult Init = InitExpr;
-  if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent()) {
-    Init = ConvertMemberDefaultInitExpression(FD, InitExpr, InitLoc);
+  ExprResult Init = CorrectDelayedTyposInExpr(InitExpr, /*InitDecl=*/nullptr,
+                                              /*RecoverUncorrectedTypos=*/true);
----------------
ilya-biryukov wrote:
> Should we pass `FD` here to avoid correcting to itself?
unfortunately the interface requires a VarDecl, hence we can't pass a FieldDecl.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:4103
+                                              /*RecoverUncorrectedTypos=*/true);
+  if (!FD->getType()->isDependentType() && !Init.get()->isTypeDependent()) {
+    Init = ConvertMemberDefaultInitExpression(FD, Init.get(), InitLoc);
----------------
aaron.ballman wrote:
> Should we be checking for `Init.isUsable()` before calling `.get()`?
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.


================
Comment at: clang/test/PCH/typo3.cpp:6
+  // in PCH.
+  int y = bar;
+  // CHECK: use of undeclared identifier 'bar'
----------------
hokein wrote:
> IIUC, the issue is that, we have a dangling `TypoExpr` under the `FieldDecl` in the final AST, which violates the contract of `TypoExpr`.
yes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142187/new/

https://reviews.llvm.org/D142187



More information about the cfe-commits mailing list