summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2014-11-20 22:06:44 +0000
committerKaelyn Takata <rikka@google.com>2014-11-20 22:06:44 +0000
commit57e07c950d858229249b362c0ae3b49401e40b17 (patch)
tree3bde032f120d1d77b17594a8f9684eb385f49fe3 /clang/lib/Sema/SemaExprCXX.cpp
parentb16e632c64666bfab88518b369ecaab989a4915d (diff)
downloadbcm5719-llvm-57e07c950d858229249b362c0ae3b49401e40b17.tar.gz
bcm5719-llvm-57e07c950d858229249b362c0ae3b49401e40b17.zip
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). llvm-svn: 222465
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 94da5f22d66..35211a28a52 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud