diff options
author | Kaelyn Takata <rikka@google.com> | 2014-11-21 18:48:00 +0000 |
---|---|---|
committer | Kaelyn Takata <rikka@google.com> | 2014-11-21 18:48:00 +0000 |
commit | b108f094f02cca962eb0bdfafc9fdd7f86ae3b93 (patch) | |
tree | 40939620100e0cd2aee49366a2ce225c3ccb0870 /lib/Sema/SemaDecl.cpp | |
parent | 7f0ea0ae7a555c89a598434b1ad147dfcd4f1e3b (diff) |
Properly correct initializer expressions based on whether they would be valid.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222550 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d44f141776..08f5c3c8b8 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -8799,6 +8799,23 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, Args = MultiExprArg(CXXDirectInit->getExprs(), CXXDirectInit->getNumExprs()); + // Try to correct any TypoExprs if there might be some in the initialization + // arguments (TypoExprs are marked as type-dependent). + // TODO: Handle typo correction when there's more than one argument? + if (Args.size() == 1 && Expr::hasAnyTypeDependentArguments(Args)) { + ExprResult Res = + CorrectDelayedTyposInExpr(Args[0], [this, Entity, Kind](Expr *E) { + InitializationSequence Init(*this, Entity, Kind, MultiExprArg(E)); + return Init.Failed() ? ExprError() : E; + }); + if (Res.isInvalid()) { + VDecl->setInvalidDecl(); + return; + } + if (Res.get() != Args[0]) + Args[0] = Res.get(); + } + InitializationSequence InitSeq(*this, Entity, Kind, Args); ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Args, &DclT); if (Result.isInvalid()) { |