diff options
author | Kaelyn Takata <rikka@google.com> | 2014-10-27 18:07:37 +0000 |
---|---|---|
committer | Kaelyn Takata <rikka@google.com> | 2014-10-27 18:07:37 +0000 |
commit | 6c759519bb374cbe9866d602665f4048b597a7e6 (patch) | |
tree | 7ad06cf4580b95d96ea34734b742f3ac9ea1aee5 /clang/lib/Sema/SemaExpr.cpp | |
parent | 0d6a3edccedde68f8042026dfee6ed772796d0d9 (diff) | |
download | bcm5719-llvm-6c759519bb374cbe9866d602665f4048b597a7e6.tar.gz bcm5719-llvm-6c759519bb374cbe9866d602665f4048b597a7e6.zip |
Start adding the infrastructure for handling TypoExprs.
Part of the infrastructure is a map from a TypoExpr to the Sema-specific
state needed to correct it, along with helpers to ease dealing with the
state.
The the typo count is propagated up the stack of
ExpressionEvaluationContextRecords when one is popped off of to
avoid accidentally dropping TypoExprs on the floor. For example,
the attempted correction of g() in test/CXX/class/class.mem/p5-0x.cpp
happens with an ExpressionEvaluationContextRecord that is popped off
the stack prior to ActOnFinishFullExpr being called and the tree
transform for TypoExprs being run.
llvm-svn: 220695
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 10814081954..8c13f89c0b3 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -11286,6 +11286,7 @@ Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, void Sema::PopExpressionEvaluationContext() { ExpressionEvaluationContextRecord& Rec = ExprEvalContexts.back(); + unsigned NumTypos = Rec.NumTypos; if (!Rec.Lambdas.empty()) { if (Rec.isUnevaluated() || Rec.Context == ConstantEvaluated) { @@ -11333,6 +11334,12 @@ void Sema::PopExpressionEvaluationContext() { // Pop the current expression evaluation context off the stack. ExprEvalContexts.pop_back(); + + if (!ExprEvalContexts.empty()) + ExprEvalContexts.back().NumTypos += NumTypos; + else + assert(NumTypos == 0 && "There are outstanding typos after popping the " + "last ExpressionEvaluationContextRecord"); } void Sema::DiscardCleanupsInEvaluationContext() { |