summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2014-11-21 18:48:00 +0000
committerKaelyn Takata <rikka@google.com>2014-11-21 18:48:00 +0000
commitb108f094f02cca962eb0bdfafc9fdd7f86ae3b93 (patch)
tree40939620100e0cd2aee49366a2ce225c3ccb0870 /lib/Sema/SemaDecl.cpp
parent7f0ea0ae7a555c89a598434b1ad147dfcd4f1e3b (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.cpp17
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()) {