diff options
author | Kaelyn Takata <rikka@google.com> | 2014-11-20 22:06:44 +0000 |
---|---|---|
committer | Kaelyn Takata <rikka@google.com> | 2014-11-20 22:06:44 +0000 |
commit | feea241eacd2e89751d297322fa74c7ce239d2e4 (patch) | |
tree | 9ca68cabc0ee1f8eb96ee6d6cd89059a56f0bd34 /lib/Sema/SemaExprCXX.cpp | |
parent | b11b40a67ef9847447d3066fad06698dd9c317d2 (diff) |
Ensure all TypoExprs are diagnosed by the tree transform.
If there is more than one TypoExpr within the expr being transformed and
any but the last TypoExpr seen don't have any viable candidates, the
tree transform will be aborted early and the remaining TypoExprs are
never seen and hence never diagnosed. This adds a simple
RecursiveASTVisitor to find all of the TypoExprs to be diagnosed in the
case where typo correction of the entire expr fails (and the result of
the tree transform is an ExprError).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222465 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 94da5f22d6..35211a28a5 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -5976,6 +5976,18 @@ static ExprResult attemptRecovery(Sema &SemaRef, } namespace { +class FindTypoExprs : public RecursiveASTVisitor<FindTypoExprs> { + llvm::SmallSetVector<TypoExpr *, 2> &TypoExprs; + +public: + explicit FindTypoExprs(llvm::SmallSetVector<TypoExpr *, 2> &TypoExprs) + : TypoExprs(TypoExprs) {} + bool VisitTypoExpr(TypoExpr *TE) { + TypoExprs.insert(TE); + return true; + } +}; + class TransformTypos : public TreeTransform<TransformTypos> { typedef TreeTransform<TransformTypos> BaseTransform; @@ -6084,6 +6096,10 @@ public: break; } + // Ensure that all of the TypoExprs within the current Expr have been found. + if (!res.isUsable()) + FindTypoExprs(TypoExprs).TraverseStmt(E); + EmitAllDiagnostics(); return res; |